x


How to make a Realtime 3D Eulerian Fluid Simulation like “From Dust”, or something similar, in C#/Unity3D?

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.

more ▼

asked Jan 03, 2012 at 02:23 AM

Anselm gravatar image

Anselm
1 1 2 2

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!

Jan 03, 2012 at 02:55 AM syclamoth

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.

Jan 03, 2012 at 03:20 AM Anselm

I've never really done much research about this- I'm pretty sure you'd know more about it than I would!

Jan 03, 2012 at 04:08 AM syclamoth

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

Jan 03, 2012 at 04:26 AM Bunny83
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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/

more ▼

answered Jan 04, 2012 at 12:56 AM

Winterblood gravatar image

Winterblood
469 5 7 14

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x10159
x6827
x451
x93
x21

asked: Jan 03, 2012 at 02:23 AM

Seen: 6030 times

Last Updated: Jan 04, 2012 at 12:56 AM