6

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?

Etan
  • 17,014
  • 17
  • 89
  • 148
  • Sounds like you need to interpolate, or find some method that does this for you? – ccook Dec 15 '10 at 13:10
  • Yes, I'm looking for a method to do this interpolation in openGL since i'm not very familiar with it yet. Some sort of solid dynamic model maybe... Transparency is also important to make realistic fire on the edges – Etan Dec 15 '10 at 13:16

2 Answers2

5

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

Jackson Pope
  • 14,520
  • 6
  • 56
  • 80
  • I don't want to use an existing particle system since I want to learn how they work ;-) – Etan Dec 15 '10 at 15:01
5

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'.

Elemental
  • 7,365
  • 2
  • 28
  • 33
  • Nice! 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. – Kos Dec 15 '10 at 14:25
  • Thanks. Could you please add more info about those 2d grids? – Etan Dec 15 '10 at 15:02
  • It 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? – Elemental Dec 16 '10 at 10:15
  • it'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. – Etan Dec 19 '10 at 10:22