Tactile press dent and damped elastic shockwave pad
I wanted to know if one ElementGL canvas can dent a live 3×2 HTML pad under pointerdown and release damped concentric shockwaves across neighbouring tiles while every control stays clickable. Hold a tile to dent it, release to ripple, or switch to flat CSS press.
Show the code Drawable pad markup, deterministic tMs wave solver, dent and shockwave shader, upload and fallbacks
- Live 3×2 pad inside one drawable canvas.
#ti-padholds six tactile button and switch tiles, live increment readouts and a selectable<input id="ti-label">inside<canvas id="ti-canvas" content="drawable" layoutsubtree>. - Deterministic dent and 4-ring wave solver plus hit-box sync.
stepImpactWaves()evaluates press compression and up to four concurrent damped wave rings at timestamptMs, andsyncPadGeometry()aligns hit boxes viageometryUnit()andupdateElementGeometry(). - Press dent and concentric shockwave fragment shader.
IMPACT_FRAGbends nearby pixels inward arounduPressPoswith cavity darkening and a raised rim highlight, then integrates up to four propagatingsin(r*k - w*t) * exp(-decay*r - timeDecay*t)rings with finite-difference surface normals. - Premultiplied uploads, 5-argument 2D fallback and context recovery. Turns on
UNPACK_PREMULTIPLY_ALPHA_WEBGL = trueon creation and restore, gatesstage.upload()behindhasPaintedandstage.begin(), and falls back to 2D ring overlays or#plain-host.
How it works
The entire control surface sits inside one <canvas id="ti-canvas" content="drawable" layoutsubtree> managed by a single ElementGL WebGL 2 context from /lib/element-gl.js. Both at creation and inside onRestored, the page turns on gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true) so keycap bevels, counters and input borders stay crisp without dark fringes. Uploads stay gated behind hasPainted inside the paint handler, and stage.begin() sizes the backing store before stage.upload() transfers #ti-pad via texElementSubImage2D().
Pressing down on any tile or pad gap stores an active press origin and ramps uDentDepth smoothly over 80 ms. In IMPACT_FRAG, the depression forms a Gaussian bowl with a subtle outer rim lip: pixels around the press pull gently inward toward the fingertip while finite-difference surface normals darken the concave centre and add a specular highlight along the rim. On release (or when you press Drop pulse), stored dent energy converts into an entry in a four-ring buffer evaluated at timestamp tMs by stepImpactWaves(). Each active ring evaluates -sin(r*k - w*t) * exp(-r*rDecay - t*tDecay) behind a causal wave front at speed * t, pushing neighbouring HTML tiles radially outward on crests and catching Blinn-Phong highlights along tilted slopes until exponential decay drops amplitude to zero.
Every button, switch and input inside #ti-pad remains clickable because syncPadGeometry() calibrates CSS-to-canvas scale with geometryUnit(), applies updateElementGeometry() and toggles data-hit-tick to flush Chromium's hit-test cache. Pointer tracking avoids calling setPointerCapture() on interactive buttons and inputs, and a selectstart guard stops drag selection across the pad while leaving user-select: text enabled on #ti-label. Animation frames pause when the stage scrolls off screen (IntersectionObserver), when document.hidden is true, when Flat CSS press or Reduced motion is active, and whenever all rings finish decaying. When WebGL 2 isn't available or ?route=2d is set, a 5-argument drawElementImage() pass draws the pad with a 2D concentric ring overlay; on webglcontextlost, ?route=plain or missing API support, #ti-pad moves into #plain-host as plain HTML.
Live checks
These checks run on isolated fixtures inside testStage() and wait for a tap so loading the page allocates one WebGL context and moves nothing on screen.
| Status | Check | Detail |
|---|
Findings
- Measured in
HeadlessChrome/160.0.0.0on 2026-11-27 (412×915at DPR2.625with touch emulation andCanvasDrawElementenabled): all 6 live checks pass with0console errors,scrollWidth === 412, a945×877backing store (0.829 MP,6.63 MBinitial,15.36 MBpeak),glPeak = 2,openSnapshots = 0,unaskedReads = 0,noSizeDraws = 0andwrongDraws = 0. - Holding
pointerdownonPAD 01ramped dent depth to109%, darkened the cavity centre luminance from212to136, lifted the outer rim lip to241and pulled the reference stripe inward (x=144luminance212down to156). - Releasing four taps in sequence ran
4/4concurrent shockwave rings (266 px/s) across neighbouring tiles and the pad label input before settling back to0/4 ringsand0 px/s. In the isolated wave fixture, neighbouring tile colour difference reached334at280 msand returned to0once settled. - Real clicks and typing updated
PAD 01, flippedSW A(aria-checked="false",OFF · 1) and typed into#ti-label(BANK A · PERCU LIVESSION). Under?route=2d, the 5-argumentdrawElementImage()ring overlay ran withwrongDraws = 0; under?route=plainor--disable-blink-features=CanvasDrawElement,#ti-padmoved into#plain-host(inert = false,scrollWidth = 412); under emulatedprefers-reduced-motion: reduce,Drop pulsekept0/4 ringsand0 px/s. - Running
/lib/a11y-audit.jsat960×800(DPR2, focus emulation enabled) passed 9 checks (calm,blank,dom,hit,ghost,focus7/7,names7/7,sharp,motion) with 0 failures and 1 warning (zoom, becauseElementGL.#syncSize()does not multiply backing pixels bycurrentCSSZoom). npm run check:jank,node tools/draw-size/audit.mjs, real Chrome 159 on Android hardware andsocial.jpgcapture are not verified.