Website powered by

OTG - Toxic Smoke Optimization

One of my main tasks at Gunzilla Games is reviewing and optimising all the effects in "Off The Grid". One of the effects that had the biggest impact on performance was a smoke propagation effect.

When a projectile is fired, it releases a toxic smoke that spreads across the surrounding area, damaging players within it and reducing visibility.

The effect’s logic was implemented by the programming team. The effect works on a grid system: starting from the point of impact as the central cell, neighboring cells are checked progressively, and if a cell contains no obstacles, the effect propagates into that cell.

The pre-existing effect spawned a Niagara System with smoke particles for each cell, which caused several performance issues:

Since there was a particle system for every cell, dozens or even hundreds of Niagara Systems could exist simultaneously, generating a significant CPU cost. This problem could worsen if multiple smoke effects were spawned in the same area.

Having many smoke particles in the same space caused high overdraw, resulting in a heavy GPU cost.

To solve these issues, a hybrid solution combining a volumetric material with smoke particles was implemented.

The volumetric material added density to the effect without requiring multiple overlapping particles, solving the overdraw problem and reducing GPU cost.

To transfer the positions from code to the material, a very small texture (around 8 x 16 pixels) was used, containing the normalized position of each cell within the effect’s domain. Spheres were drawn at these positions using Signed Distance Fields (SDF), which merged together, and multiple 3D textures packed into a single map were applied to break the sphere shapes, giving the effect a realistic smoke appearance.

Because the smoke could appear too soft or blurry, additional smoke particles were added around the edges to give the effect a sharper look. To avoid overdraw, these particles were culled when the player was too far or too close. To prevent having multiple particle systems in the same area, Niagara Data Channels were used, so all smoke particles in a region were contained in a single system, solving the CPU cost issue.

Additionally, several scalability options were configured to ensure the effect ran efficiently on a variety of devices.

The initial smoke particle and the "splash" effect were created by the VFX team. The post processing effect triggered when the player enters the smoke was created by the VFX and Technical Art team.