Pixel sparkle ink ripple across live cards
I wanted to see if one ElementGL WebGL 2 canvas could render Pixel sparkle ink ripples across live Material cards without overflow: hidden boundaries getting in the way. Tap any button, switch, field or gap to burst up to four overlapping waves that light up DOM borders sampled from texElementSubImage2D().
Starting canvas…
Show the code drawable Material surface, 4-ripple uniform packer, quantum sparkle shader, hit-box sync and 2D fallback
- One drawable Material surface inside a single canvas. Every chip, button, switch and editable
<input>lives inside#sr-surfacewith nooverflow: hiddenbox trapping ripples inside individual cards. - Four-slot concurrent ripple packer.
launchRipple(),stepRipples()andpackRippleUniforms()accept explicit millisecond timestamps and pack up to four concurrent origins, progresses and fade envelopes intovec4[4]uniform arrays. - Turbulent perimeter, edge-glow and quantum sparkle shader. Computes luminance gradients across neighbouring texels of
uTex, perturbs the expanding radius with layered value noise, scatters flickering sub-pixel stars and shifts R/B channels along the wave crest. - Premultiplied
ElementGLupload gated onpaint. SetsUNPACK_PREMULTIPLY_ALPHA_WEBGLtotrueon creation and restore, callsstage.begin()beforestage.upload(surfaceEl)and updates only uniforms while waves animate. - Hit-box sync with
geometryUnit(). Callscanvas.updateElementGeometry()scaled bygeometryUnit()and togglesdataset.hitTickso clicks and text selection pass through to live DOM controls. - Five-argument 2D and plain-HTML fallbacks. Draws
#sr-surfacevia five-argumentdrawElementImage()with a radial 2D ripple overlay when WebGL 2 is absent, or moves the surface into#plain-hoston context loss.
How it works
A standard CSS ripple uses a pseudo-element inside a container with overflow: hidden, so the wave stops dead at each button's border and can't read neighbouring pixels. Putting all cards inside one <canvas content="drawable" layoutsubtree> flips that around.
- Spilling across card borders: none of the cards, chips or switches inside
#sr-surfacesetoverflow: hidden. A tap on Pause, Boost or the Edge glow switch fires a capture-phasepointerdownlistener on#sr-canvaswithout callingpreventDefault(), so the DOM click still lands while the expanding ripple crosses gaps onto neighbouring cards. - Four overlapping waves in one pass:
launchRipple()stores each tap's CSS pixel origin, palette index and start timestamp inside a four-slot ring buffer. When no ripples are active,uRippleCountis zero and the shader returnstexture(uTex, vUv)directly while stopping the animation loop. - Illuminating live DOM edges: when Edge glow is active, the fragment shader samples four neighbouring texels from
uTex(1.25texels apart) to estimate local luminance and alpha gradients. Card borders, switch thumbs and letters you type into the status input glow brightest right as the advancing crest passes over them. - Quantum sparkle vs flat CSS circle: switching between Pixel sparkle, Noisy ink only and Flat circle CSS-like isolates each layer on the same DOM texture. Under
prefers-reduced-motion: reduce, turbulent noise, sparkle flicker and chromatic shifts switch off, leaving a calm radial ring. - Fallbacks and lifecycle: the animation loop stops when the stage leaves the viewport (
IntersectionObserver) or the tab hides (visibilitychange). Without WebGL 2texElementSubImage2D(),render2DFallback()draws with five-argumentdrawElementImage(), and onwebglcontextlostthe surface moves into plain HTML until restored.
Live checks
Each check builds an isolated fixture on testStage() and retires its canvas when finished. The visible demo above isn't touched.
| Result | Experiment | Detail |
|---|
Findings
Measured in headless Chrome 160.0.0.0 canary on 2026-11-27 at 412 px wide and 2.625 DPR (SwiftShader WebGL). Chromium 157, npm run check:jank and Chrome 159 on Android are not verified.
- Works: four overlapping ripples and edge illumination in one pass. At
412x915and2.625DPR, the stage held oneElementGLWebGL 2 context at937x1057 px(0.99 MP,7.9 MB) with0errors. Check 2 measured ring luminance rising from23.6to91.5(+109.4peak gain), and Check 3 verified 4-ripple capping and0pixel difference across 8 sample points after completion. - Works: live DOM clicks and typing without
overflow: hidden. Check 4 confirmeddocument.elementsFromPoint()hit both the fixture<button>and<input>throughupdateElementGeometry()scaled bygeometryUnit(), and real clicks in Chrome 160 Canary toggledPause/Play,Boost, palette chips and text input while launching ripples from the tap coordinates. - Works: 5-argument 2D fallback, context recovery and reduced motion. With
texElementSubImage2D()removed, the 2D fallback rendered at0.99 MPwith0wrong-size draws and Check 5 measured luminance rising from21.4to57.9. Togglingprefers-reduced-motion: reducesynced#ctl-reducedand mounted.motion-warnwhen page metadata is loaded, then restored cleanly onno-preference. - Clock skew between pointer handlers and
requestAnimationFrame: early tests saw a freshly launched ripple vanish on the first animation frame because the rAF frame timestamp preceded the click handler'sperformance.now()by under a millisecond. Keeping ripples alive whenevertMs - startMs < durationMsand clamping elapsed time to>= 0fixed both WebGL and 2D loops. - Not verified: headless Chromium 157,
npm run check:jank -- /sparkle-ripple/(Playwright isn't installed here), and real Android Chrome 159 touch scrolling, on-screen keyboard opening and GPU frame rate.