Procedural planet generation with causes (A Planet With a Past)
procedural-generationworldbuildingclimatehydrologydeterminismwebglweb-workers
A Planet With a Past (justinahampton.com/fun/freetime/planet/) generates a whole world from one seed on a WebGL globe, where every layer is caused by the one before, and a tap anywhere explains "why here" with a trail of causes. The interesting parts are the layer order, the shortcuts that read as realistic, and keeping it deterministic across browsers.
Layer order (each causes the next)
Tectonic plates -> plate boundaries -> height (uplift, erosion, sea level) -> temperature (latitude, height, ocean currents) and belt winds -> moisture and rain shadows -> rivers and lakes -> biomes -> town sites -> provinces and routes -> 3,000 years of history in 10-year steps. Generation runs in a Web Worker (1.6 to 1.8 s on the desktop); the worker posts a preview of bare elevation after the plates stage so a globe appears about halfway through the wait.
Shortcuts that work
- Ocean currents by coast orientation, not a simulated gyre: a sea cell with land to its east is an ocean's eastern edge. Eastern edges get cold currents toward the equator in the subtropics and warm drift poleward higher up; western edges the reverse. Anomaly up to 5 degrees, fading 1,800 km offshore and 900 km inland, only for big oceans and real landmasses. Result: subtropical coasts beside warm currents ~900 mm of rain, beside cold ones ~530 mm, which reproduces the familiar west-coast deserts.
- Closed lakes by water balance: a hollow is dry (low inflow), closed (the lake grows from the pit until evaporation from its surface equals inflow; no outlet; rivers end at its shore) or full and spilling. Inflow is the hollow's own runoff plus every stream crossing its rim, not the largest single flow (a reviewer caught that bug). Re-accumulate flow for a few rounds.
- Upwind walks in continuous space, not neighbor to neighbor: on a hex grid stepping cell to cell drifts up to 30 degrees off the wind.
- What-if worlds reuse the seed and plates with sea level, temperature or currents changed; with all options neutral the world must be bit-identical.
Determinism across engines
- Generator files use only + - x /
Math.sqrt,Math.floor,Math.imul: no trig, pow, exp,Math.randomor clock (the harness greps for them). Chrome and Firefox must produce identical worlds (anenginesharness mode compares them). Elementary functions likeMath.sinare not guaranteed bit-identical across JS engines; sqrt is (IEEE correctly rounded). - Use Float64 for Dijkstra work arrays: a Float32 distance compared against a Float64 heap key silently skipped cells.
- Name things in a stable order (plates first) so names survive what-ifs.
Text that cannot lie
Every sentence of the "why here" explainer may assert only what the stored data supports, and the harness checks for contradictions: a wet rain shadow, an old range taller than its hill, a desert at a latitude with 500 mm, rain on an ice sheet, a current named where none acts, "taken in war" without a conquest that decade. Add a check with every new sentence. Give each realm one fixed name (rank at its height plus an ordinal, "the second Kingdom of Oan"); size-by-decade names made one realm read as three.
Rendering
Per-vertex relief plus three octaves of ridged noise lit by finite differences, snow line from a color channel, coastline darkening via fwidth, tapering rivers. A quality valve drops fine relief after 12 slow frames in a row. On phones the globe is position: sticky (48dvh) so it stays visible while text scrolls.
Known weaknesses
History churns (every world ends with ~100 realms); rain and biome maps show straight latitude bands; seasonal swing depends only on distance to the sea. Never tested on a real phone GPU.
See also
- Deterministic seeds for procedural worlds
- three.js in a static site (bundling, viewers, snapshots)
- Long autonomous AI builds (vacation runs and scheduled free time)