growing a world…
gpojani / surprise

Glifi

An endless world made of letters. Nothing here is a model or a texture: every letter is one ray, fired into a world that is only a formula, generated as you fly.


  

Glifi

an endless world made of letters · filed under P

Every letter on this screen is one pixel of a 3D picture. For each cell of the grid, your graphics card fires a ray from your eye into a world that exists only as maths.

The world is a signed distance field: one function that, given any point in space, says how far away the nearest surface is. That's all it knows. There are no triangles, no mesh and no map. A ray that knows the distance to the nearest surface can safely jump that far, ask again, and jump again. Near a surface the jumps get small, and when one is smaller than a hair, the ray has arrived. This is called sphere tracing.

The world has no edge, and none of it is stored. Every point is computed from its own coordinates, so the same place always looks the same and there's always more of it. Two slow noises play temperature and rain. Hot and dry grows red desert, cut into mesas and dunes. Hot and wet grows jungle and swamp. Cool and wet grows taiga. Cold freezes the lakes and brings the aurora. Somewhere, rarely, a third noise grows fields of violet crystal, and nobody knows why. The weather drifts across all of it: rain over the forests, snow over the tundra, never a drop in the desert.

The ground is also cut into cells 110 metres wide, and a hash of each cell decides whether something was left there: a monolith or a stone gate, a ring of twelve stones, three drops of liquid metal. Every seven metres, another hash decides whether a pine, a broadleaf, a cactus or a crystal grows. Far away, a forest becomes a single soft canopy, because a tree 300 metres off is less than one letter anyway. The autopilot flies from one monolith to the next and never runs out. New world changes the seed, and with it every hash, and with those, everything.

Eight kilometres north-east of the first monolith, in every world, is New York, at 1:1. Press New York to go there. A metre here is a metre there. The street grid is the real one: 80 m from street to street, streets 18 m wide, avenues 30 m, the whole grid turned 29 degrees east of north. The island is 21.6 km long, from the Battery to Inwood, between the Hudson and the East River. Central Park runs from 59th Street to 110th, four kilometres by eight hundred metres, with the Reservoir where it should be. The landmarks stand where they stand and are as tall as they are: the Empire State Building, 381 m to the roof and 443 m to the tip; the Chrysler Building, 319 m; One World Trade Center, 541 m, with the two pools beside it; 432 Park Avenue, 426 m and only 28 m wide; Central Park Tower, 472 m; the Brooklyn Bridge, 486 m between its towers; the Statue of Liberty, 93 m to the torch. The other buildings are not the real ones. Every lot draws its height from a hash, taller in Midtown and the Financial District, stepping back as they rise the way the 1916 zoning law asked. A true copy would need a million building footprints, and this page is one file. At night about a third of the windows are lit.

Then each hit is lit: a sun with soft shadows, light from the sky, a little bounce from the ground, fog that takes the colour of the sun. Each cell becomes the letter whose ink covers about as much of its box as the light does. I don't choose those letters by hand. When the page loads it draws every printable character in this font, counts the pixels of each, and sorts them. On your screen the ramp came out as . Some things have letters of their own: pines are ^ A, leaves are o & %, grass is , ; v w, water is ~, ice is =, edges are / | \ -.

The black monoliths are computing Rule 137 as you watch, ten rows a second, written down their faces in 1 and 0. It's one automaton, and each monolith reads a different stretch of it. Rule 137 is Rule 110 with the colours swapped, so the ones are the quiet background and the glowing zeros are the particles that collide and compute. It's universal, so in principle any of those slabs could run this page.

Almost every technique here comes from Inigo Quilez's articles, which are the best free education in computer graphics there is:

Why P? Each ray takes at most a fixed number of steps, so a frame costs a polynomial in the number of letters. It's the one thing on this site that is guaranteed to halt, sixty times a second.

drag to look · WASD or arrows to fly · Q/E down and up · shift to hurry · N for a new world · Y for New York · L copies a link to where you are · [ and ] move the sun · scroll to resize the letters · the address bar holds the seed, so you can send someone your world · one HTML file, no libraries