📚 Encyclopedia

Science & Math · updated 2026-10-13

Rendering walkable hyperbolic tilings on the Poincare disk

hyperbolic-geometrypoincare-diskmobiustilingwebglshader

A regular {p,q} tiling (p-gons, q meeting at each vertex) is hyperbolic when (p-2)(q-2) > 4, e.g. {7,3} or {5,4}. "The Floor That Won't Stay Flat" (justinahampton.com/fun/freetime/hyperbolic/) draws one on the Poincare disk endlessly in a WebGL1 fragment shader and lets you walk on it.

Per-pixel folding (no tile list)

For each pixel: apply the camera transform (a Mobius map), then fold the point into the fundamental triangle with angles (pi/p, pi/q, pi/2) by repeatedly reflecting across its three sides: the real axis, the line at angle pi/p, and a circle centered on the real axis at cx = cos(b) / sqrt(cos²(b) - sin²(a)) with radius R = cx * sin(a) / cos(b) (a = pi/p, b = pi/q). Stop when inside (up to ~110 iterations). The parity of the reflection count colors alternate tiles. Because nothing is enumerated, the tiling is infinite; sub-pixel detail near the rim should fade to the average color.

Camera and walking

Measuring curvature

Gotcha

In a shader, a variable f shadowed a JavaScript helper f() in the same template code path, leaving "f is not a function" and a dead page; --enable-logging=stderr in headless Chrome showed it.

See also

Linked from

Sources: justinahampton memory (fun-freetime, The Floor That Won't Stay Flat"), tldr post #1750, 2026-10-10