Datamosh and RGB block-slice glitch cut

I wanted to know if one ElementGL WebGL 2 canvas could run NLE-style datamosh, horizontal sync tear and RGB chroma-shatter cuts between two live HTML panels while keeping buttons, toggles and editable inputs working. Press Trigger cut to B, scrub the cut slider or drag across the stage to smear macroblocks across both views.

LIVE FEED · CH-A STUDIO 4 · 1080i50
EDITORIAL BROADCAST FEED

Backup transit ring live

Active feeds: lower3rd · wire · live sync

Cues: 0 · ON AIR
NODE-07 · CONSOLE RTT 14 ms · B
BUFFER 84%
PACKETS 1,240/s
ROUTE AUTO-SYNC
> filter: node-07.edge.lon --live
Flushes: 0 · SYNC OK

Starting canvas…

Show the code dual-scene canvas markup, ping-pong smear FBO, transition envelope, hit sync and 2D slice fallback
  1. Two live panels in one drawable canvas. Both #gc-scene-a (Editorial Broadcast Feed) and #gc-scene-b (Telemetry Node Console) sit directly inside <canvas content="drawable" layoutsubtree>.
  2. Explicit timestamp envelope. triggerCutEnvelope() and stepCutEnvelope(env, tMs) drive cut progress and glitch bell decay from explicit millisecond timestamps.
  3. Ping-pong smear and three glitch shaders. SMEAR_FRAG advects frozen macroblocks along motion vectors and COMPOSITE_FRAG switches between Block datamosh, Scan tear, Chroma shatter and a reduced-motion geometric wipe.
  4. Ping-pong FBO pipeline with clean unbind. Draws pass 1 into the back smear FBO, unbinds with gl.bindFramebuffer(gl.FRAMEBUFFER, null) before compositing to screen, and finishes with gl.bindVertexArray(null).
  5. Paint gating and selective uploads. Waits for hasPainted = true, runs stage.begin() before stage.upload() and skips re-uploading unchanged scenes during shader frames.
  6. Active scene hit-box calibration. Routes updateElementGeometry() and geometryUnit() to the dominant view, marks the hidden view inert offstage and toggles dataset.hitTick.
  7. Five-argument 2D slice and plain-HTML fallbacks. Draws horizontal slice cuts via 5-argument drawElementImage() without WebGL 2, or moves both views into #plain-host on context loss.

How it works

Both live panels stay mounted inside one <canvas content="drawable" layoutsubtree> driven by a single ElementGL WebGL 2 context from /lib/element-gl.js. I set gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true) on creation and inside onRestored, wait for hasPainted = true inside the paint handler and call stage.begin() before calling stage.upload() on whichever scene changed.

During each transition or pointer drag, GlitchPipeline runs two passes. Pass 1 writes into one of two ping-pong RGBA8 FBOs, advecting stale tiles from View A along simulated P-frame motion vectors and pointer velocity. Before drawing pass 2 onto the canvas, it calls gl.bindFramebuffer(gl.FRAMEBUFFER, null), composites View A, View B and the smear buffer for the chosen preset (Block datamosh, Scan tear or Chroma shatter), and calls gl.bindVertexArray(null) when done. Under prefers-reduced-motion or the Reduced motion toggle, strobing and RGB flashes drop out in favour of a crisp stepped geometric wipe.

Dragging on the canvas injects pointer velocity into the shader while a selectstart guard keeps text selection off the panels outside #gc-a-input and #gc-b-input. Once a cut crosses 50%, syncSceneGeometry() switches inert and moves the inactive scene offstage via updateElementGeometry() calibrated with geometryUnit() and dataset.hitTick, so clicks and typing only land on the active view. An IntersectionObserver and document.hidden check pause the animation loop off screen.

Live checks

These checks wait for a tap so the page opens with one WebGL context running. Each check creates its own fixture on testStage() and retires it afterwards.

ResultExperimentDetail

Findings

Measured in headless Chrome 160.0.8188.0 canary on 2026-11-27 (412 px DPR 2.625 and 960 px DPR 2, SwiftShader WebGL), plus a fallback check with --disable-blink-features=CanvasDrawElement and emulated prefers-reduced-motion: reduce. Chrome 159 on Android, Chromium 157 and npm run check:jank stay not verified.