Cakes & Desserts & Liqueurs

Various projects at Royal HaskoningDHV

Projects

Old code

Various games / projects at Deltares

Older games

Augmented Reality / Graphics

Realtime visualization of water simulation output

Water experimentation project

For the "experimentation project" at the University of Utrecht, I created a real-time water visualization based on the output of a Sobek run. Sobek is a 1D/2D modelling suite. One of the formats that Sobek can output is "Incremental ASCII files". Which basically are just a long list of changes spread over many frames.

Now, one could read these frames, create a texture out of it, and render these steps with a certain interval. Of course, this would not really capture the 'flow' of the water. My goal for this experimentation project was to:

  • »Take the existing data
  • »Interpolate between the given frames
  • »Show a fluid water flow on some kind of 3D map view

The data that I used in this experiment was a simulation of a levee breach somewhere in The Netherlands. Which immediatly resulted in a first problem: In the first few frames the water has quite some velocity. The data consisted of 48 frames, each 30minutes a step. So between the breach and the next step would be 30 minutes.

A modified floodfill algorithm

To solve this problem I created an modified floodfill algorithm, which works like a layered bathtub. The water will normally keep increasing for a while, until it will overflow somewhere else. Then in this new "tub" the water will continue to increase. Until, of course it will also overflow.

Think of a bucket in a bathtub in a swimmingpool. smile This algorithm has become rather slow as the edges where it can overflow, keep increasing the higher the waterlevel comes.

This algorithm created a "flow time texture" which indicates how the water would flow. For efficiency reasons the texture contains various data separated over the texture channels. The "flow" of the water can be clearly seen this way, and the high water velocity at the starting point as well. The image's alphachannel is also used as part of the time texture, hence that this image shows transparency as well.

Realtime visualization of water simulation output

Having the interpolation ready, there still need to be some way of visualizing it. This was done using a technique called "Flow maps" as presented by Valve's Vlachow at SigGraph 2010: Water Flow in Portal 2 - Valve. It is a nice read!

Sobek provides the water flow vectors, but in this case they were not very practical to use, as those would only show the flow for each timestep (30 minutes). Therefore I added an extra element to the algorithm which determines flow based on the "overflowing bath tub" principle, and turn it into a normalized flow map. This results in the following (quite tall) texture:

Realtime visualization of water simulation output

Combining the flow textures, some shaders and a terrain texture leads to the following frames.

Realtime visualization of water simulation output

Some moving animations. Unfortunately the animation does not come to its justice on a small video, in my opinion. It really looks quite nice on a higher resolution.

"The water is too dark/real/etc..."

One of the most frequently heard comments was that the water was too dark! I modelled the water colours upon the colours of the March 2011 tsunami in Japan, as that was right when I was working on this project. But I also made a light variation of th water.

Download the whole PDF

Download the detailed PDF containing a lot more technical information about the actual implementation here.