So, for a game project I'm going to be working on I need to make a fully working 3D fluid simulator in Unity3D using C#, that can work in real time.
The only problem is, I've never done anything like fluid simulation. I've been doing tons of research on it, and I think a Eulerian based fluid simulator would fit my needs best (just like this).
Basically what I need is something that can react to changing terrain and move realistically.
The people that made that simulator have a research paper online, and I've read through it. I understand the basics, but I have no idea how I could get that in to C# or Unity3D. So I was wondering if any of you could help me, either by linking to other fluid-simulators where the code is open source, so I can pick it apart and change it to my needs, or by giving me tips on where to start/what I would need to do.
I've spent hours looking online for fluid simulators, but haven't found a single one programmed in C# as of yet, I have a program that can convert C++ to C#, but I don't understand C++ well enough to know where to put the scripts in Unity once they're converted.
Any help at all would be extremely appreciated, I'm really interested in teaching myself how to make this system, but I just have no clue where I should start, or what has already been done that I could build off of.
Probably you'd be best served to write it in C++ and then use it as a plugin called from native code. Fluid simulation is really complicated, as I'm sure you know, which is basically why people don't try to do it very often!
Hmm...yeah, I was thinking I'd have to make a plugin in C++, C# doesn't seem to be flexible enough to pull off what I want. I found an asset that may work, we'll see. If you could show me in the right direction to find a fluid simulator coded in C++ that'd be great, otherwise i'll find one myself if I need it.
I've never really done much research about this- I'm pretty sure you'd know more about it than I would!
as far as i can tell the simulation in this video uses CUDA on NVIDIA cards. If you haven't done something like this before, you better look for a ready-to-use solution. You won't get such a solution for free. That's "golden" technology and i guess not very easy to implement into Unity. Unity is really a fabulous engine, but to do such low level stuff efficient you really need to wrap your head around that stuff.
Just in case you've missed that: tallCells.pdf
Answer by Winterblood
Jan 04, 2012 at 12:56 AM
This is cutting edge technology, using all sorts of advanced maths to make it accurate and advanced programming to make it fast. Here are the underlying equations that even simple fluid sims use: http://en.wikipedia.org/wiki/Laplace%27s_equation
I've been programming games for over a decade, and I would run a mile from fluid dynamics :) Unless you're comfortable with coding differential equations, I recommend designing around it or faking it using a simpler algorithm that's inaccurate but cheap.
Check out some of the simpler sims here, maybe you can adapt one to your needs: http://vterrain.org/Water/
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
7 People are following this question.
Distribute terrain in zones
A node in a childnode?
Multiple Cars not working
How to execute a Skript global?
How can i shuffle a list