2D Fire

Hi all,

I’ve been trying to extend Kurt Kaminski’s amazing 2D fluid example:

to behave/look more like fire, by implementing a few concepts from Houdini’s Pyro Solver:

  • Disturbance
  • Turbulence
  • Cooling rate
  • Drag

Disturbance/Turbulence ended up being a collection of finely tuned noises, masked by the speed of the surrounding velocity field to add back onto the velocities. This creates lots of lovely break-up and flow patterns - there’s plenty of opportunity to get creative here.

Cooling rate and drag keeps the sim under control, after having injected a lot of temperature to add more dynamic interest. I’ve also added another image input to the buoyancy operator, to allow for varying buoyancy across the image, which adds additional swirling motion.

For the fire-look, I crunched the levels of the temperature output to give me as much contrast as possible and then ran the result through a series of modular filters. You want to apply a linear colour-space workflow here when dealing with very high luma values. Finally I’ve used tone-mapping to get the result back into a sRGB-friendly colour-space and tweaked to taste, until I recovered a pleasing looking range.

After having played with a bunch of simple shapes as density/temperature input, I’ve explored driving the whole thing with a video, by running an edge detection filter to extract contrast areas from the video:

At that stage things are really starting to come alive :smiley:

The input temperature/density values are very touchy and dependent on the input. For the sake of sharing something more sane, I’ve cleaned up my mess and tried to prepare an interactive example which turned into its own side-project:

Move the mouse around to control where to emit from (and advect things, it’ll pick up the mouse’s velocity), the fuel will spread and propagate using a modified dilation operator. Have a play with the parms of the ‘FUEL_SOURCE’ component:

  • Fuel - amount of fuel injected into the sim
  • Spread - amount/speed of propagation
  • Cooling Rate - globally calming things down
  • Cooling Noise - patchy reduction of emission areas

Sorry, this turned into way more text than I hoped :stuck_out_tongue:
Some stuff in the example I’ve borrowed/extended from other sources, I hope I’ve credited everyone accordingly - let me know if I forgot anything.
Huge thanks to Kurt again for sharing his original example! :smiley:

Lastly, this project is a bit of a beast - I’m getting around 50fps@1280x720 on my GTX1080, any ideas for optimisation are greatly appreciated :slight_smile:
fire2D_01.toe (2.02 MB)



Found a few things worth optimizing:

This op is costing like 12ms for some reason. Replaced with a fit TOP doing the same thing. The fit TOP costs about 0.01 ms in comparison.

Remove the vector array ref in the GLSL TOP. Those arrays can be real handy, but they can also be expensive. The TOP was cooking at about 12ms, just removing the array refs from the TOP (it’s already commented out in the shader) dropped the cost on this TOP down to 0.02ms.

50 passes weighs in at 2ms on my gtx 980, knocking this down to 1 pass cuts the cpu cost down to 0.1ms. So far this change is what’s made for the biggest speed improvement I’ve seen.

Starting out I was seeing 25 fps performance on a 980, after the above changes I’m up to 45.

Wow! :astonished: This is so cool! I was impressed with the video you posted a few months ago on Vimeo, and am very happy/grateful that you posted an example file.
I’m having a lot of fun flailing the mouse around and will probably attach fuel source to Kinect hand tracking next… or maybe HTC Vive controller render-pick? :nerd:
Thanks for sharing!

Thanks guys, glad you find it useful :slight_smile:

Appreciate the optimization suggestions, nice find!
I keep forgetting about the fit TOP…thanks for the reminder. Turns out, the ‘Quality Resize’ option on the Resolution TOP slows things down a fair bit alone.

True, the Jacobi iterations is in fact the slowest part of the whole thing, but it also makes the fluid look more interesting/swirly by doing a more ‘accurate’ pressure solve (at least that’s my understanding). I guess it’s a good trade-off, seeing how it still produces nice results at much lower interations with everything else that’s going on.

Yes, hooking up a Kinect would be so much fun! I’d love to see what you come up with :slight_smile:

Working on the FX for an environmental ballet March 2018 in LA. This is perfect for the fire section for attacking to a 1520 Kinect. Luminario Ballet of Los Angeles. Thanks x1000

That sounds awesome!
You’re very welcome, I’d love to see a recording of the show :slight_smile:
Good luck with the preparation.