Skip to content

Instantly share code, notes, and snippets.

@rreusser

rreusser/erosion.md

Last active Jan 6, 2017
Embed
What would you like to do?
Description of erosion on the gpu

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.

  1. Rain particles fall uniformly onto the landscape
  2. Each particle moves inertially subject to d^2p/dt^2 = - g * grad(y) - c * dp/dt where p is the 2D position, g is gravity, y is the elevation, and c is velocity damping so that particles don't pick up too much speed.
  3. The maximum velocity has a hard limit to prevent them from picking up too much speed.
  4. As particles move, they pick up sediment at a rate proportional to their velocity and up to some maximum carrying capacity.
  5. The shape of the carving is just a smooth circle a few grid cells wide. Think basically a smooth paintbrush in photoshop.
  6. 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.
  7. 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.
  8. 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:

  1. 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.
  2. The size of the brush together with the smoothing causes this all to be resolution-dependent in a way that is not numerically consistent.
  3. 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.
  4. In light of all the other shortcomings, it just uses Euler timestepping which is fine here but not very accurate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.