Sign in to follow this  
karx11erx

How to create good looking smoke fx?

Recommended Posts

I have been trying to add smoke effects to an old 3D shooter, but I just fail to make it look good and have decent performance. Obviously it's not enough to create a particle engine and throw a ton of bitmaps at the screen (not even if the bitmaps are small animated clouds). So please, is there anybody around who could explain me how to create good looking smoke, like white, pretty directional thruster exhaust, or thick, black, billowing smoke from a damaged machine, or fog like effects? Maybe with some code examples (OpenGL preferred for the rendering), or examples what kind of images to use?

Share this post


Link to post
Share on other sites
So what exactly did you try so far?

I'd say, creating a particle engine that allows an artist to dynamically change the opacity, location, rotation and scale of the particles should be sufficient to create some interesting effects already. Various flak cloud effects I've seen were accomplished by having a few black sprites slowly move outwards, while rotating, growing larger and fading out eventually.
I would definitely recommend looking at other games that achieved such effects, and try to find out how they did it. Usually, it shouldn't be too hard to spot the tricks they employed. Or look at real steam vents and get an idea of the particles behaviour. Either way, this tends more towards 'artistism' than towards programming.

Share this post


Link to post
Share on other sites
One problem is that my smoke looks like it is made of soap bubbles.

Another problem is that overlaying a lot of bitmaps makes it look white - no matter how black the bitmaps are.

Scaling them to greater size doesn't make the particles look too pretty either.

So I don't know whether to use few or many particles, small or large bitmaps ...

Here's a few pics (click on small images for bigger ones):

Share this post


Link to post
Share on other sites
A rather interesting technique that I just recently heard about involves particles and raytracing. Mind you, it is being done on DirectX 10, so I am not sure how that will work. link - scroll down a bit and look for SoftParticles. Really quite an interesting technique with good looking results.

I would say that a particle system is the way to go either way.

EDIT - now that you posted the screenshots, it looks like a bit of an art issue to me. Try using a higher detail texture for your particles with more alpha blending towards the outsides of the particles. The problem with them appearing white when drawing a bunch of them has to do with how you are doing your blending. I don't know the exact method of blending them to make them look good, but it looks like you are doing some sort of additive blending.

Share this post


Link to post
Share on other sites
I read about this too - create photon map using particles and some raytracer and extract some volume fogging data from it. Beyond what time I can invest. :)

Edit:

OMG - I just found one major reason why my smoke doesn't look good: Due to a bug, smoke sprite size was too small ...

Still remains the question which OpenGL blend mode is best suited for many overlaying smoke sprites ...

[Edited by - karx11erx on October 2, 2006 6:44:20 PM]

Share this post


Link to post
Share on other sites
Ever played Red Alert 2? I always liked that sort of flak clouds. Atomic Tank, a PopCap game, shows the same. You should check out such games for reference. There's amazingly few sprites used per cloud - only up to 5 or 10 perhaps. They certainly didn't use an additive blending mode, they probably used a color blending mode or such.

Looks nice bytheway. Descent ah? :)

Share this post


Link to post
Share on other sites
Quote:
Original post by karx11erx
Still remains the question which OpenGL blend mode is best suited for many overlaying smoke sprites ...


You're using additive blending from the looks of it, you need 'regular' blending:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

You've also still got depth testing enabled from the looks of it. Draw your regular geometry, disable the depth test and then draw them back to front.

I'd also suggest turning on texture filtering to GL_LINEAR rather than GL_NEAREST and giving the particles softer edges.

Share this post


Link to post
Share on other sites
I am using the blend mode you posted, but I will try the other things. Though rendering the stuff back to front can hurt - a smoke cloud can have several thousand particles ... sorting every frame?

Captain P,

the problem is not that I wouldn't know how smoke should look like. The problem is to make it look like I want it to. Yes, it's Descent. ;)

