GPU Fire

GPU Fire 1   GPU Fire 2


This project creates an animated fire texture on the GPU. A pbuffer is created, and wglShareLists is used so that the pbuffer and window contexts share textures. A blank texture is also initiated.

The following steps occur:

  1. Average the values in the texture neighbouring each pixel in the pbuffer, and scroll up by one. This is done in a single pass on the pbuffer, by binding the texture to all four texture units and using NV_register_combiners to take the average.
  2. Subtract one of four "cooling" textures from the values in the pbuffer, to simulate the flames cooling over time.
  3. Add fuel values (random 0.0-1.0) to the bottom of the pbuffer.
  4. Use CopyTexSubImage to copy the pbuffer contents back into the texture.
  5. Display the texture in the window, using NV_register_combiners to convert the texture's alpha values to realistic colors.
  6. Repeat from step 1.

Note that all drawing to the pbuffer occurs in the alpha channel only. This is because this technique is adapted from one which used a paletted display. The texture is converted into color values only when it is drawn to the screen.


ARB_multitexture with at least 4 texture units
NV_register_combiners with at least 3 general combiners


Dynamic Texturing, by Mark Harris

Download: (107 KB)