Realistic fire


I have a program that shows fire, but to show it I use 3 quads all rotated differently to show it. What I want is to create realistic fire without have to put thousands of particles where every fire is.

To create releastic fire you should use from many particles. creating a fire with only 3 quads seems too bad. you should use from the small quads to create the fire. Take a look at this site. there are many particle systems here:

Well thats what I mean. I use many particles made of 3 quads so I can view them from all directions.

Originally posted by Terminatore3:
Well thats what I mean. I use many particles made of 3 quads so I can view them from all directions.
If you want to see it from all directions, you should use from the effect called billboarding. In this case you use from the right and up direction of the viewer to rotate the quads.

Ok, but I don’t know the math for how to do that and even so my program still wouldn’t be able to run moree than 10 fires at once without jumping all over the place. I need realistic fire that runs on a 256 MB ram and a 16 MB vid card with 30-40 fires at once.

Translating the particles that consist of the quads isn’t so expensive. So something is going wrong in your code. But here’s some suggestions about the billboarding:

The idea is that you use from the up and right directions to rotate each particle. Assum that what does happen when you rotate the camera. your up and right directions will change. So your particles also should roatate. In this case you can ensure that the particles directions are parallel to your direction.
In this case you need a simple vector class with overloaded operators. please wait until i find that vector class for you

Now we should find the up and right vectors of the viewer. We can extract these vectors from the modelview matrix and then use from the vector classes to create the up and right vectors:
GLfloat matrix[16];
glGetFloatv( GL_MODELVIEW_MATRIX, matrix );
vector3_t right( matrix[0], matrix[4], matrix[8] );
vector3_t up( matrix[1], matrix[5], matrix[9] );

Now for each particle, we should use from these directions. also we need to know the center point of each partcile.
Here’s the code:

//Center point of each particle:
vector3_t p( x,y,z );

//Now create each particle:
glBegin( GL_QUADS );
glTexCoord2f( 0.0f, 0.0f );
glVertex3fv( (p + (right + up ) * -size ).v );
glTexCoord2f( 1.0f, 0.0f );
glVertex3fv( (p + (right - up ) * size ).v );
glTexCoord2f( 1.0f, 1.0f );
glVertex3fv( (p + (right + up ) * size ).v );
glTexCoord2f( 0.0f, 1.0f );
glVertex3fv( (p + ( up - right ) * size ).v );

Every time that you rotate the camera, the right and up vectors will be updated and So the particles will be rotated.


You can find that vector class here:
Download the sample codes of chapter 15 and use from the file vectorlibe.h

You could try to simulate only 2 or 3 particle systems and just replicate them over the scene multiple times. This way you save a lot of performance but you will get some identical looking fires…

And I just had another idea. I did never test it, but in theory it could work:
Simulate 8 particle systems with each having 1/4th of the particles needed to have good looking fire. Then for each fire you need, draw any 4 of these particle systems together. This way you only have to simulate two times the particles you need for one particle system, but it will give you 70 (=binomial 8 over 4) distinct fires.

They would be not as distinct as having one particle system per fire, but perhaps it is enough to fool the user :wink:

I’m not sure what you mean about simulating one particle system. I have one particle system that is divided among all of my points of fire so if I have 1000 particles divided by 50 points of fire then thats 20 particles for every point of fire. I’m not sure what your saying, do you want me to copy what one fire lookes like in a display list or something and move it somewhere else?

P.S. Ehsan I am still working on your idea

Yes, basically that’s what I am proposing. You can simulate just one or two particle emitters and draw the result multiple times to save performance.

That way you can get much more fires and still get the visual quality of particle systems, but with the disadvantage that every fire will look similar…

I don’t know how to implement this though. Do you mean instead of finding the position of every particle like normal I use the positions of another system and just translate it?

Yes. Calculate the particle system with the emitter at the origin, and translate the whole thing to where the emitter should really be.

Thank you Ehsan for your help, my program now runs very well with lots of fire and Overmind your idea was great as well.