carveDrainage

function carveDrainage
universe/src/drainage.ts:1352
carveDrainage(graph: DrainageGraph, lookup: Vec3, landform: number) → DrainageCarve

The valleys, cut into a landform at one sample.

Over every segment the sample's cell lists: the distance to the chord and where along it, the floor, channel half-width and depth interpolated there, and then the terms —

ground = landform − max cut + max fill − max notch

where a segment's cut is the landform's height above the floor over the valley's cross-section, its fill the floor's height above the landform over the same cross-section, and its notch the channel's depth over the bed. One segment alone gives mix(landform, floor, shape) − depth · bed: the bed at the floor less the channel's depth whichever way the landform went, the floodplain at the floor, the walls blending out to the landform at the reach. Every term is a maximum of continuous terms that are zero for a segment out of reach, so the set of segments a sample sees can change without the ground noticing.

The fill is the term the plan's min(landform, floor + profile) does not have, and it is alluvium. The relief and the craters are not on the lattice, so along a channel the landform dips under the floor wherever a hollow of theirs falls on it, and a cut alone leaves the hollow — either a pool in the bed or, with the water held at the floor, a channel of water standing over the land beside it. The fill spans the valley's cross-section rather than the bed alone, because a fill the bed's width is a causeway with a cliff for a bank: a crater a cell wide dips hundreds of meters under a floor, and that height over a bank of tens of meters put the kernel four meters off the CPU at a float32 position. Over the whole cross-section the same height is a fan a valley wide.

Where two valleys overlap the deeper cut and the taller fill each win, which at a confluence lays the tributary's floodplain over the trunk's as a cone that thins downstream faster than the trunk's floor drops.

The water is the floor over the bed, or the lake or sea that drowns the reach where that stands higher, and a lake's spill level over its floor, read as a kernel-weighted mean over the lake nodes within reach so one lake is one level exactly.

graphDrainageGraph
Undocumented
lookupVec3
Undocumented
landformnumber
Undocumented