Dynamic Water Simulation

Dynamic water and erosion system integrated with simulated ecosystem

Overview and Inspiration

For my landscape simulations, I want to integrate water as an active component that evolves, adapts and impacts other features over time. In the context of climate change, water is extremely important to model flooding, shifting waterways and ocean storm surges. Water shapes ecosystem evolution through the successional creation of wetlands, lakes and complicated landforms. Water impacts vegetation, and trees can shape water. Water simulations can also be used to improve terrain generation, where erosion and deposition are important steps to generate convincing landscapes. Resulting variations from rocky mountain slopes to sandy estuaries create diverse conditions for various biomes depicted by changes in vegetation.

Simulating water has taken much more time than I initially expected, and has been the most mathematically precise simulation work I have done. I have found simulating water to be extremely touchy, where the entire system can “explode” into ruinous results within a fraction of a second. Simulating water is also very resource intensive, and must be done in small steps. After taking computer animation courses, I know that these issues persist in modeling complex phenomena such as gravity, and other fluid motion simulations also require many small timesteps with relatively large computational power. Working with water simulations has been very complicated, and I am continually refining my code to be more flexible and more efficient.

“Exploded” water simulation, incomprehensible results can happen with rapid accumulation errors

Previous Work

Many video games feature a degree of dynamic water that changes with viewer interaction. Cities Skylines features a node based water system to simulate changes with altered landforms and the construction of dams. With this very slow and inaccurate system, some flooding can occur, but erosion and deposition are not simulated. Many video games and interactive artworks feature a fluid motion simulation that reacts to input, but does not produce lasting changes in the virtual environment. 

https://paveldogreat.github.io/WebGL-Fluid-Simulation/

 

An older interactive webGL project, Craftscape, is a water simulation for a large landscape that includes erosion. I have not been able to explore a live implementation of this project, but it demonstrates fast and efficient water flow.  The following papers were reviewed to explore similar approaches to model water flow and erosion implemented with GPU shaders. My process is very similar to the method described by Jákó.

https://experiments.withgoogle.com/craftscape

https://old.cescg.org/CESCG-2011/papers/TUBudapest-Jako-Balazs.pdf

https://ieeexplore.ieee.org/document/4392715

 

There are many realtime fluid or water simulations, and I do not claim that my process is novel or optimal. However, for my artistic work, I require full control and understanding of my code so that I can integrate it with my other simulation systems. My goal is also not to render photo-realistic water or scientifically model water dynamics.

Technical Overview

To simulate water, I am working with 32 bit RGBA float render textures, which allow for a high level of precision. Elevation and water depth are essential values that are represented in these dynamic textures, and small changes need to be registered correctly. Based on combined elevation and water depth, flow direction is calculated in a separate step. The flow velocity for each cell is updated on previous values, slope and the gradient of combined elevation and water depth. Water depth is updated separately, where water moves in the direction of flow and can only move down hill. For each cell, water can be accumulated from multiple neighbours, and it can flow into multiple neighbours. A more simple approach to model water is to restrict movement between cells to only flow in and out in a single direction.

Exchange of water values between neighbouring cells needs to be preserved in both directions. With GPU implementation, each cell needs to calculate incoming water from all neighbours, as well as outgoing water with the exact same equation. With a shader implementation, cells can only read data from the previous time step, and can not update values for neighbouring cells. So any water added to a cell needs to be accounted for independently by the neighbouring cell. With much refining and experimentation, my results work well for my purposes of creating representational landscapes.

 

Dynamic Water with erosion and sedimentation. Elevation loss (red) and gain (green) shown on right

 

Changing rainfall rate as part of a simulated climate yields powerful results, where streams disappear and fires sweep across dried up wetlands. Increasing rainfall results in flooding, washing away established vegetation and causing more erosion. Sediment flows into lakes and estuaries, gradually building up islands shaped by water flow. Even with relatively simple implementation, these results can stand on their own as generative art, and may be the focus of a separate project.

Below is an interaction diagram for my water system, showing what ecological processes are included and how other simulation systems are affected.

Interaction between water system variables and modelled ecological processes

Results and Future Development

I definitely need to keep refining my water simulation system, as well as continue to improve my water rendering shaders. However, after integrating water with soil, vegetation and urban growth simulations, the potential of my simulation works has been greatly expanded. So far this water system has been integrated into Hydrosheds, where viewers can change rainfall and witness how changes in urban conditions affect surrounding waterways.  Water is a key factor in how a simulated ecosystem is impacted by urban and agricultural development, as well as how flooding affects infrastructure and crops. I will continue to refine my water simulation in future projects that depict impacts and adaptation of human communities amidst climate change. 

So far my water simulation is devoid of an ecosystem. Future work will involve basic representations of nutrient flow, algae, small fish and aquatic vegetation. I hope to also model ocean dynamics and marine ecosystems with similar processes. These simulations can also include modeling chemical properties of water, such as nitrogen, oxygen and temperature which affect freshwater and marine ecosystems. 

Separately, while learning Hydrological modeling with ArcGIS, I found the normal approach of filling holes in an elevation map, calculating D8 flow direction and then flow accumulation to be not convincing, and can produce inaccurate results. In a small experiment, I have tested my own water simulation with high resolution 1m landscape data to map wetland features. Using my naive approach, I was able to generate more accurate results than the standard GIS process. This simulated water flow was improved by incorporating vegetation and impermeable surfaces to model water flow in complex urban landscapes.