Skip to content

No.166 · Heroes

Glass Torus

A ring of thick glass turning in front of huge type; the letters seen through it bend, flip and fringe into colour. Drag to spin it.

The prompt

Written for the variant you picked above: Smoke

Build a hero in raw WebGL1 (no libraries): huge bold type (default "GLASS / ICON", Geist 800, fitted to 86% of the width) drawn into a canvas texture behind a raymarched glass torus that turns slowly in front of it. The torus (major radius 0.62, tube 0.21) is a signed distance field, rotated by a 3×3 matrix built from yaw, pitch and a fixed roll so it reads as a tilted ellipse; 72 sphere-tracing steps from a camera at z = 3.2. Off the ring each pixel shows the type texture directly. On the ring: compute the normal by central differences, refract the view ray with refract() three times — the index of refraction nudged down for red and up for blue by a dispersion amount — and look up the type at the screen position plus each refracted ray's x/y offset (plus a little of the normal), so the letters inside the glass shift, mirror and split into colour fringes. Multiply by the glass tint, mix in a Fresnel reflection of a soft studio (a bright strip overhead, faint side lights) with pow(1 − cosθ, 3), and add a tight specular highlight. It turns by itself (0.45 rad/s); pointer drag spins it with inertia that decays, and the pitch eases back to a resting tilt. Rounded frosted 44px buttons: full screen at the top left, pause/play and reset at the top right. Render at 0.8× (0.55× on touch); the loop stops when the ring is paused and settled, and pauses offscreen. The type is in a visually hidden h1 too. Selected variant — Smoke: Smoked glass: tint (0.82, 0.83, 0.87), IOR 1.45, dispersion 0.03, full Fresnel reflection — a black glossy ring with bright rims; the white type behind shows through it bent and fringed.

Notes

Interaction
Drag the ring to spin it (it keeps turning, then settles back to its tilt); pause, reset or go full screen with the buttons.
Motion
Idle spin 0.45 rad/s; drag inertia decays to 12% per second; pitch eases back to 0.18 rad.
Accessibility
The headline is a real h1 (visually hidden) and the canvas has a role="img" description. Buttons are labelled; pause is aria-pressed. Reduced motion starts paused. Without WebGL the type is shown on its own.
Responsive
The type is re-fitted to the canvas on resize; the ring is sized to the height so it frames the words at any aspect.
On touch
Drag spins the ring on touch too; vertical swipes still scroll.

Featured

301 components