Jump to content

  • Log In with Google      Sign In   
  • Create Account






Water, water, everywhere...

Posted by Milcho, 21 November 2011 · 665 views

I've been working on water, slowly progressing forward. To those who might wonder, keeping track of, generating storing and updating water when you're dealing with a 5km planetoid (our current test planet) isn't quite straight forward. This is sort of a backpost, since i already had basic water in my last post. But this is a bit more in depth.

The water simulation we went with is not like anything I've read about. There were several methods I considered before going with what we have now.

First was particle water.
The pros: Good water simulation. Realistic waves, breaking etc. possible.
The cons: Hard to extract surface. Impossible to keep track of all particles on any significant planetary scale.
This was obviously not going to work for us.


Height-field based water.
The pros: Significantly less storage. Easy surface extraction. Decent water simulation.
The cons: Braking waves are harder (though not impossible). How do you do a height field based water on a spherical planet? The answer: not well. You can either split into 6 separate height fields, or try to create one with polar coordinates based on a even point distribution.
This is too bad because back before we went for an actual planet, on a flat 2d terrain, this was my top choice

What I went with:
Storing water in a 3d voxel density grid. Much like terrain.
Pros: Storage concerns were already figured out - storing can be done in same datablocks as we store terrain - thus its possible on a planetary scale.
Cons: It's not a very realistic simulation. It's hard to make huge waves.


There was also one other pro, which i didn't realize until later - updating water was made just somewhat easier by the fact that I stored water on a grid. Of course, the grid is NOT oriented with the surface, yet due to a range of densities [-127,127] - it was possible to achieve a perfectly smooth water surface anywhere on the planet despite the grid being all squirrly.

Here are some screenshots of the apparently misaligned grid and the non-the less smooth water surface:

Posted Image Posted Image




And here is a video of the new water shader:

http://www.youtube.com/watch?v=DxkK226C4pY

And a video with the older shader, but the only video of water spreading in a huge hole.

http://www.youtube.com/watch?v=c7V9EFp9XnQ
Update: video of the water on a small planet (200m radius)


http://www.youtube.com/watch?v=a_vlkAcodl8



For more info, and a demo of the project, you can visit at http://blog.milchopenchev.com.

Thanks.




Nice! Destructible terrain and dynamic water.

If your spherical planet was generated with oceans on either side, and you dug a hole from the ocean straight through to the core and to the opposite ocean, would A) the water stop falling when it reaches the center of the planet, and B) would the oceans on either side drain (if there was enough space) or would they just generate water without lessening themselves?
Well, although we plan on stopping the user from digging through the core, mostly to try to limit data storage, it is currently possible. to do what you described. To answer your questions:
A) Yes, the water will stop falling when you dig through the core. It technically isn't falling, since it has no notion of gravity, but it is spreading. However it will stop when it touches another body of water.
B) The oceans wouldn't drain. The current method of water spreading is a copy-density method, or in other words, an infinite water.
The reason for this is that if instead of copying densities, the water densities got transferred (moved from one voxel to another) - even a tiny dig would potentially trigger a huge chain reaction that would propagate along the entire body of water. It would eventually die down because of the minimum density transfer (there's 255 levels of density, and the minimum to transfer is 1 density.) However it would still cause a huge water update reaction - which isn't computationally feasible.
On a bright note, this type of water spreading works great for oceans, seas, rivers or other large bodies of water where its unrealistic to assume you could drain them all.
We are considering the water spreading by the density transfer method for user-placed water. If the user has a bucket of water, it is a very finite source, thus it would be more computationally feasible to move all the density around.
Thanks for reading.

July 2014 »

S M T W T F S
  12345
6789101112
13141516171819
202122 23 242526
2728293031  
PARTNERS