Post news Report RSS Soft particles

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.

Posted by on

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.

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

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:

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.

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:

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!



Track us
on ModDB (visit our page)

Please join us here too:
Facebook icon ModDB icon Steam icon Twitter icon YouTube icon

Post comment Comments
Nebcake
Nebcake - - 443 comments

Great news as always guys, and particles rock in everything.

Reply Good karma Bad karma+4 votes
DariusII
DariusII - - 64 comments

Really appreciate the informative tech posts. I never knew exactly how this was done in games, but now I do. One problem that I see in games (even current ones such as MW2) is the problem with screen overdraw when you have several large sprites overlap each other. For example, when someone throws a smoke grenade in MW2, the FPS will drop considerably as the player gets closer to the smoke clouds.
Source engine games alleviate this by actually putting a grey overlay on the screen and not rendering any smoke sprites that are too close/too large on the screen. It's kind of a hacky method but it works decently enough.
Do you guys have a system to combat overdraw of alpha sprites when too many of them overlap and fill up the screen?

It's funny how video cards have advanced so much over the past decade allowing us to spit out more and more fancy polygons, but the problem with rendering overlapping alpha sprites is still a big bottleneck for video cards.

Reply Good karma Bad karma+10 votes
doublethink
doublethink - - 148 comments

Agree 100%. It also stops really complex scenes involving both fog and smoke from looking good.

This is especially true when dealing with fire, for example being inside a building that is on fire, with hanging smoke, and billowing/pluming smoke from the source of the flames.

Also usually the transition between the rendering methods is readily apparent and greatly hurts the scene overall. The Mass Effect 2 intro sequence is probably one of the best I've seen, but to the keen eye it has problems.

Anyway, about overgrowth, what happens when the Sun or other dynamic light sources try to permeate either smoke or fog, is the effect as realistic and nice as what you did with the plants leaves, for example?

A real life example would be a scene at dusk of a village that has been "raised".

Reply Good karma Bad karma+2 votes
aerozol
aerozol - - 179 comments

ooh breath mist and blood spray
Gettin' fancy

Reply Good karma Bad karma+6 votes
Elementalist
Elementalist - - 732 comments

As said, very glad you wrote this. This was definitely an 'Ahhh' moment, for some reason I'd never even thought about how it was done! Thank you very much. :)

Reply Good karma Bad karma+4 votes
Kyou.
Kyou. - - 920 comments

flat particles for the lulz?

Reply Good karma Bad karma+2 votes
awesomepossum
awesomepossum - - 997 comments

That really does look way better, nice work!

Reply Good karma Bad karma+2 votes
SliderFF
SliderFF - - 896 comments

О_о

Reply Good karma Bad karma-4 votes
Tottel
Tottel - - 242 comments

I always love évery single post made by Overgrowth. I always learn something new. :)

Reply Good karma Bad karma+3 votes
feillyne Staff
feillyne - - 5,816 comments

I lôvé évèry pôst màdé by Ovèrgrôwth tèàm / Jèffr, tôô. ;-)

Reply Good karma+1 vote
hilmart
hilmart - - 11 comments

Very nice work. Can't wait to play a foggy level. This game is looking better and better every update :).

Reply Good karma Bad karma+3 votes
AlekZanDer
AlekZanDer - - 2,695 comments

Great stuff. I do wander how heavy the engine will become when it's finished.

Reply Good karma Bad karma+2 votes
revengous
revengous - - 165 comments

I noticed when you look on the steps with the smoke, it reaches to the edge of the "inner" parts of the steps, but only closer to the rabbit on the "outer" parts. I can see this is because of the fact that its a 2d sprite that faces the camera.

Do you have any plans to change this to create a more 'natural' feel? or are trying to keep requirements as low as possible?

Reply Good karma Bad karma+2 votes
MrEmjeR
MrEmjeR - - 131 comments

no it's not optical illusion. because the face is not straight angled with the stairs, the smoke in the inner part of the stairs are relatively closer. that is because of the billboard effect. for getting better effects you should make multiple faces that are directed in different directions, and they would give a better effect of volumetric smoke.

Reply Good karma Bad karma+1 vote
pejck
pejck - - 5 comments

Wow, i didn't how the soft particles actually worked, thanks for the simple explanation. I never thought the technique for rendering them would be that simple. I love how it exploits the fact that particles and the depth buffer are always parallel to each other.

@revengous: I think this is actually just an optical illusion, here's a great example of it: Michaelbach.de

Reply Good karma Bad karma+2 votes
Dragonlord
Dragonlord - - 1,934 comments

So I get it right you offset the billboard towards the camera? Can get you into clipping troubles with certain situations but I think from the type of maps it should be working. Otherwise a spherical solution would remove these clipping problems. Similar to deferred rendering light volumes just for billboards.

Reply Good karma Bad karma+2 votes
nosfer4tu
nosfer4tu - - 1,378 comments

holy **** now this is awesome

Reply Good karma Bad karma+2 votes
xXMaNiAcXx
xXMaNiAcXx - - 4,807 comments

Sexy!

Reply Good karma Bad karma+2 votes
.Omena
.Omena - - 149 comments

Particles are a must no matter what game you're making. Really good job on yours, me likey. :)

Reply Good karma Bad karma+2 votes
Awesome_ninja
Awesome_ninja - - 809 comments

badass! keep on rocking guys!

Reply Good karma Bad karma+2 votes
Famouz
Famouz - - 22 comments

You forgot particles are very important for the atmosphere of a game.
it makes the space "tighter" so it makes you feel the enviorment is real, in case of moving particles you're always sourounded by

Reply Good karma Bad karma+2 votes
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: