Progressive backdrop blur behind floating bars
I wanted to know if one WebGL 2 canvas could run a multi-pass progressive Gaussian blur behind a floating top navigation header and bottom capsule over a live scrolling feed, while keeping controls in both subtrees clickable with updateElementGeometry(). Scroll the feed, type in the search box, or compare progressive blur against stepped CSS bands and uniform blur.
Starting...
Show the code two drawable subtrees, 6-pass separable FBO pyramid, progressive shader and geometry sync
- Two sibling
drawablesubtrees in one canvas.#pb-feedhandles native inner scrolling and#pb-chromeholds the transparent-backed floating header and bottom capsule withpointer-events: noneon the wrapper. - Six-pass separable Gaussian FBO pyramid. Runs horizontal and vertical 9-tap Gaussian passes across three CSS-pixel-normalized levels, then unbinds offscreen FBOs and VAOs before compositing.
- Progressive, stepped and uniform composite shader. Smoothly interpolates across the raw texture and three blurred mip levels over
uRampPx, or switches to 4 stepped CSS bands or rounded-box uniform blur. ElementGLupload, FBO composite and hit-box sync. Gates uploads onhasPainted, callsstage.begin()beforestage.upload(), keepsUNPACK_PREMULTIPLY_ALPHA_WEBGLenabled and updatesupdateElementGeometry().- Five-argument 2D fallback. Draws both subtrees with 5-argument
drawElementImage()and clips blurred top and bottom strips from a plain copy buffer.
How it works
One <canvas id="pb-canvas" content="drawable" layoutsubtree> holds two drawable children inside a single ElementGL WebGL 2 context from /lib/element-gl.js. The first child, #pb-feed, uses overflow-y: auto, overscroll-behavior-y: contain and touch-action: pan-y so touch drags and wheel scrolling stay inside the phone frame while #pb-search keeps user-select: text. The second child, #pb-chrome, sits above it with pointer-events: none on the overlay and pointer-events: auto on the floating top header and bottom capsule.
On each paint or scroll update after hasPainted turns true, stage.begin() sizes the WebGL buffer first and stage.upload() copies #pb-feed and #pb-chrome via gl.texElementSubImage2D() with UNPACK_PREMULTIPLY_ALPHA_WEBGL set to true. Next, createBlurPyramid() runs six offscreen separable 9-tap Gaussian passes (horizontal then vertical across a half-res prefilter, a 0.42x CSS level and a 0.18x CSS level) so a 28 px blur looks identical at 1x and 2.625x device pixel ratios, then unbinds every offscreen FBO and VAO before calling stage.begin() again for screen output.
In Progressive mode, the composite shader maps distance from the top and bottom viewport edges across uRampPx (40 to 140 px) through smoothstep and blends smoothly between the sharp feed texture and the three blurred pyramid levels, leaving the middle of the feed unblurred. Stepped CSS bands quantizes the same ramp into four mask plateaus with visible step seams, while Uniform clips constant blur strictly inside the rounded header and capsule boxes.
After drawing, syncGeometry() updates updateElementGeometry() on both #pb-feed and #pb-chrome using geometryUnit() from /lib/surface.js and toggles dataset.hitTick so clicks in both layers hit their moved DOM boxes. Smooth scroll jumps pause off screen via IntersectionObserver and when document.hidden is true, and snap straight to target when prefers-reduced-motion: reduce or the Reduced motion checkbox is checked. Without WebGL 2, the canvas switches to 5-argument drawElementImage() strips, and on context loss both subtrees move to plain HTML with CSS backdrop-filter.
Live checks
Each check builds an isolated fixture on testStage() without scrolling or focusing the demo above. Press Run to test this browser.
Findings
- Measured in headless Chrome 160 Canary on 2026-11-27 (
412x915viewport,2.625DPR, touch emulation, SwiftShader WebGL): all6/6live checks pass, the canvas stays at1.24 MP(927x1335,9.9 MB) on1WebGL context,0console or page errors occur andscrollWidth === innerWidth === 412. - Six-pass separable pyramid stays consistent across DPR: running a half-resolution prefilter followed by
0.42xand0.18xCSS-pixel levels keeps a28 pxoptical blur equal across1xdesktop and2.625xphone screens while reducing RMS stripe contrast monotonically from64.2in the sharp middle (y = 145 px) to4.5aty = 10 px. - Dual subtree hit testing needs explicit wrapper sizing: inside
<canvas layoutsubtree>, settinginset: 0on#pb-chromewithoutwidth: 100%; height: 100%collapsed the overlay height and shifted the bottom dock above the canvas. Setting explicitwidth: 100%; height: 100%withpointer-events: noneon#pb-chromeandpointer-events: autoon the two bars landselementsFromPoint()cleanly on buttons in both subtrees. - Fallbacks and reduced motion:
?route=2drenders 5-argumentdrawElementImage()strips at1.24 MPwith0draw-size errors,?route=plainmoves both subtrees into#plain-hostwith CSSbackdrop-filter, and togglingprefers-reduced-motionsyncs the Reduced motion checkbox and.motion-warnbanner. - Not verified yet: real Chrome 159 on Android at 412 px (GPU frame rate during touch momentum, soft keyboard over
#pb-search) andnpm run check:jank -- /progressive-blur/(Playwright isn't installed in this environment).