Holographic foil and brushed-metal sheen

I wanted to see if one ElementGL WebGL 2 canvas could extract micro-relief normals straight from texElementSubImage2D() luminance gradients and sweep holographic prism, brushed titanium and gold-leaf glints across embossed borders and text on a live membership card. Drag the card to tilt it in 3D, click a tier badge, edit the cardholder name or press Activate pass and Copy token.

ATELIER COLLECTIVE MEMBER PASS
FND-057
$240/YR
FND-8842-K9Q READY

Drag card to tilt in 3D · tap tier badges or edit name

Starting ElementGL WebGL 2 stage...
Show the code card markup, Sobel relief shader, MVP projection, paint upload and 2D fallback
  1. Live membership card inside one drawable canvas. Clickable tier badges, an editable member name input, an embossed SVG seal and action buttons sit inside one <canvas content="drawable" layoutsubtree>.
  2. Deterministic tilt and sweep state helper. stepTiltAndSweep(sim, tMs, reduced) advances spring tilt, auto orbit and directional light sweeps from explicit timestamps or snaps cleanly under reduced motion.
  3. Sobel relief extraction and three optical materials. FOIL_FRAG reads 3x3 luminance gradients from texElementSubImage2D(), tilts local normals by the 3D pose and switches between Hologram prism, Brushed titanium and Gold leaf.
  4. Perspective projection and hit-test calibration. buildCardMvp() produces matching uMvp and cssMatrix transforms, and syncCardGeometry() calibrates updateElementGeometry() with geometryUnit() and dataset.hitTick.
  5. One ElementGL WebGL 2 context with paint-gated uploads. Sets UNPACK_PREMULTIPLY_ALPHA_WEBGL = true on creation and restore, calls stage.begin() before stage.upload() inside paint and pauses off screen.
  6. Five-argument 2D gradient fallback and plain-HTML recovery. Falls back to 5-argument drawElementImage() with a 2D foil gradient blend when WebGL 2 is missing, or moves #os-card into plain HTML on context loss.

How it works

CSS gradients can layer a static shine over a card, though they don't know where every border hairline, SVG seal stroke or letter stem sits in the rendered bitmap. Here one ElementGL WebGL 2 context uploads #os-card via gl.texElementSubImage2D() with UNPACK_PREMULTIPLY_ALPHA_WEBGL = true whenever you edit the member name, switch tiers or toggle pass activation.

Inside FOIL_FRAG, each fragment samples a 3x3 neighbourhood around vUv at CSS-pixel spacing, unpremultiplies RGB and runs a Sobel operator over luminance. Flat obsidian areas produce gradients near zero, so they stay matte. Hairline borders, SVG crest lines and typography edges produce steep luminance slopes that bend a local surface normal N_local, which is rotated by the card's 3D yaw and pitch before lighting runs.

Three material branches share that extracted normal without recompiling shaders: Hologram prism computes thin-film optical path difference and rainbow diffraction grating lines that shift hue across the card as tilt and pointer angle change; Brushed titanium evaluates Ward and Kajiya-Kay anisotropic highlights perpendicular to horizontal micro-grooves; Gold leaf concentrates warm amber-gold Fresnel and hammered micro-flake specular glints along embossed borders and text.

Dragging on #os-canvas tilts uMvp in perspective while keeping user-select: none and a selectstart guard outside #os-member-input. syncCardGeometry() scales the same projective DOMMatrix by geometryUnit() from /lib/surface.js, calls canvas.updateElementGeometry() and flips dataset.hitTick so every button and input stays clickable while tilted. Motion pauses via IntersectionObserver and document.hidden, snaps immediately under prefers-reduced-motion: reduce and falls back to 5-argument drawElementImage() or plain HTML if WebGL 2 is unavailable or lost.

Live checks

These checks wait for a tap so the page opens with one GPU context. Each check builds an isolated fixture on testStage() and retires its canvas when finished.

ResultExperimentDetail

Findings

Not verified in a live browser yet. Tap Run above in Chromium with #canvas-draw-element enabled to measure this device.