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.

Optical ramp target Scroll under bars
FBO
Optics01 · Pyramid

Six-pass separable Gaussian mip pyramid

Horizontal and vertical 9-tap passes build half-res, 0.42x CSS and 0.18x CSS levels so 28 px blur stays smooth without grid stippling.

CSS
Optics02 · Comparison

Why stacked CSS backdrop-filter shows bands

Switch to Stepped CSS bands above to quantize the edge ramp into four mask plateaus and reveal step boundaries along sharp stripes.

RGB
Colour03 · Premult

Premultiplied alpha keeps white pills crisp

Setting UNPACK_PREMULTIPLY_ALPHA_WEBGL to true prevents dark fringing when anti-aliased text in #pb-chrome composites over blurred colour.

HIT
Optics04 · Geometry

Dual subtree hit testing at any scroll offset

Both #pb-feed and #pb-chrome call updateElementGeometry() with geometryUnit() and toggle data-hit-tick so buttons in either layer respond.

DPR
Colour05 · HiDPI

CSS-normalized blur stride at 2.625 DPR

Sizing levels 2 and 3 in CSS pixel ratios keeps a 28 px blur equally wide on a Pixel screen and a 1x desktop viewport.

2D
Colour06 · Fallback

Five-argument drawElementImage() and plain HTML

Without WebGL 2, a 2D canvas copies the feed into a plain buffer for banded blur; on context loss, both subtrees move to plain HTML.

Bottom dock test strip Check capsule edge
Feed All · 6

Starting...

Show the code two drawable subtrees, 6-pass separable FBO pyramid, progressive shader and geometry sync
  1. Two sibling drawable subtrees in one canvas. #pb-feed handles native inner scrolling and #pb-chrome holds the transparent-backed floating header and bottom capsule with pointer-events: none on the wrapper.
  2. 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.
  3. 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.
  4. ElementGL upload, FBO composite and hit-box sync. Gates uploads on hasPainted, calls stage.begin() before stage.upload(), keeps UNPACK_PREMULTIPLY_ALPHA_WEBGL enabled and updates updateElementGeometry().
  5. 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