Welcome to the Wolfire Blog! This is where we keep everyone up to date on our progress on Overgrowth and other new stuff. Be sure to subscribe to get the latest news! Also, be sure to check out the forums for even more up to date news - or get on IRC for up to the second updates.

Soft Particles

Add Comment! By David Rosen on April 28th, 2010

In games, particle effects like smoke or fire are drawn as image squares that always face torwards the camera. This looks fine in most cases, but the illusion is destroyed when these particles intersect with the environment and reveal a flat intersection line. Below you can see the flat intersection of a 'hard' smoke particle on the left, and the smooth intersection of a 'soft' smoke particle on the right.

Soft particle comparison

To make it easier to see what's going on, here are the same particles without the smoke image:

Untextured particle comparison

To achieve this effect, I had to use the depth buffer, which we already store for use with post-processing (as explained in the post-processing video). Here is the depth buffer for this scene:

Depth buffer

Now to soften the intersection line, we can adjust the opacity of the square based on how close it is to the surface behind it. To do this, we can subtract the particle's depth from the environment's depth. Below you can see the environment depth on the left, the particle depth in the middle, and the difference on the right.

Depth buffer subtraction

Now that we have the difference between the particle depth and the background depth for each pixel, we can decide how transparent the pixel should be. I decided to make the opacity fall off linearly, as if the particle were a volumetric cube. I also offset the center of the particle so that the midpoint of the falloff lined up with the midpoint of the original hard particle.

Here is another example of a soft smoke particle intersecting a complex scene:

Stairs stress test

You might be wondering, "Why go to all this effort for particles in Overgrowth? It's not a war game full of explosions or an RPG full of magic spells!" That's true, but particles are still important for many natural effects. For example, drifting fog, sandstorm clouds, falling rain, impact dust, blood spray, and breath mist in cold weather.

Do you have any questions about how these soft particles work, or ideas about how we could improve them? Please let me know in the comments!