35mm film light-leak and prism burn wipe

I wanted to see if one ElementGL WebGL 2 canvas could drive a 35mm film light-leak wipe between two live HTML scenes without flattening either view at rest. Scrub across the transition, press Burn to View B, or drag on the frame mid-burn to steer the prism flare while both cue buttons and text fields stay live.

VIEW B · DECK XENON 5600K MARKS 01
Shutter 180° · 24FPS
Arc output 4.2 KW LOCK
Plate REEL 03B
GATE B · OPTICAL COOL ARC 5600K
VIEW A · SLATE TUNGSTEN 3200K TAKE 04
Stock KODAK 5219
Gate 35MM 1.37
Sync 24.00 FPS
GATE A · AMBER SLATE 3200K HALO

Starting canvas…

Show the code two drawable scenes, tMs state helper, FBM light-leak shader, paint upload, geometry sync and 2D fallback
  1. Two live drawable scenes inside one canvas. Amber Film Slate (#pr-scene-a) and Cool Projection Deck (#pr-scene-b) share one <canvas content="drawable" layoutsubtree>.
  2. Explicit tMs burn state progression. triggerBurn() and stepBurn(sim, tMs, reduced) advance wipe progress deterministically or snap straight to target when reduced motion is on.
  3. Multi-octave FBM light-leak and prism dispersion shader. Splits RGB channels across the leading flare front, samples DOM highlight halation from both textures, darkens the scorch rim and settles 1:1 at endpoints.
  4. Paint-gated dual upload on one ElementGL context. Sets UNPACK_PREMULTIPLY_ALPHA_WEBGL, waits for hasPainted = true inside paint and calls stage.begin() before stage.upload().
  5. Active-scene hit-testing sync. Flips inert, moves the inactive scene offstage via updateElementGeometry() scaled by geometryUnit() and toggles dataset.hitTick.
  6. Five-argument 2D and plain-HTML fallbacks. Clips and strokes a radial light-leak over five-argument drawElementImage() draws, or moves both scenes into plain HTML on context loss.

How it works

Both live interfaces sit inside a single <canvas id="pr-canvas" content="drawable" layoutsubtree> backed by one ElementGL WebGL 2 context. At creation and on webglcontextrestored, the page sets gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true) so semi-transparent badge borders and gradients upload without premultiplied fringes.

No texture uploads happen until Chrome fires a paint event on #pr-canvas. Inside paint, the handler sets hasPainted = true, calls stage.begin() first so the backing buffer matches CSS pixels, uploads changed scenes via gl.texElementSubImage2D(), and binds View A on TEXTURE0 alongside View B on TEXTURE1.

  1. Multi-octave FBM light-leak front: four rotated octaves of value noise warp a diagonal sweep pulled toward the pointer flare coordinates (uFlarePos), creating ragged emulsion tears as progress moves from 0% to 100%.
  2. Prism chroma offset: along the leading edge, BURN_FRAG offsets the red and blue sample UVs of both DOM textures outward from the flare centre while keeping settled pixels unshifted.
  3. DOM highlight halation: a 10-tap golden-angle kernel reads bright badges, buttons and typed text straight out of the uploaded textures and blooms them in warm amber-crimson (Warm 35mm), electric cyan-violet (Prism cyan) or a full-gate exposure pulse (Flash cut) over a dark scorched contrast rim.
  4. Clean 1:1 endpoints and hit-testing: below 0.1% or above 99.9%, the shader bypasses distortion completely to return exact View A or View B pixels. Crossing 50% switches inert, moves the inactive scene offstage with updateElementGeometry() scaled by geometryUnit(), and toggles dataset.hitTick.

Dragging outside buttons and inputs steers the flare hotspot while selectstart prevents accidental text selection across labels (leaving user-select: text enabled on both <input> fields). Loops pause off screen via IntersectionObserver and when document.hidden is true, and snap immediately when prefers-reduced-motion: reduce or the Reduced motion checkbox is active.

Live checks

Each check runs on its own isolated testStage() fixture when you tap the button, retiring every canvas afterwards without touching the visible stage.

ResultExperimentDetail

Findings

Measured in headless Chrome 160 Canary (2026-11-27): 6 of 6 live checks pass. Chrome 159 on Android and npm run check:jank stay not verified.