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:
- Cooling rate
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
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
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!
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
fire2D_01.toe (2.02 MB)