Zoom-blur tunnel NLE transition
I wanted to know if one ElementGL WebGL 2 canvas can drive a radial zoom-blur NLE transition between two live HTML scenes anchored at any focal point (fx, fy), while keeping buttons and text inputs hit-testable at both settled ends. Drag the reticle anywhere on the stage, tap Punch in or Pull back, toggle Auto loop or scrub Transition from 0% to 100%.
Show the code Dual-scene ElementGL upload, radial zoom-blur GLSL shader and hit-test geometry
- Two live HTML views inside one canvas. Editorial Shot A and Night Deck Shot B sit as sibling
drawablesections inside<canvas content="drawable" layoutsubtree>. - Hyperbolic scale curves, timestamp easing and hit-box swapping. Calculates tunnel scale, barrel warp, radial blur strength and toggles
inertplusupdateElementGeometry()at 0% and 100%. - 16-tap radial zoom-blur and warm/cool chromatic dispersion. Samples 16 radial taps along
(vUv - uFocal)with R/B channel offset and mirrored edge decay. hasPaintedgate, premultiplied alpha and fallbacks. SetsUNPACK_PREMULTIPLY_ALPHA_WEBGL = true, callsstage.begin()beforestage.upload()insidepaint, and falls back to 5-argumentdrawElementImage()or plain HTML.
How it works
Both HTML scenes live inside one <canvas content="drawable" layoutsubtree> backed by a single WebGL 2 context from new ElementGL(canvas, ...). On startup and after any context restore, the page sets gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true), waits for the canvas paint event before uploading either scene with stage.upload(), and calls stage.begin() before uploading so the backing store already matches device pixels.
Between 0% and 100%, the fragment shader measures each pixel's offset delta = vUv - uFocal from the draggable optical anchor (fx, fy). In Zoom in mode, View A magnifies hyperbolically with outward barrel distortion; in Pull out mode, View A shrinks rapidly into the focal point while mirrored tunnel borders fade into the vignette. Along delta, 16 weighted taps trail behind the radial velocity curve while shifting red outward and blue inward for warm and cool lens dispersion. Near 50% peak velocity, smoothstep cross-dissolves into View B zooming down from oversized tunnel magnification into crisp 1:1 alignment at 100%.
At 0% and 100%, the shader switches to a single crisp texture fetch so text never blurs at rest. syncSceneGeometry() uses geometryUnit() to place the settled view at 1:1 via canvas.updateElementGeometry(), flips dataset.hitTick to clear Chromium's hit-test cache, and marks the inactive or mid-warp scenes inert so taps never hit hidden controls. Under prefers-reduced-motion: reduce or the Reduced motion toggle, Auto loop pauses and Punch in / Pull back jump straight between endpoints. If WebGL 2 texElementSubImage2D() isn't available, the 2D fallback draws both scenes scaled around (fx, fy) using five-argument drawElementImage(); on context loss, both scenes move into #plain-host.
Live checks
These checks run on isolated fixtures inside testStage() and wait for a tap so opening the page doesn't allocate extra WebGL contexts or move focus.
| Status | Check | Detail |
|---|
Findings
- Measured in
HeadlessChrome/160.0.0.0on 2026-11-27 (412 px wide, DPR 2.625, withCanvasDrawElementenabled): all six live checks passed with 0 console errors, 1.096 MP backing store (994×1103 px, 8.77 MB initial, 13.63 MB peak across checks) and 8x anisotropic mipmaps on oneElementGLcontext, reclaiming fixture contexts back to 1 after checks finished. - Moving the optical focal anchor from top-left
(0.18, 0.22)to bottom-right(0.82, 0.78)at 50% transition flipped quadrant spatial contrast from10.7 vs 2.3to1.7 vs 10.7on striped fixture scenes, showing radial zoom-blur and R/B dispersion track(vUv - uFocal)directly. - Real pointer clicks inside the canvas hit
Log marker #1(updating to#2) and#zt-input-aat 0%, and hitCue clip #1(updating to#2) at 100% afterPunch insettled, while mid-transitioninertandOFFSTAGEtransforms kept inactive controls unreachable. - Running with
texElementSubImage2D()removed triggered the 5-argumentdrawElementImage()2D fallback (0 wrong-sized draws), and disablingCanvasDrawElementmoved both scenes into#plain-hostwithscrollWidth === 412and 0 console errors. - Running
/lib/a11y-audit.jsat 1080 px desktop passed 8 checks (calm,blank,dom,hit,ghost,names,sharp,motion) with 0 failures;focusandzoomstayed warnings becauseElementGL.#syncSize()doesn't multiply backing pixels bycurrentCSSZoomon its own. npm run check:jank,node tools/draw-size/audit.mjsand Chrome 159 on Android hardware are not verified yet.