Procedural Computer Page
- group .........
- Pages
- recording .....
- https://s4xw77gvirailb62.public.blob.vercel-storage.com/lab/procedural-computer-page.mp4
- source ........
- https://ui.aryank.space/pages/procedural-computer-page
- markdown ......
- /lab/procedural-computer-page.md
- human .........
- /lab/procedural-computer-page
── WHAT_IT_IS ────────────────────────────────────────────────────────────────────────────────
A full-bleed WebGL2 studio homepage whose entire background is a single raymarched fragment shader. Three tumbling 3D rings, each an analytic ellipse SDF resolved with a twelve-step Newton refinement, are smooth-unioned with a pointer-tracked crosshair and drawn twice per frame: a crisp flat line pass and a normal-shaded emboss pass, cross-faded live by pressing B. The rings orbit on a fixed fifteen second loop, the wheel injects decaying rotational velocity, the pointer is lerped toward the crosshair with exponential smoothing, and toggling dark mode inverts the grey palette. Fixed wordmark, blurred intro card, contact button, and social nav sit over the canvas. Pure WebGL2, no dependencies; keyboard shortcuts for theme (T), contact (C), and emboss (B).
── BEHAVIOUR ────────────────────────────────────────────────────────────────────────────────
* One triangle covers the whole page
The scene is a single fragment shader rasterized over one oversized triangle at [-1,-1],[3,-1],[-1,3]. There is no geometry for the rings; every pixel independently raymarches the signed-distance field, so the cost scales with resolution, not with scene complexity.
* Rings are analytic ellipse SDFs, not sampled circles
Each ring rotates a 3D circle by a rotation matrix and projects it, which turns it into an ellipse in screen space. The exact distance to that ellipse is solved with a twelve-step Newton iteration over the ellipse's parametric normal, then onioned to give the ring its thickness. That is what keeps the edges razor sharp at any orientation instead of blurring as they turn edge-on.
* Two passes, cross-faded by a key
The field is evaluated twice with different line and crosshair widths: a flat pass anti-aliased with fwidth for crisp strokes, and an emboss pass that reads the SDF at four neighbours to build a surface normal and light it. Pressing B lerps uEmboss between them, so the same rings read as line art or as raised metal without a second scene.
* The loop is deterministic, the input is not
Time is wrapped to a fifteen second period so the ring orbit is perfectly seamless. Everything reactive is added on top as an offset: the wheel feeds a velocity that decays into uScroll, the pointer is exponentially smoothed toward the crosshair, and dark mode eases uInvert. Nothing accumulates permanently, so the background never drifts out of frame.
* Dark mode is a shader uniform, not a repaint
uInvert mixes the background from a light grey to near-black and swaps the line colour the opposite way inside the shader. Toggling the theme does not touch the DOM canvas; it eases a single float, so the whole field crossfades its palette in one smooth motion.