Skip to main content
GameDev.net gamedev.net
🔒 Locked

mixing particle systems - fire and smoke

Started by Sander Mar 31, 2004 at 3:53 PM 5 replies 5.4k views
Original Post
Sander
Sander
I am (still!) working on my particle engine and i''ve stumbled into a problem: how to mix different particle systems. Take a system for a rocket engine as an example. The fire and flame obviously use a different blending equation than the gulfing black smoke that pours out. Smoke particles need to be sorted back-to-front to be rendered correctly but they are going to be interleaved with fire particles. So, how to render something like this effectively? Obviously I cannot just sort the entire buch and start rendering, flipping blending equations as I go. Rendering the fire first and the smoke after it (or the other way around) doesn''t give a good effect either (if you look at the system from the wrong angle). So, how did the pro''s solve this? Surely particle engine design has improved over the years, but the best articles I can find online about particle systems (gamasutra''s article and the paper about second order particle systems) are a bit outdated and don''t help me with this. All the other articles are either for non-realtime rendering (movie editing and such) or stuff written to explain the basics of a simple system (such as NeHe''s particle system lesson). Any clue how modern, more advanced particle systems work?
Lone Wolves Game Development Sander Maréchal [Lone Wolves][Game Developers Emporium][E-mail] [Hosting $7,95/mo][Forum FAQ][Google]
_the_phantom_
_the_phantom_
i''ve tried visulising a fire and the first thing which sprung to mind is that the smoke isnt a part of the fire as such, it tends to exist around the outside of the fire and not really in among the flames.

having had a think about it this doesnt seem like a problem you can solved with one partical emitter, infact it might require a couple to try and get the right effect.

Now, this might not be the most gracefull way of doing it but its a starting point I guess

I''m think have a central partical system which is the flames, then around the outside have a series of smoke emitters, when rendering work out the order of the emitters back to front and render back to front but in such a way that the flames replace the emitter(s) behind it and the emitters infront are blended in with the flames.

As i said, maybe not the best solution but its a starting point
mattnewport
mattnewport
If you use pre-multiplied alpha and pack your fire and smoke particles onto one texture then you can sort them and draw them all together in one batch. Packing all your particle textures on to one texture and using pre-multiplied alpha is a good idea IMO - you can get the effect of additive and normal alpha blending for different particles without having to switch render state or texture and drawing all your particles in one batch is much better performance wise than doing multiple batches. I''ve not found much use for other blending modes than additive and alpha blended.
Sander
Sander
Thanks guys. More than two systems is definately something I need to look into.

quote:
Original post by mattnewport
If you use pre-multiplied alpha and pack your fire and smoke particles onto one texture then you can sort them and draw them all together in one batch. Packing all your particle textures on to one texture and using pre-multiplied alpha is a good idea IMO - you can get the effect of additive and normal alpha blending for different particles without having to switch render state or texture and drawing all your particles in one batch is much better performance wise than doing multiple batches. I''ve not found much use for other blending modes than additive and alpha blended.

This sounds very interesting. Do you know of an article that describes pre-multiplied alpha? I have never heard of it before and it sounds good.

mattnewport
mattnewport
Pre-multiplied alpha is pretty simple. Your normal alpha blending equation is
destColour = srcColour * srcAlpha + destColour * (1 - srcAlpha) 
. With pre-multiplied alpha, instead of storing
(R, G, B, A) 
values in your source texture you store
(R * A, G * A, B * A, A) 
and then you use
destColour = srcColour + destColour * (1 - srcAlpha) 
as your blend mode. So far that hasn''t bought you anything - you''re still getting the same results as ordinary alpha blending. Now however if you have a value of
(R, G, B, 0) 
in your source texture you get additive blending so you can draw both additive blended and ordinary alpha blended particles in one
DrawPrimitive() 
call without changing texture or render states.
CyberSlag5k
CyberSlag5k
I would use two separate emitters. I''ve had particles emit particles in the past and the effect has worked well. As _the_phantom said, the smoke should come from the end of the flames. Perhaps you could have each flame particle emit a bit of fading, but long-trailing, smoke. The more flame particles, the thicker the smoke. Play with it and I bet it would look pretty nice.

Good Luck!

When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...
Without order nothing can exist - without chaos nothing can evolve.
Sander
Sander
Thanks! If I use hat pre-multiplied alpha trick I can probabely get away with just a single particle system. Start with additive for the fire particle and then fade it to an alpha blended smoke particle to create a smoke trail at the end of the flames.

Thanks heaps!


Lone Wolves Game Development
Sander Maréchal
[Lone Wolves][Game Developers Emporium][E-mail]
[Hosting $7,95/mo][Forum FAQ][Google]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.