Anyone have any good examples, tutorials, or snippets to share that preferably in C# or C/C++?
PixelJunk shooter from Q-Games has nice set of fluids. There is a GDC paper they have published here: http://fumufumu.q-games.com/gdc2010/shooterGDC.pdf (PDF!)
Jos Stam from Alias Maya fame (now Autodesk) wrote paper on real time fluids in games here: http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf (PDF!)
And he wrote a simple FFT fluid solver here: http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/jgt01.pdf (PDF!) where he included source in that PDF at the end.
- Practical Fluid Mechanics
- Very detailed explanation with C++ code and pre-compiled binary. You can interact with the demo, like creating new smoke and stirring the smoke with your mouse. The image is a capture of the demo. Lists several on-line references at the end, as well.
- Stable Fluids [PDF]
- I think the author, Jos Stam, is the expert when it comes to fluid dynamics. 75 page summary of his research.
- Chapter 38. Fast Fluid Dynamics Simulation on the GPU
- More technical and math-heavy then the Cowboy Programming Practical Fluid Mechanics. Also lists several off-line resources at the end.
- A Fire and Smoke Simulation for Mobile Game [PDF]
- The weakest resource of the bunch, but I still found it worth bookmarking...
Here's a fairly primitive write up about using cellular automata for simulating fluids: http://w-shadow.com/blog/2009/09/01/simple-fluid-simulation/
In certain situations such a simple approach can be appropriate (Dwarf Fortress uses a similar approach to simulate liquid flow; also - the powder game). Also, this approach is pretty easy to grasp/get up and running fast.