So, I’ve been working on an OF addon I call “ofxFlame”, with the purpose being to create a dynamic flame simulation based on fluid physics and other advanced concepts, with the ulterior motive being to never have to use a textured sprite.
The primary problem is that I’m still in high school (woohoo OF for being so easy to learn yet hard to master), and I have only a basic knowledge of calculus and dynamics.
I have been poring over the works of Nguyen and J. Stam, and I have come up with a basic architecture of how I want it to work.
The flames will use a dynamic fluid cell array, something I am also working on involving a threaded manager object (think renderer device
), a “fluid patch” (think vertex pool
), and a bunch of “fluid cells” (think vertices
). The manager hooks into and locks the fluid patch based on a timescale, processes fluid dynamics (straight out of J. Stam’s paper, “Real-Time Fluid Dynamics for Games”), then unlocks, allowing the other threads to access or modify the cells using their member functions.
But in my version (as opposed to Stam’s example), the cells are not exactly preallocated, but are allocated by the fluid patch when they are referenced by member functions of the patch, then dereferenced if their values reduce to 0. This process cares for the application-side fluid shape and state of the flame (and can probably be adapted to similar uses!), but does not account for the rendering.
This brings me to the render process. I’m thinking about a raytracing algorithm (as in V. Pegoraro/S.G. Parker’s paper, “Physically-Based Realistic Fire Rendering”) which accounts for the appearance of the fire due to absorption, emission, and scattering of light particles, as well as the radiative properties of the materials used. This is all fine and good, but I don’t exactly want to take it as far as being accurate in chemical composition. This leads me to my first real problem.
I have next to no clue what most of the equations represent, much less how to incorporate them into code. Plus, I don’t even know how to implement a recursive raytracer.
If anyone could offer some articles, code examples, or explanations, please do so. Because, in the words of Frankenstein’s monster, "FIRE GOOD "