Sand Flow
Grains blowing along a surface, piling into drifts that travel downwind.
The canvas in this preview is the file shown here. The surrounding demo shell only provides context and is not part of the copied code.
import { useEffect, useRef } from "react";
/**
* Vibary · Sand Flow
*
* Grains skittering along a surface and piling into drifts that slowly
* travel downwind.
*About this effect
A quiet floor for an empty state or a waiting screen. A grain landing on the sheltered lee side sticks; a grain landing while climbing the windward face usually bounces on. That asymmetry is the only reason drifts exist at all — deposit grains evenly and the surface can only flatten, because flat is the single stable state, while a lee that traps them lets any small bump collect more than it loses. Erosion is uniform across the surface for the same reason in reverse: lifting grains preferentially from the tallest column shaves the crests as fast as the lee builds them. A second rule gives the drifts their shape, relaxing the height field to the angle of repose so nothing stands steeper than about thirty-four degrees, which is why real sand has flanks at a constant angle and a heap built without it reads as dough. Mass is conserved exactly, and the simulation is run forward before the first frame so the field opens with its drifts already formed.