35mm projector gate weave, splice and changeover cue
I wanted to see if one ElementGL WebGL 2 canvas could project a 35mm cinema gate over a live screenplay card while keeping every field and button inside it responsive. Edit the scene heading or dialogue, tap Mark slate, Trigger splice or Switch reel inside the gate, or change cadence and Kodak halation below.
Starting projector gate…
Show the code drawable screenplay card, 24 fps weave maths, GLSL halation and cue shader, geometry sync and fallbacks
- Live screenplay and clapperboard card inside one canvas.
#reel-cardholds editable text fields, action buttons and a live frame counter inside#gate-canvas. - 24 fps stepped vs 60 fps gate weave maths. Quantises projector time to
floor(t * 24) / 24in telecine mode, adds splice jump impulses and mirrors the shader's sprocket pivot. - 35mm projector fragment shader. Draws the stationary rounded gate mask and sprocket strip, 16-tap red-orange halation around bright DOM edges, grain, scratches, splice tape and the top-right changeover cue.
- Hit-box sync with
geometryUnit(). Applies the matching weave matrix withupdateElementGeometry()and togglesdataset.hitTickwhen the quantised displacement changes. - Five-argument 2D and plain-HTML fallbacks. Transforms five-argument
drawElementImage()behind a 2D gate mask, or moves#reel-cardto plain HTML if the context is lost.
How it works
Instead of baking a static image of a cinema card, #reel-card stays live DOM inside a single <canvas content="drawable" layoutsubtree> driven by ElementGL from /lib/element-gl.js.
- Premultiplied texture uploads: immediately after creating
ElementGL(and insideonRestored), I setgl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true)so semi-transparent borders and anti-aliased DOM text upload as premultiplied RGBA viagl.texElementSubImage2D(). - Stationary gate vs woven film: the rounded projector gate mask and faint side sprocket holes stay fixed in screen coordinates, while
GATE_FRAGrotates and shiftsweaveUvaround a left-side sprocket pin at either 24 discrete steps a second (floor(uProjTime * 24.0) / 24.0) or continuous 60 fps. - Red-orange emulsion halation: the shader samples 16 neighbours around each pixel in CSS-pixel units, weights texels above a bright-pass threshold, and adds a warm
(1.0, 0.24, 0.04)back-scatter halo into adjacent dark borders and slate headers without tinting dark ink inside the paper fields. - Splice frame slip and changeover cue: clicking Trigger splice injects a transient vertical jump across the 35mm black frame line with a translucent Mylar tape sheen across the seam. Every 16 s reel cycle (or on tapping Changeover cue), an oval top-right cue mark blinks twice in the print's upper-right corner.
- Hit-testing and fallbacks:
syncCardGeometry()applies the active weave matrix scaled bygeometryUnit()toupdateElementGeometry()and togglesdataset.hitTickwhen quantised motion changes. Without WebGL 2texElementSubImage2D(), it drops to five-argumentdrawElementImage(), and onwebglcontextlostit moves#reel-cardinto plain HTML until restored.
Live checks
Each check builds an isolated fixture on testStage() and retires its canvas when finished. The visible projector above isn't touched.
| Result | Experiment | Detail |
|---|
Findings
Measured in headless Chrome 160 Canary on 2026-11-27 (412 px at 2.625 DPR, SwiftShader WebGL). Headless Chromium 157 and Chrome 159 on Android are not verified yet. Tap "Run these 6 checks" above to measure this browser.
- 24 fps stepped weave vs 60 fps cadence (measured in Chrome 160 Canary, 2026-11-27): clamping projector time to
floor(uProjTime * 24.0) / 24.0kept edge pixels identical att = 1.005 sandt = 1.035 sinside frame 24 and shifted them cleanly by frame 30 (t = 1.255 s). - Red-orange halation without washing out screenplay ink (measured in Chrome 160 Canary, 2026-11-27): a 16-tap 2-ring bright-pass scatter warmed dark pixels 5 px outside a white DOM box from
rgb(12,9,8)torgb(58,20,10)while moderating the close-tap bleed inside paper fields so dark dialogue text stayed legible. - Changeover cue and splice seam (measured in Chrome 160 Canary, 2026-11-27): triggering the top-right oval changeover cue shifted the rim pixel from
rgb(18,14,12)torgb(255,195,90)around a darkrgb(12,6,4)core, and keepinguGatePadwider than normal weave amplitude kept normal motion inside the frame while letting a 46 px splice jump pull the black frame line into view. - Live DOM hit testing and fallbacks (measured in Chrome 160 Canary, 2026-11-27):
updateElementGeometry()scaled bygeometryUnit()plus quantiseddataset.hitTicktoggles kept buttons clickable under weave offsets, and five-argumentdrawElementImage()2D fallback plus syntheticwebglcontextlostrecovery ran with zero wrong-size draws. - Not verified: headless Chromium 157,
npm run check:jank -- /gate-weave/,node tools/draw-size/audit.mjs /gate-weave/and Chrome 159 on Android at 412 px touch.