### Simulating erosion in Blender part II, fluvial erosion

This second version of my `erode.py` script adds erosion by water (fluvial erosion, a.k.a. hydraulic erosion). It's not perfect yet, but this first steps already produces some quite interesting results as you can see in the next image: The image shows a small section of a 256x256 ANT generated landscape. The original is on the left, the eroded version is on the right.(The input file in .raw format and thr commandline parameters to produce the result from the image are provided on GitHub as well, together with the erode script itself.)

The script accepts some additional options to control the fluvial erosion (the other options are documented in this previous article).

OptionDefaultDescription
Ka 1.0 Angular dependence
Kc 0.9 Sediment capacity
Kdep 0.0 Deposition rate
Kr 0.1 Rain amount
Ks 0.1 Sediment solubility

## Algorithm

Each iteration at each point of the mesh we add an amount of rain to any existing water at that point. Each point also has an amount of suspended sediment and this amount divided by the amount of water gives us the sediment concentration.

By comparing the total heights of rock plus water we calculate how much water flows to and from a point on the mesh and (by multiplying by the sediment concentration) how much sediment is transported.

With these values we adjust the water height and ghe amount if suspended sediment at a given point and recalculate the new sediment concentration. We the compare this concentration to the effective sediment capacity and deposit some sediment if the concentration is higher and dissolve some rock if it is lower.

The effective sediment capacity of flowing water in this model is the product of the base sediment capacity `Kc`, the sine of the slope `a` of the heightmap and the speed of the moving water `v`. How much the slope influences the result is tweaked by the angular dependence `Ka`:
`Kc * sin(Ka * a) * v`

Note that faster moving water already has a larger capac2for suspended sediment but on steeper slopes sediment settles less well, effectively increasing the sediment capacith of the water even more.

## Reference

Although the code presented here does not use the GPU but relies on Numpy and Numexpr for speed up, the following article proved to be an excellent reference:
Fast Hydraulic Erosion Simulation and Visualization on GPU by Mei et al.
There are however quite some differences, especially in the calculation of the flow field and the order in which the steps if the algorithm are executed.

## Future developments

The results so far are promising but we are not there yet. The algorithms need to be fine tuned but I feel experimenting is easier with direct visual feedback so I think I will concentrate on turning this script into a Blender add-on first.