Description of the algorithm used here. The algorithm is definitely not scientifically accurate! It's just ad-hoc to achieve a nice look and learn more about GPGPU in WebGL.
- Rain particles fall uniformly onto the landscape
- Each particle moves inertially subject to
d^2p/dt^2 = - g * grad(y) - c * dp/dtwherepis the 2D position,gis gravity,yis the elevation, andcis velocity damping so that particles don't pick up too much speed. - The maximum velocity has a hard limit to prevent them from picking up too much speed.
- As particles move, they pick up sediment at a rate proportional to their velocity and up to some maximum carrying capacity.
- The shape of the carving is just a smooth circle a few grid cells wide. Think basically a smooth paintbrush in photoshop.
- Particles evaporate exponentially. As they evaporate, their carrying capacity decreases proportionally and they deposit what they can no longer carry. Once they hit a certain threshold, they just dump all the sediment.
- Additional laplacian-based smoothing is applied to the hightfield as a whole. This prevents the particles from carving ruts that are too deep and leads to more coherent structure.
- Finally a noise function is used to vary the carving rate in order to simulate stratification. (The state parks around where I grew up always said the giant hill was due to a section of harder rock that didn't erode away like everything else.)
Most questionable parts:
- Inertia should not be a factor at this scale. Movement proportional to the gradient should be adequate. Second order just made it a bit prettier.
- The size of the brush together with the smoothing causes this all to be resolution-dependent in a way that is not numerically consistent.
- Carving proportional to the square of velocity is probably closer to physically accurate, but I don't have any idea what the actual law is.
- In light of all the other shortcomings, it just uses Euler timestepping which is fine here but not very accurate.