Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Fluid Dynamics in 3D Similar to DF  (Read 1098 times)

strich

  • Bay Watcher
    • View Profile
Fluid Dynamics in 3D Similar to DF
« on: January 15, 2013, 07:27:52 pm »

Hi guys,

I'm currently developing a new game based on space and one of its goals is some lightweight pressure/fluid/temperature simulation throughout the player spaceship. Like a good developer I'm cutting the project up into more palatable bite-size projects. The one I'd like to discuss and develop here is an open source version of DFs Cellular Automata simulation. After fairly extensive research I've concluded that the solution DF has implemented is actually really well done.
I'd love some help from the community here around a few specific points:
1. Has anyone already done the above? Eg is there already an open source implementation of DF's liquid and pressure simulation as discussed here? No point reinventing the wheel.
2. The above linked article discusses liquid simulation quite well. However I'm struggling to find information around how the system works with liquid interactions (water+magma), gases, temperature, etc. Would love some resources around this.

The plan here will be to develop a small open source project written in either C# or C++ (Undecided yet) and pluggable into Unity as its currently my engine of choice. But I'll try to keep it as engine agnostic as possible.
Logged

GalenEvil

  • Bay Watcher
    • View Profile
    • Mac-Man Games
Re: Fluid Dynamics in 3D Similar to DF
« Reply #1 on: January 16, 2013, 05:10:19 am »

I'm not sure if there is one already developed but fluid simulation is a very interesting subject since it is a sliding scale between accurate and fast. Since this is for a game then it needs to be fast enough to run in real time but accurate enough that it doesn't do stupid/weird stuff. Cellular automata is pretty good at that. I'll make a longer post later on when I am a bit more awake about this. I will try to write up some pseudocode / C# to use with this as well. You may want to look at The Procedural Content Generation Wiki which has loads of information and specifically some on Cellular Automata and Hydraulic Flow :D
Logged
Fun is Fun......Done is Done... or is that Done is !!FUN!!?
Quote from: Mr Frog
Digging's a lot like surgery, see -- you grab the sharp thing and then drive the sharp end of the sharp thing in as hard as you can and then stuff goes flying and then stuff falls out and then there's a big hole and you're done. I kinda wish there was more screaming, but rocks don't hurt so I guess it can't be helped.

strich

  • Bay Watcher
    • View Profile
Re: Fluid Dynamics in 3D Similar to DF
« Reply #2 on: January 16, 2013, 07:10:35 pm »

My thoughts exactly GalenEvil. I think CA could be done in 3D well enough in real-time. One can display the CA fluids via isosurface extraction. What that means is that it'll scan the CA grid and output a shell mesh. From there some simple water shaders could make a fairly decent fluid dynamics system. If one could get the CA+mesh extraction going at 30FPS it'd look quite nice.
Its something I plan to test out fairly soon.

Right now however I'm trying to look for a good 3D CA lib, if I can. I'm sure it wouldn't be too difficult to create from scratch but I understand there will be quite a few optimizations to be had to get it going at a good speed. Again, trying not to reinvent the wheel there.

The other part of that is how to implement multiple interacting fluids/CA types. The classic example for this is the 2D falling sand game where you can place water to grow plants that you can burn with fire. I'd love to see a clean and fast example of that somewhere.
Logged