WOAH
A low-poly planet covered in forests, water and snowy peaks hanging in a starfield with a small moon nearby

Play

Paint a low-poly planet into being, one tile at a time

By The host4 min#procedural#webgl#gamedev

Oskar Stalberg's Planet lets you brush terrain onto a tiny globe; hand-built tiles snap to your edits via the vertex trick that grew into Townscaper.

A small planet hangs in space with a moon drifting past, forests in green clumps, water pooling in the low spots, snow on the peaks. You pick a brush and paint, and wherever you drag, the terrain rebuilds itself to fit, shorelines meeting cleanly like the world was always meant to be that shape.

Planet is a 2016 browser toy by Oskar Stalberg, made four years before his town builder Townscaper turned this kind of instant, impossible-to-fail building into a hit. The whole thing runs in a tab, free, and five minutes with it teaches more about procedural geometry than most lectures.

The sphere is triangles all the way down

The globe looks round, but it is a geodesic sphere: a ball built entirely out of triangles, each one roughly equilateral. That regularity is the load-bearing fact. Because every triangle is close to the same shape, Stalberg could hand-model one library of terrain tiles that fits anywhere on the planet, with no fear of the curvature warping the seams.

Your brush never places tiles directly. It writes data onto the sphere's vertices: a height, plus a terrain type (grassland, forest, glacier, city). Every tile then looks at the vertices it touches and swaps in the one pre-built module matching that corner situation, this side high, that side low, water lapping two edges. Change a vertex and only the tiles touching it recalculate, which is why edits land instantly.

If you know Marching Cubes, the mesh-from-data trick behind every voxel game, this is its triangular cousin: prisms with six corners instead of cubes with eight, and any height difference of two or more swaps in dedicated cliff modules. The combinatorics are the whole reason the modules exist: pre-authoring one finished mesh for every reachable corner situation would have meant millions of tiles, so Planet instead converts the painted heights into a lattice of points and fills the lattice from a small kit of pieces. Beaches get their own modules, and each terrain type runs the same machinery over its own filtered copy of the heightmap. Boris the Brave traced the whole system in a teardown of how Planet works, down to the finishing touches: painted-in ambient occlusion, animated water, drifting clouds.

Two details from that teardown stuck with me. A vertex on this sphere usually touches six triangles, but a ball built from near-equilateral triangles is forced to keep a few special spots where only five meet, and the module system has to cover those seams too without anyone noticing. And the water lapping your coastlines is not an animated texture: Boris identifies a miniature fluid simulation running just for the shoreline waves. His verdict is that the finishing coat makes the tile-based nature of the planet almost completely invisible, which matches my experience; I only saw the triangles once I went hunting for them with the camera zoomed all the way in.

Delivery is charmingly 2016. I checked the page source: it is a Unity WebGL build, hauled in by UnityLoader.js, and it asks your browser for a 700 MB memory heap up front before drawing a single triangle. That heap request is the one place the toy shows its age, and it still started in seconds on my machine, a decade of hardware later.

Why you cannot make it ugly

Every module was authored by a human, so every combination the system can reach has an artist's taste already baked in. The lookup does the assembly; the beauty was pre-paid. A few careless drags still come out looking designed, and that, not randomness, is the trick. Stalberg proved the vertex-data idea in his earlier toy Brick Block, refined it here on a sphere, and rode it all the way to Townscaper.

The same hands, one trick, compounding

The shelf this toy sits on is worth walking end to end, because you can watch the one idea grow in public:

  • Brick Block, the 2016 proof of concept, still loads free in a tab: paint cubes into the air and hand-modeled housing modules snap over whatever shape you leave behind.
  • Townscaper runs in the browser too, the full pastel town builder as a free WebGL demo, no install, the same instant-rebuild feel moved onto an irregular grid Stalberg describes as weird in a lot of ways but made out of quads.
  • Bad North took the trick procedural, and Stalberg walked through exactly how in his EPC 2018 talk, assembling island dioramas from handcrafted tilesets live on stage.

The commercial punchline arrived in 2021. Stalberg told MCV he expected Townscaper to sell maybe 4,000 copies; it passed 380,000 on Steam by that May, a 95x miss in the right direction, from a solo project he had budgeted one year for. Switch and mobile ports were already in motion with Raw Fury when that interview ran, and the free browser demo above never went away.

Where the path starts

Boris's teardown above is the map to this exact machine. Stalberg's later fame runs through constraint solving, his island game Bad North generates its levels with Wave Function Collapse, and the gentlest introduction to that family I have found is the same author's Wave Function Collapse explainer, which starts at Sudoku and ends at level generation.

The algorithm itself lives in Maxim Gumin's WaveFunctionCollapse repo, 25,400 stars at last count, with ports in C++, Python, JavaScript and Rust and credits in Bad North, Caves of Qud and Unreal Engine 5. Few procedural ideas have traveled further on one README.

More worlds a system grows on its own: cellular automata that hatch swimming creatures.

Next up

The art is an algorithm someone left running