Liquid glass floating toolbar

I wanted to see if one WebGL 2 canvas could float a translucent iOS 26 style glass capsule dock over a live scrollable HTML feed, refracting and dispersing passing cards through a bevelled capsule edge while keeping buttons on both layers clickable. Scroll the feed, drag the glass dock over the photo cards, tap tabs, or compare Liquid refraction, Flat frosted glass and Magnify x1.4.

Optics Feed 6 cards
OPTICS · 35MM F/1.8
Coral Amber

Analytic bevel refraction across scrolling cards

Snell's law bends rays inward along the steep capsule rim using the exact gradient of a rounded rectangle SDF.

AURORA · HDR 10-BIT
Cyan Emerald

Diagonal light beams passing under the capsule

Chromatic dispersion splits red and blue refractive indices along the rounded rim while the centre magnifies softly.

CHROMA · PRISM CALIBRATION
Spectrum Dispersion

Vertical colour bars reveal bevel curvature

Dragging the floating dock over vertical stripes shows the curved meniscus pulling colour seams toward the capsule centre.

SOLAR · 50MM FLARE
Gold Rose

Offscreen Gaussian blur FBO underlay

A separable blur framebuffer supplies frosted milkiness behind crisp premultiplied dock labels uploaded with UNPACK_PREMULTIPLY_ALPHA_WEBGL.

CANVAS · GL2 1:1 UI
Lime Cobalt

Both layers stay independently clickable

Calibrating updateElementGeometry() with geometryUnit() and toggling dataset.hitTick aligns tabs after every dock drag.

STUDIO · BW DISPERSION
Monochrome Fringe

High-contrast stripes expose red-blue fringes

Horizontal black and white bands make chromatic aberration along the top specular bevel easy to inspect and measure.

Starting...

Show the code two-child canvas markup, blur FBO, capsule SDF refraction shader and hit-test sync
  1. Two drawable subtrees in one canvas. #lt-feed handles native vertical scroll while #lt-dock floats on top with touch-action: none.
  2. Separable offscreen blur FBO. Blurs #lt-feed into a half-resolution framebuffer, then unbinds both FBO and VAO before compositing to screen.
  3. Analytic capsule SDF refraction shader. Computes the exact rounded-capsule gradient, traces Snell's law per RGB channel along the curved rim and composites crisp premultiplied #lt-dock pixels on top.
  4. Texture upload and geometry sync. Applies UNPACK_PREMULTIPLY_ALPHA_WEBGL = true, calls stage.begin() before stage.upload(), and updates updateElementGeometry() plus dataset.hitTick whenever the dock moves.
  5. Five-argument 2D and plain HTML fallbacks. Draws both children with 5-argument drawElementImage() without WebGL 2, and moves both to plain HTML on context loss.

How it works

Both #lt-feed and #lt-dock sit as direct drawable children inside one <canvas content="drawable" layoutsubtree> managed by a single ElementGL WebGL 2 context. Keeping gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true) active at creation and on restore stops translucent white capsule borders and the sliding .lt-pill indicator from washing out to opaque white during gl.texElementSubImage2D() uploads.

Whenever the feed changes or scrolls, a separable four-pass blur pipeline blurs the feed texture into a half-resolution offscreen framebuffer, then unbinds the framebuffer and VAO before ElementGL draws to the screen. Inside the main fragment shader, pixels outside the floating capsule draw #lt-feed directly with a soft drop shadow. Pixels inside the capsule evaluate the exact analytic gradient of a rounded rectangle SDF, derive a 3D surface normal across a 20 px curved bevel, and trace refract() for red, green and blue at slightly offset refractive indices so passing stripes bend inward and split into fringes near the rim.

After mixing the refracted feed with the blurred offscreen underlay and adding a directional top-rim specular glint, the shader composites #lt-dock at 1:1 CSS layout coordinates so button labels and SVG icons stay sharp. Dragging the dock moves its hit box through updateElementGeometry() calibrated by geometryUnit() and flips dataset.hitTick to clear Chromium's hit-test cache, while an IntersectionObserver and document.hidden pause the spring loop off screen.

Live checks

Each check builds an isolated fixture on testStage() without scrolling or focusing the demo above. Press Run to execute them in this browser.

Findings