Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit61a33237e0

README.md

terrain_apply_delta

Folds an erosion pass's accumulated fixed-point deltas into a channel and clears the accumulator.

An erosion pass never writes height. Every gram of material it moves accumulates into an integer accumulator in units of 1/65536 m, because integer addition commutes and float addition does not — the summed result of thousands of droplets landing on one cell is the same whatever order the threads resolved in. This pass is where that sum becomes terrain.

It runs once per erosion iteration, after the gather that brings in the material neighbouring tiles moved across the seam. atomicExchange reads and zeroes in one step, so the accumulator is empty for the next iteration without a second clearing pass.

One thread per stored cell, apron included. An apron cell's own delta is applied here as well: the following apron exchange overwrites it wherever a neighbour owns the cell, and where the field ends and no neighbour does, the applied value is what keeps the border apron a plausible continuation of the terrain rather than a step.