teichgraf's picture

Flui°D°emo - A 2D Fluid Simulation

Description
Flui°D°emo is an interactive 2D physically based fluid simulation using a Smoothed Particle Hydrodynamics (SPH) approach as described in the paper "Particle-Based Fluid Simulation for Interactive Applications" by M. Müller et al., which utilizes the Navier-Stokes equation and SPH to simulate the behaviour of the fluid. The resulting differential equation is solved with a numerical integration (basic verlet).
The whole project is written in C# 3.0 against the .Net Runtime 2.0.
The visualization and input handling is done with OpenTK - what else. ;-) (GameWindow)
As a by product a little framework for a flexible 2D particle systems, including emitters, consumers and a renderer for Meta-Balls (Blobs) was developed. The Meta-Balls are drawn with a Render-To-Texture (RTT) technique using the framebuffer extension (FBO), if available, a procedural generated gaussian distribution texture and alpha-testing.
The collision handling is done with the Separating-Axis-Theorem (SAT) and Object Bounded Boxes (OBBs).

I released the project as open-source under the GPLv3 license.
By the way, most of the people know Lutz Roeders Reflector, so a .Net binary innately comes with the sources. ;-)

Screenshots
Screenshot 1 Screenshot 2 Screenshot 3

Video
You can also watch a video at YouTube.

Download
Download the Zip here (1594 KB)
The download includes the binaries and the source code (including Visual C# Express 2008 solution).
See "bin\Readme.txt" for further instructions and requirements.

Enhancements
There are a lot of enhancements, which could be implemented.
Currently the whole geometry is drawn in intermediate mode, because it's simple and the framerate for this version is OK. But for sure it would be better to use VBOs.
Another point is the Meta-Ball renderer and the RTT with alpa-test, which would be nicer implemented with a shader.
...

Ideas wanted
My first goal was to build a game using the fluid simulation. And I already have some ideas for a game, but I didn't find an idea that took off.
So, when you have some ideas for a game or other suggestions, reviews, comments, questions, ... don't hesitate to post a comment.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Inertia's picture

[...]The simulation only runs with ~250fps at 500 particles on an AMD X2 6400[...]
No critique there, just stating the fact that 500 particles aren't much, and the objects in a game (both: particles and the world) will have to be smaller and in higher quantity.
Yes, I've read about the possible optimizations, but the performance gain is pure theory atm and cannot be measured. You might not want to have DirectX 10 hardware requirements for a 2D game to play smoothly, thus the suggestion to have the simulation separated from the interactive part. Something like a specialized version of the Incredible Machine.

Edit: Mhmmm I didn't mean to discourage you to try a Cataclysm style game, it was more intended to be a warning that it will be *hard* to do this in realtime and might not meet your expectations. In your demo the physics are most likely the bottleneck and not the immediate mode calls, so the switch to VBO will not improve framerate times 100.

...or has the discussion ended because I got everyone hooked on Incredible machine? ;)

iisystems's picture

teichgraf,

Is your ZIP file still available? I was hoping to check it out. The link seems to be bad.

Also, I am working on an iPhone game and am currently using Chipmunk, but I'm unhappy with the way my fluid looks. Not sure if you might be interested in collaborating or if you or anyone else has ported your code to iPhone...

Thanks,
Scott

objarni's picture

iisystems: just curious - what tools are you using to develop the iphone game?