Hi,
I posted this question in the scripts forum but realised it was in the wrong section. How hard would it be to script or create a game where you can specify a water source, and water will flow based on gravity and topology. This will be similar to how you can change the water flow in “From Dust” http://www.youtube.com/watch?v=gSOQGazo7Oo.
So what I’m hoping to create is a terrain (for example an large mountainous region), and I can specify a unlimited water source near the top of the mountain. This will flow down naturally using the topology and form rivers until it hits the ocean. Is this possible in unity and if so, how would I go about achieving this?
That video shows some serious fluid dynamics (+ development time)
Makes my head hurt just thinking about it… probably some sort of vovel/marching cube fluid based on slopes of a heightmap.
edit. you mentioned dynamic terrain in other thread, so would go fully voxel for the terrain too.
Sure, what the video shows could be done in Unity, but it would require some serious research no matter what engine it’s implemented in. I don’t see any overhangs on the terrain, so Unity’s default terrain should do fine; voxel terrain is not needed just to make water flow on a terrain. But really, the terrain is the least of your worries. Generating the meshes for water and other fluids / semi-fluids is going to be the real tricky part if needs to be as dynamic as that video shows.
You could take a simpler approach and just have a river that has a fixed width and flows down the terrain, always choosing the steepest path down. This would be pretty manageable. You could do this similar to how the River tool on the Asset Store can create rivers on terrain and then just base the river path automatically on the steepness of the terrain. This wouldn’t handle rivers branching out or merging together, or preserving the volume of the water in a physically based way.
Those more complicated things in the video really are pushing what has been done in a game and don’t have an easy answer since it simply requires a lot of research. Sure, there are well known 3D fluid algorithms, but I’m pretty sure that’s still too processing intensive for realtime use, so I’m pretty sure they are taking a shortcut by doing the simulation in a 2D grid which however stores water height etc. at each grid point. The 2D simulation can then simulate 3D water with proper flow and volume conservation as long as there are no “overhangs”. Even with this simulation, generating the animated surface of the water as nicely as they have done is a research problem in itself.
Thanks,
I knew it would be a headache to do it, but I was interested in how to go about doing it. Most likely will not get implemented in the game, but I was bascially going to work on the game one step at a time and slowly adding features to it. Now that I know now one has done a unity script for it, it will be on the very bottom of the todo list. 