Rendering fire in OpenGL
Solution 1
If you are just trying to create a realistic fire effect I would use some kind of re-existing library as recommended in other answers. But it seems to me you that you are after a display of the simulation.
A direct solution worth trying might be replace your current spheres with billboards (i.e. graphic image that always faces toward the camera) which are solid white in the middle and fade to transparent towards the edges - obviously positioning and colouring the images according to your particles.
A better solution I feel is to approach the flame as a set of 2D Grids on which you can control the transparency and colour of each vertex on the grid. One could do this in OpenGL by constructing a plane from quads and use you particle system to calculate (via interpolation from the nearest particles you have) the colour and transparency of each vertex. OpenGL will interpolate each pixel between vertexes for you and give you a smooth looking picture of the 'average particles in the area'.
Solution 2
You probably want to use a particle system to render a fire effect, here's a NeHe tutorial on how to do just that: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=19
Comments
-
Etan almost 2 years
I want to render a fire effect in OpenGL based on a particle simulation. I have hundreds of particles which have a position and a temperature (and therefore a color) as well as with all their other properties. Simply rendering a
solidSphere
using glut doesn't look very realistic, as the particles are spread too wide. How can I draw the fire based on the particles information? -
Kos over 13 yearsNice! The latter can be implemented as a procedural texture, right? Hmm... No, that doesn't make sense- each fragment shader instance would probably have too much to do. So we'd need to create that texture once per frame before rendering any fire.
-
Etan over 13 yearsI don't want to use an existing particle system since I want to learn how they work ;-)
-
Etan over 13 yearsThanks. Could you please add more info about those 2d grids?
-
Elemental over 13 yearsIt would really help if we knew exactly what you want to achieve: Are you trying to draw the simulation in real-time or just rendering specific stills? Do you want it to faithfully represent the simulation or should it look good to the eye?
-
Etan over 13 yearsit's for a realtime effect for a simulation (I use SPH fluids to simulate the fire). The idea with the billboards made it look awesome much more :-) Thanks for this hint.