I’ve finally decided on the name for my Magic-Carpet-like game. It’s called Arcane Worlds now.
This week I improved old water simulation and implemented water rendering with flowing foam. It still needs some work on shallow water (make it transparent) and improvements where it touches the coast.
7 Comments
Hi!
I am very impressed by your technical demo and very interested by your technical posts…
I am working on a similar pet project and have wanted to implement a water simulation like yours. So I’ll be very interested by a post on your water simulation implementation. Please !
Is it based on the technique you described in your erosion post? Is it GPU based? (I don’t think so, by the way the CPU usage evolves when adding water in the demo). Anything you might say regarding the technique you developped would be great to read!
Oh, I forgot : Well done!
It’s CPU-based grid processing algorithm.
Each grid cell has water amount (height), flow speeds (x/z) and foam amount.
Amount of water is defined in the cell center, while flows are on the (positive direction) edges.
So each cell has 4 flows for each edge, but 2 of them are shared with neighbors.
Basically, the flows are accelerated with gravity, and then water is transferred out of the cell to neighbors based on the flows.
Hi,
Thanks for the info!
May I ask what’s the size of your grid?
And what the foam amount is based on and used for? I’d say that the amount of foam is proportionnal to the flow speed and used to help visualize the direction and speed of the flow, but it’s pure speculation!
How are you mapping the foam texture? Are you just offsetting the UV coordinates by the flow speed x delta time?
The grid is 256×256, just like land heightmap.
It’s rather small, yeah. But it allows to run complex procedural generation methods in short time, and water simulation doesn’t consume too much CPU too.
I might increase it to 512 later if performance tests will show it’s OK for most people.
The foam amount is increased when gravity acceleration is applied, and in special cases like “hitting a wall”. It then fades out with time.
Yeah, the foam is there to give a feeling of flow. The mapping is randomly shifted and rotated and then advected by flows for a short time. There are two mappings actually, cross-fading continuously because with long advection time a mapping becomes too distorted.
Thanks for the reply!
I’m on my way trying to implement this myself!
Thanks again for sharing!
The expertise shines through. Thanks for taking the time to asnewr.
Hi,
thanks to you I did this last month : http://www.youtube.com/watch?v=1hti5VgKZ6s
Thanks again!
One Trackback
[...] by this anf this, I implemented a water simlation on the GPU. It still a WIP, but here are the first showable [...]