Prism Light Instrument
- group .........
- 3D and WebGL scenes
- recording .....
- https://s4xw77gvirailb62.public.blob.vercel-storage.com/lab/prism-light-instrument.mp4
- source ........
- https://ui.aryank.space/components/prism-light-instrument
- markdown ......
- /lab/prism-light-instrument.md
- human .........
- /lab/prism-light-instrument
── WHAT_IT_IS ────────────────────────────────────────────────────────────────────────────────
A lighting rig you play with a pointer, where the light lands on a height field instead of on empty space. Typed letters, a ruled grid and a fine tooth are pressed into the surface, and every lamp rakes across that relief at a shallow angle, because grazing light is what makes an emboss read. The beam is measured rather than painted: three angular gaussians per lamp, one per wavelength, offset by a fixed chromatic amount around an achromatic core, multiplied by a two-term radial throw and gelled from tungsten through neutral to daylight. Standing on the surface is a real triangle of glass. Rays are traced through it in the vertex shader with a wavelength-dependent index, refracting in one face and out another, following the bounce when a ray hits the far wall too steeply to leave, so the spectrum is the actual dispersion of that geometry and not a gradient laid over it. Each pair of adjacent rays spans a quad rather than drawing a line, so the fan is watertight in a single frame instead of filling in over time, and a flat-topped profile across each slice sums to one however wide it spreads, which is what keeps a widening fan from banding at every seam. The glass casts a soft shadow because the lamp is a disc rather than a point: the penumbra falls out of the silhouette geometry, so it carries no temporal noise at all. Both the direct beams and the refracted spectrum answer to the same baked normal and openness map, so the colour carves the letters and finds the ruling rather than sitting on top of the picture. Letters slide to re-centre and sink to depth on their own clocks, a running average converges the image over twenty-six samples, and an ordered dither keeps the long dark falloff from banding into eight bits. One WebGL2 canvas, no library and no asset required.
── BEHAVIOUR ────────────────────────────────────────────────────────────────────────────────
* The light lands on relief, not on a backdrop
Type, a ruled grid, a slow swell and a fine tooth are pressed into a height field, and its normals plus an openness term are baked to a texture whenever the surface changes. Both the lamps and the refracted spectrum read that same map, so the colour carves the letters instead of sitting on top of them, and the foot of a letter goes dark because its own walls are in the way rather than because it was shaded darker.
* The spectrum is traced, not painted
A triangle of glass stands on the surface and rays are refracted through it in the vertex shader with a wavelength-dependent index, following total internal reflection when a ray cannot leave through the far wall. Adjacent rays span a quad rather than a line, so the fan is complete in one frame, and two edge rays are only allowed to bound a slice when they took the same path through the glass.
* A finite source, so the shadow has a real penumbra
The lamp is a disc rather than a point, and the softness is solved from the silhouette geometry instead of sampled over time. The blur is identical every frame, converged or not, so dragging the glass never shows the noise a stochastic soft shadow would.
* Converged over time, but never stalled
A running average accumulates twenty-six jittered samples and restarts on any input. While letters are still sinking the wavelength count drops to eight, since every band is full-screen overdraw, and the caustic renders at half resolution because a blurred spectrum survives it perfectly well.
* Scoped to its own box
The original was a whole-page instrument bound to window. This version sizes from a ResizeObserver on its own root and takes keyboard only while focused, so it fills a bounded demo stage or the full screen with no branch between the two.