Looks cool, right? I’ve always been in love with the idea of trying to put real physics into games- and flames was my first target. It turned out to be a lot of work (had to write my own fast fourier transform!) but being foolish and optimistic, I decided to give it a shot.

Modern GPU’s are astonishingly powerful – even low end ones. Processing clock speeds ground to a halt around 2005, but GPU’s don’t have to run fast- they run in parallel. If you can take your algorithm and represent it as a sequence of texture transformations, you can squeeze a lot of beauty out of those little processing units.

And I’ve tried to do so. The flames engine represents the space around a burning object as a field of little cells that can hold varying amounts of fuel, air, and heat at any given point. And there is a differential equation defined in which if there is enough of each element at a point in space, a reaction occurs in which fuel is combusted with air and heat is produced. The field itself behaves like a viscous fluid, and the forces within the field depend on things like heat, buoyancy and pressure gradient, and also the overall motion of the object itself. There are all kinds of ways to customize this- you can vary the fuel rate, cooling rate, light spectrum as a function of heat, and so on:

(The method by which the space behaves as a realtime fluid is based on books and research by Jos Stam of the University of Toronto. It’s a wonderfully elegant algorithm, and extendable in all sorts of ways.)

Now here’s where I’m going to let you in on a secret: the flames algorithm is not *quite* 3d. It’s actually 2.5D – two dimensions plus a depth coordinate. It’s one thing to ask a GPU to simulate a realtime fluid of 1024×1024 pixels, but it’s another one altogether to ask for 1024x1024x1024 pixels – a thousandfold increase! But, the z coordinate trick works really well and it reads onscreen as 3D quite nicely. Take a look:

This little snippet of a burning fireball represents more time and energy than I’d like to admit. I haven’t yet done a full usage tutorial on the flames effect, but expect to see one in the next few days. Enjoy!

-The Falling Frog