[Edited by - karx11erx on October 3, 2006 7:32:22 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by karx11erx
I am using the blend mode you posted, but I will try the other things.

Hmm, I'd double check that. The pictures show lots of over-bright areas which you don't really get with that blending function. Of course your particle sprites might just suck.

Quote:
Though rendering the stuff back to front can hurt - a smoke cloud can have several thousand particles ... sorting every frame?

Blending is order-dependant, and without sorting you'll get all sorts of artifacts. Depending on your game you might be able to get away with just sorting on a per-system basis. Personally I'd sort particles within a system, and then sort all systems. You'll greatly reduce the sorting time but with only minimal artifacts.

Whatever you do, for goats sake turn off depth testing - most of your artifacts on the screenshots above are solely due to depth testing.

Share this post


Link to post
Share on other sites
I re-checked the blend func, it's definitely the proper one.

I turned off depth testing though and will add particle sorting for back to front rendering.

The quality of the particle images is another story ... Currently, it's a small cyclically animated cloud puff. They're the best I could get, and I can by no way do something like that myself. :/

Edit:

Added sorting (quicksort with minimal data movement required) - completely kills framerate. :(

Edit 2:

I had to re-enable depth testing because otherwise smoke would appear in front of objects even if it was behind them.

[Edited by - karx11erx on October 3, 2006 5:20:40 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by karx11erx
http://www.descent2.de/temp/smoke1.jpg
It looks like you're using 1-bit transparency. Just use 8-bit transparency like with your explosion sprite on that same image, and the smoke will look 10 times better already.. And make them more transparent.

Share this post


Link to post
Share on other sites
Quote:

Added sorting (quicksort with minimal data movement required) - completely kills framerate. :(


I don't think quicksort is a good choice. Sure, its expected performance is good (n*ln), but it's really the worst performance you should consider (n^2) (because that's the one that will ruin the player's experience).
I personnaly prefer mergesort, its performance is always n*ln.

Quote:

I had to re-enable depth testing because otherwise smoke would appear in front of objects even if it was behind them


I think what was meant was that you should disable writing into the Z-buffer. But the depth test itself should not be disabled.

Edit:
I have a naive question: Where does this back-to-front rendering requirement for transparent layers come from? It does not matter in what order I stack yellow and blue transparent plastic sheets, they'll look green anyway, won't they?

Share this post


Link to post
Share on other sites
If you render the transparent front texture first, the rearward texture will not be rendered at all if z-testing is enabled. That means you wont see anything behind your transparent texture ...

How do I disable z writes? (Yes, I am an OpenGL noob.)

Share this post


Link to post
Share on other sites
Thx. Fast. :)

Re QuickSort: I have made sure QS is not applied for (almost) sorted particles. Still slow as hell. Actually I wonder why, sorting 4000 8 byte elements on an Athlon 3500+ 64 and good RAM shouldn't be an issue.

Share this post


Link to post
Share on other sites
sorting 4000 elements is quite a bit, certainly not something u wanna do 60x a second.
why do u need so many, perhaps use fewer particles but make them bigger
i think the max num of particles i sort is something like 250 in a particle group

Share this post


Link to post
Share on other sites
i can't see your images, but to make a simple smoke particle engine should not require many particles. now if you are making a nice system for a next gen game, then THIS IS NOT THE SMOKE YOU WANT, but this is a decent smoke system for you to use.

What i did is just made like 5-10 billboards of a rounder smoke texture that was black on all sides, kinda like this: (Note, your alpha channel should also look like this)

With those billboards, just make them start at around your particle emitter, and move in a general upward direction, slowly getting bigger, and maybe with some spin on them. then slowly have them fade away. Thats all there is to it. Animated textures, although somewhat nice, dont always look as nice as how much you waste with them like memory and processing.

Share this post


Link to post
Share on other sites
One question ahead: I have failed to rotate my smoke particles, I cannot figure the required math. How do I do that? It should be possible by just changing the u,v texture coordinates, right? But how?

I am pretty satisfied with my smoke now:



Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this