/HydraulicErosion

An hydraulic erosion simulation by raining down droplets on top of an 2d map.

Primary LanguageC++GNU General Public License v3.0GPL-3.0

HydraulicErosion

This implementation is inspired by Hans Theobald Beyer, Sebastian Lague and a few others. I combined all the elements from other designs and ideas to make a version that I was happy with.

  • Implemented in c++ (without any outside dependencies)
  • Made for 2d maps of floats ( std::vector<std::vector<float> > )
  • The map can be any width and height (not limited to a square)

Example

Input height map (1024x1024) of simplex noise: Input for erosion process

Output height map with erosion config (32768 droplets of rain):

seed = 1337;
numIterations = 32768;
erosionRadius = 4;
inertia = .3f;
sedimentCapacityFactor = 4;
minSedimentCapacity = .01f;
erodeSpeed = .8f;
depositSpeed = .8f;
evaporateSpeed = .01f;
gravity = 10;
maxDropletLifetime = 128;
initialWaterVolume = 1;
initialVelocity = 1;
mapWidth = 1024;
mapHeight = 1024;

Output of erosion process

TODO

  • Make distribution of droplets configurable (uniform, normal, ...)
  • Memory and CPU cycle optimizations
  • Optimize erosion brush (unnecessary building of brush)