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.
Starting canvas…
Show the code two drawable scenes, tMs state helper, FBM light-leak shader, paint upload, geometry sync and 2D fallback
- 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>. - Explicit
tMsburn state progression.triggerBurn()andstepBurn(sim, tMs, reduced)advance wipe progress deterministically or snap straight to target when reduced motion is on. - 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.
- Paint-gated dual upload on one
ElementGLcontext. SetsUNPACK_PREMULTIPLY_ALPHA_WEBGL, waits forhasPainted = trueinsidepaintand callsstage.begin()beforestage.upload(). - Active-scene hit-testing sync. Flips
inert, moves the inactive scene offstage viaupdateElementGeometry()scaled bygeometryUnit()and togglesdataset.hitTick. - 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.
- 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%. - Prism chroma offset: along the leading edge,
BURN_FRAGoffsets the red and blue sample UVs of both DOM textures outward from the flare centre while keeping settled pixels unshifted. - 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. - 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 withupdateElementGeometry()scaled bygeometryUnit(), and togglesdataset.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.
| Result | Experiment | Detail |
|---|
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.
- Dual-scene upload with clean 1:1 endpoints: gating
stage.upload()onhasPainted = trueinsidepaintand callingstage.begin()first uploaded both#pr-scene-aand#pr-scene-bwithgl.getError() === 0. At0%and100%, bypassing shader distortion returned exactrgb(216,120,24)andrgb(24,136,216)endpoint pixels. - 48% mid-burn overexposure and R/B ratio flip: sampling neutral dark fixtures with a bright white highlight at
48%lifted peak luminance from20(at intensity0) to248inWarm 35mm(meanR=235, B=100) and242inPrism cyan(meanR=137, B=238). - Endpoint hit testing across overlapping views: flipping
inert, moving the inactive scene offstage viaupdateElementGeometry()scaled bygeometryUnit()and togglingdataset.hitTickswitchedelementsFromPoint()from Cue A at0%to Cue B at100%across identical screen coordinates. - Fallbacks and mobile budget: synthetic
webglcontextlostmoved both scenes into#plain-hostandwebglcontextrestoredrebuilt the pipeline after resettingUNPACK_PREMULTIPLY_ALPHA_WEBGL. At412 pxwide and2.625DPR, the backing store sits at948×941 px(0.89 MP,8.6 MBlive,0open snapshots,scrollWidth === 412). - Not verified on real hardware: Chrome 159 on Android touch steering on
#pr-viewport, real GPU frame rates, hardware context loss andnpm run check:jankstill need verification.