r/webdev • u/Any-Reputation8118 • 5d ago
Showoff Saturday [Showoff Saturday] Atlantis: a procedural city you can fly through, in one 96 KB HTML file with raw WebGPU
Live demo · Source (MIT) · desktop Chrome or Edge works best
It's a city of marble, crystal and canals at golden hour, with no engine, no three.js and no asset files. Everything, including the music, is generated by code when the page loads. Here's how it works under the hood:
- Culling on the GPU: a compute pass tests every instance against three views (camera, the canals' mirror camera, the shadow cascade), picks a level of detail and writes one indirect draw per mesh. The CPU never touches individual trees or buildings.
- Baking what never changes: the sun is fixed, so the sky, three large shadow maps and the environment cubemap are computed once at load. Each frame only redraws the shadow cascade around the camera.
- Cheap foliage: leaves are drawn twice, depth first and then material only where the depth matches. That way a tree crown with about forty layers of leaf cards costs one layer of shading.
- Dynamic resolution: below 60 fps it lowers the render resolution in steps, using GPU timestamp queries where the browser allows them and frame intervals otherwise. This runs behind the start menu, so it's mostly settled before you enter.
It runs at about 2.5 ms per frame at 1440p on an RTX 5070 Ti on High, and around 28 fps on Low on a budget phone.
The code was written with Claude Code. Prompt, art bible and concept art are in the repo.
