Dynamic Terrain Erosion on the GPU

I experimented a bit with different erosion models, trying to compute them dynamically on the GPU (using compute shaders). Example result:

The algorithm can also generate a flow map (amount of sediment carried by the water):

You can use the W key to spawn water (marked as blue). While holding the T key, the terrain is dynamically eroded. You can also hold the Z Key for a faster erosion (equals pressing the T key 20 times).

To achieve a good erosion, you will probably have to spawn a lot of water, and hold Z until it completely evaporated.

The performance is quite fast, I didn’t test it for bigger heightfields yet, tho (Currently using a 512x512 heightfield).

A gpu with GL 4.3 support is required.
Erosion v1.02.zip (513 KB)

Should be noted your code doesn’t even compile unless using 1.9.0 or later.

Also, I don’t see what you have a screenshot of when I run it, do I need to do something?

Hey tobspr, again some great work!
I tried to make such a program for months now, mine does still produce anything but the expected results. :blush:
As I don’t know nearly enought about shaders to come up with something equivalent to your solution, I would like to expand your program into a fully functional terrain editor program.
Therefore, i have some Questions:

  1. which erosion model did you implement, is there a paper around that explains the underlying idea?

  2. Do you plan to do further work on this?

  3. I noticed that, altought calculation is done using floats, most images use an integer format. What advantages does this have?

  4. is your LUI system meant to replace DirectGui? When should I use which of them?

thanks in advance

  1. I didn’t stick to an erosion model, basically I just simulate water flow over time (water carrying sediment)
  2. Not really, it was just an experiment
  3. Thats because I am using imageLoadStore, which only supports atomic operations on integer formats
  4. Its meant as an alternative, but its no direct replacement yet (maybe at some later stage, if it turns out to be sufficient)