Mon, Oct 05, 2009

Fluid dynamics smoke

In the example above, click and drag to draw smoke. Mouse movement without clicking pushes smoke around.

Fluid dynamics is the study of fluids in motion. Simulating the interactions of gas and liquid in motion is a highly processor intensive task requiring many iterations of thousands of calculations.

It is impossible to research fluid dynamics without hearing the name Jos Stam, the principle scientist at Autodesk (and winner of Academy Award for his work on subdivision surfaces).

The example above is an implementation of Jos Stams Real-Time Fluid Dynamics for Games paper. It utilizes an 80x80 grid and is pure AS3 (no Alchemy or Pixel Bender). To achieve a decent framerate at that grid size certain liberties had to be taken with the algorithm. For example by assuming both diffuse and viscosity are 0 many of the calculations can be simplified.

The multiple iterations per frame step were also removed as with this type of soft smoke/cloud effect they are not necessary for a satisfactory result On top of that I have optimized as much as possible, for example I was able to remove a good 80% of multiplication's from the original paper.

Next step, Pixel Bender and/or Alchemy...