TerraFractal, part 6: function first

The current approach starts from a different rule: below the landmass scale, height is a function. Give it a position and what was handed down from above, and it returns the ground. No solving with neighbours, no negotiation.

One flood at the top

There’s still one big solve, because drainage is genuinely non-local: whether a valley drains depends on the whole basin. It runs once per landmass, on a lattice about 30 km apart. Rain from the climate falls on the ground, water flows downhill, basins fill until they spill or evaporate as much as flows in. Out of that come the trunk rivers, the big lakes and their levels, and which basins stay dry.

The landmass flood
The landmass flood: basins, lakes and trunk rivers from rain on the ground.

Rivers on flat ground don’t stay put. Sediment builds up their beds until they jump to a lower course. The landmass flood repeats that a few times: on the test world it moved 440 river courses over 8 rounds, before any tile is built.

Hexagons that only listen to their parents

Below that, the surface is cut into hexagon tiles. Each level has tiles about half the size of the level above. A hexagon tile doesn’t sit neatly inside one parent; it overlaps up to three.

The rule that took longest to get right is simple to say. A tile uses only its own data and what it inherited from its ancestors. It never looks at a neighbour. And the matching rule: nothing a tile creates may reach past its own border.

If both hold, everything that can affect a tile was made by one of its ancestors and arrived by inheritance. Two neighbours read the same inherited data along their shared edge and so agree exactly, with no conversation. When I’ve broken this, it showed up as a tile build that had to build its neighbours first, which had to build theirs. A test that should take seconds runs for minutes. That’s always the sign.

A child tile (yellow) reads only from the parent tiles it overlaps (shaded)
A child tile (yellow) reads only from the parent tiles it overlaps (shaded). The river reaching it was handed down by those parents.
Hexagon tiles drawn over the ground in an early test
Hexagon tiles drawn over the ground in an early test.

Noise with pull, then flood, then carve

Each tile repeats the same three steps at its own scale:

  1. Noise with pull. The tile adds its octaves of relief, but fades them out near the rivers it inherited. That’s the pull: the river’s line was decided at a coarser scale, so finer relief isn’t allowed to build a ridge across it.
  2. Flood. The tile runs its own small flood on its own ground, which finds its new streams and how they join the inherited rivers.
  3. Carve. Where a river still stands above the ground or a ridge still crosses it, the channel is cut to the river’s bed, shaped by the flow and the rock: wider in soft ground, steep walls in hard rock or where ice carved.
The same cross-section across a river
The same cross-section across a river: the raw noise, the noise with pull, and the carved channel.

Then it hands the rivers and their heights to its children, which do the same.

The same window in shaded relief, with the pull off (left) and on (right)
The same window in shaded relief, with the pull off (left) and on (right). With the pull on, the finer relief stays off the inherited rivers.

The stream wins

Where noise and a river disagree, the river wins. It’s a deliberate brute-force rule. It means some extra lakes and the odd gorge. It never pretends to be a perfect erosion model. The goal is realistic, not perfect.

The other rule: lower levels don’t fix higher ones. If something is missing at a fine scale, the fix is for each tile to do its share, not to ask the landmass stage to work harder. Every time I’ve been tempted to make the top level solve more, it’s been the old mistake from parts 3 to 5 coming back.

Part 7 is about what it took to make the rivers agree with the ground at every level.