
This is a quick little project I had to see if I could implement hydraulic erosion on a simple terrain generation system I had built. I whipped this project up after watching the following wonderful video from Sebastian Lague:
In this video, Sebastian Lague explains the process of implementing a hydraulic erosion simulation which when run over a piece of terrain multiple times, causes it to be carved into very realistic looking ridges and valleys.
I decided to use what I learned from this video and implement it on my own simple terrain generator. The main difference with my terrain generator is that it generates terrain in a variable number of chunks. I had to adapt the erosion process to work over multiple chunks of terrain without creating any seams.
My terrain generator uses Perlin noise as a foundation, and combines it with fractal Brownian motion to allow for the adjustment of multiple layers of noise at different scales. By default, the terrain created by my terrain generator will often look like this:

This kind of generation is certainly not perfect. It creates terrain that ends up being very bumpy, and does not generate anything close to the natural ridges and smooth descents into valleys that occurs with the real world.
To get this landscape to look a bit more natural, we have to simulate some erosion. The basis of this is to simulate how rainfall would shift sediment over thousands of years.
The best way of understanding this simulation is to imagine that it is raining: As a drop of rain rolls down the side of a hill, it will pick up sediment. Eventually, the raindrop reaches a local minima, where it will evaporate and deposit the sediment it carries. This is one of the ways that landscapes are shaped in the real world!
My erosion simulation performs the following process thousands of times over a chunk of terrain to simulate the effects of long-term rainfall:

By performing this process thousands of times on a piece of terrain, a landscape of bumpy hills is transformed into having natural slopes and flat valleys, with more well-defined minimum and maximum points in a given piece of terrain.


To avoid creating seams between different chunks of terrain, I performed a simple process where the sides of each chunk would re-stitch themselves at a point in the middle of the elevation of each side.
