how to realize smoke effects with Opengl

can anyone tell me how to realize smoke effects in Opengl

I thinck the best is (theory):
“A simple fluid solver based on the FFT” from Jos Stam. maybe at : http://www.dgp.utoronto.ca/people/stam/reality/Research/pub.html
I hope that you find a GLUT implementation at: http://www.nada.kth.se/~gustavt/fluids/ or look at Nvidia developer site.

You can use a simple particle system and make the smoke puffs (your particles in this case) get more and more transparent as time goes on, untill they are completely clear then those particls would be killed.

-SirKnight

Originally posted by SirKnight:
You can use a simple particle system and make the smoke puffs (your particles in this case) get more and more transparent as time goes on,
-SirKnight

… and scaled … :slight_smile:

Yes, they must get bigger and more transparent as time goes on.

Originally posted by chief:
I thinck the best is (theory):
“A simple fluid solver based on the FFT” from Jos Stam. maybe at : http://www.dgp.utoronto.ca/people/stam/reality/Research/pub.html
I hope that you find a GLUT implementation at: http://www.nada.kth.se/~gustavt/fluids/ or look at Nvidia developer site.

IS anybody able to compile the FFTW libraries , For compiling the GLUT sample
code for smoke we need to compile the libraries which i tried but I am unable to
do , i mean I compiled all the library but still the glut sample code does not work me ,
I get the linking errors :

  1. Error: Unresolved external ‘_rfftwnd_one_real_to_complex’ referenced from S:\NT\DESKTOP\SMOKE\FLUIDS.OBJ

    1. Error: Unresolved external ‘_rfftwnd_one_complex_to_real’ referenced from S:\NT\DESKTOP\SMOKE\FLUIDS.OBJ

    2. Error: Unresolved external ‘_rfftw2d_create_plan’ referenced from S:\NT\DESKTOP\SMOKE\FLUIDS.OBJ

can anyone please help me in this ?

thankx

Originally posted by SirKnight:
[b]You can use a simple particle system and make the smoke puffs (your particles in this case) get more and more transparent as time goes on, untill they are completely clear then those particls would be killed.

-SirKnight[/b]

hey do u have some sample implemenation
of what u suggested ? Or can you please
elaborae what u said ?
Thankx

I implemented a small particle engine a while ago. It runs on command line and reads different parameters from an XML file. Just pass the xml file name as parameter.

The file “smoke.xml” demonstrates a simple smoke particle system with particles that get larger size and smaller alpha over time.

It is for Linux, but it uses only SDL and libXML, so the source should be easy to understand for a Windows user, too. Perhaps you are able to compile it with Cygwin.

Here is the URL for the source: http://www22.brinkster.com/theovermind/particle.tar.bz2

Please note that the noise function I use in my code is very slow, but I am too lazy to change it. Just ignore it and implement a better one, any other noise function will do.

EDIT: The direct link to the file didn’t work, just wrote a little html file.

[This message has been edited by Overmind (edited 07-03-2003).]

Oh yeah scaling, I forgot about that. There is a nice article on particle systems that has some code on gamasutra.

-SirKnight

[This message has been edited by SirKnight (edited 07-03-2003).]

Another question regarding particle systems:
How do I have to configure a particle system to get a realistic fire effect? I once saw an OpenGL benchmark with extremely realistic looking torches and it claimed it is a particle system, but didn’t reveal any details.

No matter what I try to reproduce it myself, it always looks like red/yellow smoke, not like real fire. I also found no good tutorials on how to set up the particle parameters, only how to write the particle engine.

Does anyone know a good code example or tutorial on this?

Thanks
Overmind

Method 1: hire an artist :slight_smile:

Method 2: use additive mode to create fire (it adds light); use interpolative mode to create smoke (it occludes)

My favorite way of doing 2) is to use blend mode GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA, which allows you to express both additive (zero source alpha) and opaque (one source alpha) and everything in between.

This blend function is a good idea to combine additive and transparency rendering, I’ll definitely try out. Until now I only used pure additive rendering with a color like (0.8, 0.05, 0.0) for the fire particles, then particles are red and get more yellow when they overlap because of the capping to 1.0.

But my problem is not the color of the flame, but the form. What parameters should my particle system have? What is the initial velocity/direction of the particles? What forces are applied? Any friction? Does the color change with time? Or with position? I know how to implement all these things, I just don’t know how to put it all together to get something that looks like the flame of a torch.

I don’t really care if the color is realistic, because that’s something I can find out by just trying out some values, but for the particle movement I think I am missing something more important.

EDIT: Just found the URL to the benchmark where I saw the effect I’m interresten in: www.glexcess.com
The scene with the torches is scene 4 (crypt). There are screenshots on the homepage.

[This message has been edited by Overmind (edited 07-05-2003).]

You really need an artist. These are exactly the kinds of things that artists do!

Anyway, I’d suggest using texture animation, so you start with a yellow-ish half-opaque ball that blends through orange to transparent black at the edges, and then fades in color to dark gray and successively less transparency. 16 frames is probably enough; make each particle jump to the next frame every 1/4 of a second or so.

You could make the particles a little more turbulent in how they look; add little mini-flames and “fingers” towards the top of the particles; try experimenting with that. I e, more like a slightly wider mini-image of a flame and less like a small, bright spot.

It also makes sense to not go over-strong on the particles. 0.8 sounds way too strong. Try 0.1 for red and 0.07 for yellow, and add more particles if it isn’t bright enough.

The particles should probably start by dispersing outwards, and perhaps a little downwards, and then use a fairly weak upwards drift to generate the height of the flame and more smoky images higher up. When the particle has played out the last frame, kill/recycle it.

I’d spawn about one particle every 20 milliseconds – but this is a very tunable thing and depends a lot on your particle texture image.

The image you posted looks like it did this, except it probably doesn’t have the smokey edge; there’s probably a bit of turbulence in each particle image (or there are lots of little particles, each of which is very weak).

I knew I missed some important features of the particle system. The texture animation sounds very good, I always had two seperate particle systems for flame and smoke.

One final question: What do I have to do that the flame gets more narrow at the top? For me it always gets wider at the top, but a flame should be wider at the bottom.

Make the particles big to start with, and smaller as they rise?

-Mezz

I’d suggest making the painted part of the texture frames narrower towards the later frames.

Also, if your particle system works something like:

Particle::init() {
position = base + jitter;
velocity = random_unit_vector * init_speed;
}

Particle::update() {
++numUpdates;
if( numUpdates > maxLifetime ) {
killMe(); return;
}
position += velocity * timestep;
velocity += upVector * upGravity;
velocity *= (1.0 - lengthSquared( velocity ) * airDragFactor);
}

What’s going to happen is that the base gets wider, because particles are spreading out in all directions; however, particles that travel upwards will reach higher than particles that start in any other direction; thus the highest part of the flame will be in the center, and the flame will taper towards the top. This would be true even if the particles just stayed the same size, and didn’t shrink. The screen shot you posted seems to use many, small, possibly constant-size particles.

or, you could try to implement stams method, it works really good, and can be made pretty fast, especially with the FFT.
look in GDC2003, stams has a paper there, where he wxplains the method with sample code. a very good paper.

I think I’ll try the approach with the particles getting smaller. It sounds very promising, and it is easy to implement with my current particle engine.

Thanks for all replies, I hope I have time to post the results soon.
Overmind