How it works
A drop of thick glass trails your cursor over an interface that the page paints into a texture (WebGL can’t refract the DOM, so the page draws its own). The drop is a signed distance field, so a single full-screen pass knows, for every pixel, how deep inside the glass it is and which way the edge faces. Those two numbers give a height profile and a surface normal. The normal gives one refracted ray per wavelength. The flat centre stays clear, the rim squeezes the page into a bright compressed band, and smooth-min lets the drop melt into the glass toolbar like mercury. The interface is painted scenery, so its buttons do nothing, but the tab bar and the Day / Week / Month / Year control answer a tap by sliding their selection.
Pipeline (per frame)
ON CHANGE ONLY (load · resize · Background select)
layout: landscape 1280×720 · tablet 820-wide stack · phone 390-wide column (fitted to the height)
Canvas2D page ─▶ uBg SRGB8_ALPHA8 W×H (2560×1440) + mip chain, 8× anisotropic
Canvas2D glyphs ─▶ uFg SRGB8_ALPHA8 atlas, NEAREST (icons + labels that sit ON the glass:
one padded cell per toolbar shape, 720×440 at 2560×1440)
(the page canvas stays at W×H and is reused; it is reallocated only on resize)
uBg mip 1 ─▶ Gauss H ─▶ tmp ─▶ Gauss V ─▶ uB1 RGBA16F W/2×H/2 σ 3 CSS px ┐ frost pyramid,
uB1 ─▶ Gauss H ─▶ tmp ─▶ Gauss V ─▶ uB2 RGBA16F W/4×H/4 σ 8 CSS px ├ linear light,
uB2 ─▶ Gauss H ─▶ tmp ─▶ Gauss V ─▶ uB3 RGBA16F W/8×H/8 σ 22 CSS px ┘ tmp freed per level
whole repaint ≈ 1.4–2.1 ms main thread (3–10 ms the first time a scene is drawn)
EVERY FRAME
JS pointer ─▶ springs, sub-stepped at ≥ 240 Hz (dt-based):
head ω15 ζ.8 (≈105 ms behind) · stretch ω21 ζ.38 (wobbles) · grow · press
tail ×3 ω(24/19/15)·0.18^viscosity ζ(0.9 + 1.5·viscosity) + cohesion limit
2 selection pills ω17 ζ.72
─▶ uniforms in place: 1 uneven capsule, 3 tapered tail links + their joint k,
3 rounded rects, 2 pills, 4 bounding boxes, 3 glyph cells (0.05 ms)
GPU ONE full-screen pass ─▶ canvas (no render targets, no simulation)
outside all 4 boxes ─▶ page texel + dither (most pixels stop here)
d, ∇d, bezel = smin( smin(capsule, link_i; k_i), min(toolbar shapes); k_merge )
d > reach ─▶ page texel + dither
outside ─▶ page × key shadow (SDF at p + offset) × ambient halo
inside ─▶ x = s/bezel ─▶ h(x), h′(x) ≤ 8, + 4 % dome ─▶ normal n
─▶ 7 × refract(−z, n, 1/η(λ)) ─▶ textureGrad(uBg) │ uB1..uB3 (frost)
─▶ vibrancy · tint (mixed in sRGB) · toolbar legibility
─▶ Schlick F − F₀ → uB3 just outside the rim (light: darker, saturated, + sky)
─▶ key highlight + counter, minus their flat-face value (a shade on light pages)
─▶ hairline / lit edge ─▶ 1 px analytic AA ─▶ selection pills ─▶ uFg atlas cell
─▶ sRGB + dither
The ideas that matter
- A squircle bezel, with its slope clamped. Inside distance
sover bezel width givesxin 0..1, and the glass height ish = (1−(1−x)⁴)^¼. It rises almost vertically at the edge, then lies flat, so the centre is clear and all the bending happens in the rim. The slopeh′is infinite atx = 0, so it is clamped at 8. Otherwise the outer pixel ring would turn to NaN. - Thickness is what sells “thick”. The page offset is
R.xy / −R.z × T·h, which is zero at the very edge, peaks in the outer tenth of the bezel, then decays. I modelled the mapping numerically before choosing defaults. With an 80 px bezel, a thickness of 0.5 moves the page by at most 14 px, which looks like a flat disc with an outline. At 1.0 it moves by 35 px, so the outer 8 px show 35 px of page (a 4:1 squeeze). Above about 1.4 a mirrored band appears inside the rim, the jewel look the Prism preset uses. - Analytic gradients, even through smooth-min. Each SDF returns its distance and its outward unit gradient: rounded rect, circle, and iq’s uneven capsule in a rotated frame. For the polynomial smin
mix(b,a,h) − k·h(1−h), the h-derivative terms cancel, so the gradient is exactlymix(∇b, ∇a, h). The samehblends the bezel width and a “toolbar-ness” weight, so a merged neck gets one continuous surface. There are no finite differences, and no 2×2-quad blockiness fromdFdxnormals. - Filtering that matches the compression. The rim squeezes the page up to about 4:1, so a plain lookup would shimmer while the drop moves. The pass computes the refracted UV and its
dFdx/dFdybefore any branch that could differ inside a 2×2 quad. The derivatives come after the bounding-box reject, but that is safe: the boxes sit more than the shadow reach away from any glass, so every quad on a box edge leaves atd > reachbefore it reads them. The pass then usestextureGradon the mipmapped, anisotropic page, so the hardware filters exactly as much as the glass squeezes. - A clear centre that stays clear. Three things used to lay a milky film over the flat face. Tint was mixed in linear light, where 6 % white lifts black to 27 % grey. Schlick’s 4 % at normal incidence pulled the whole face toward a brightened environment. And the highlights’ broad tails left a faint sheen. Now the tint is mixed in sRGB, so 2 % (the default) reads as 2 %. Only the grazing part of Fresnel,
F − F₀, is used, and each highlight has its flat-face value subtracted. Measured under the resting drop: the black Get started button goes from 25 to 30 (out of 255) on Clear, black stays at 8–9 on Prism, and Dark glass’s navy gets a little darker (smoky) instead of greyer. Toolbar glass takes only 30 % of the tint, so its white labels stay readable even at a tint amount of 0.8. - Dispersion as a spectrum, not an RGB split. Seven taps each refract with their own index
η + δ(2t−1). Each tap is weighted by three overlapping tents (red, green, blue), and the weights are normalised per channel. Zero dispersion therefore reproduces the page exactly, and strong dispersion gives a smooth rainbow rather than three ghost copies. - Frost from a Gaussian pyramid, not box mips. Hardware mips magnified 8–16× show blocky diamonds. Instead, three separable Gaussians (σ 3, 8 and 22 CSS px, each built from the last at half the resolution, in linear RGBA16F) are blended between adjacent levels. That gives a continuous frost slider for one or two taps, and it is rebuilt only when the page changes.
- The rim mirrors its surroundings. Schlick Fresnel
F₀ + (1−F₀)(1−n.z)⁵, minus its normal-incidenceF₀, mixes toward the 22 px blurred page sampled just outside the rim, alongn.xy. The steep edge picks up the colour around it, the way real glass does. On dark pages that colour is brightened. On light pages, a brightened copy of an already pale page would vanish, so the rim instead mirrors a darker, more saturated copy under a cool sky (bright above, slate below), and the grazing term gets 3.2× the gain. The Fresnel slider then moves the rim from undefined to a crisp glass edge. A Blinn-Phong key highlight sits top-left. The counter-highlight opposite is a 45 % highlight on dark pages and a shade on light ones, where white would not show. - A drop that behaves like liquid. The stretch is an under-damped spring on velocity, and the capsule radius conserves area:
r = (√(l² + π²R²) − l)/π. A fast drop narrows as it lengthens and wobbles round when it stops. Three tail drops chase it on softer springs with a cohesion limit. Tail viscosity softens those springs by0.18^v, over-damps them (ζ from 0.9 to 2.4) and lengthens the limit by up to 25 %. At the default 0.8 the strand drains back into the drop over about 2 s after you stop, instead of springing in. The drop materialises by growing in with an overshoot, and it swells while the button is held. - A tail that tapers instead of beading. Circles chained with smooth-min need a big
kto bridge their gaps, and smooth-min inflates shapes by up tok/4: the strand either broke into beads or swelled at the trailing end. Instead, each link is an uneven capsule from its parent’s centre and radius to its own drop. The strand is one tapered chain with no gaps, and the smooth-min only rounds the joints (k = 0.3·r, grown in with separation, so a joint bulges by under 8 % of the tail’s radius and the drop at rest is exactly the lens size). Tail radii follow the head’s stretched radius, so the strand always thins toward its end. The area the strand adds comes mostly out of the head (r² = R² − 0.7·A/π, floored at 0.6 R²), so a fast drop keeps roughly its resting mass. - Merging without everything merging. The drop smooth-mins with the toolbar (
k = 0.8·merge·Rin the classic form above, 0.2·merge·R in iq’s normalised form). The toolbar shapes join each other with a plainmin, so the tab bar and the search button never bridge. Toolbar glass gets a light legibility dim, weighted by the sminh, plus a soft halo behind the glyphs on dark pages, and the free drop stays perfectly clear. In the Spectrum scene the barcode stops just inside the tab bar’s top rim, so the rim still squeezes the bars while the labels sit on black. - One pass, but most pixels skip it. Every frame, the JS computes bounding boxes for the drop group and for each toolbar shape, grown by the shadow reach and the worst-case smin bulge. Outside all four, a pixel is just the page texel. The boxes sit more than the reach away from any glass, so the 2×2 quads that need
dFdxare never split. In an A/B on a busy shared GPU (six alternating sweeps each), the median frame fell from 2.7 to 2.2 ms. Most of what remains is the full-screen texel read and write that every frame pays. - An interface that fits any screen. The page is laid out in one of three design frames, chosen by aspect: landscape 1280×720, a tablet frame 820 wide with the headline stacked above the photo, or a 390-wide phone column. Tablet and phone frames take the full stage height, so the toolbar sits at the bottom. The photo and widgets shrink, then the widgets drop out, to fit above it (a 360×640 phone keeps the photo and loses the widgets). With reduced motion, the toolbar lifts above the shell’s note. In the landscape frame the lens radius is measured in frame units too, so the drop keeps its size against the interface at any window width. The ghost path is planned on the same layout. The intro crosses the photo and widgets and dips into the tab bar. It then eases to rest at the first spot where the drop covers no widget, button or screen edge: beside the search button when there is room, otherwise on the photo, fused with the end of the segmented control. At the default size that is the photo in every landscape window, from 1280×720 to 2560×1080.
- Different depth cues on light and dark. On light pages, highlights vanish, so the glass gets a darker 1 px hairline, a coloured key shadow and an ambient halo. On dark pages, the same shadows darken instead of tinting, and the glass gets a faint lit edge and a brighter environment.
Parameters
Presets
Performance & compatibility
- Measured (verification harness, Chrome on an Apple M-series Mac, 2560×1440 backing store, scripted sweep). The GPU was shared with other effects’ test runs (load average about 6), so the figures are a range over six harness runs: GPU 1.4–3.2 ms mean / 2.3–6.6 ms p95 per frame, JS 0.05–0.08 ms per frame, 60 fps in every run. An alternating A/B against the previous revision (four 2 s sweeps each) measured 1.3–2.0 ms mean against 1.2–3.1 ms, so the tapered tail links and the glyph-cell lookup cost nothing measurable. In a per-preset sweep (2.5 s each, twice), every preset averaged 1.5–2.2 ms. No preset was consistently the heaviest: the differences were smaller than the run-to-run noise.
- What scales it: the glass area. Outside the bounding boxes, a pixel costs one texel fetch. Inside them, the SDF scene runs, and past shadow reach it again costs one fetch. Inside the glass, the seven-tap spectral loop runs only where red and violet land more than 0.6 px apart, which is the outer rim at low dispersion. Elsewhere, or with dispersion 0, it is one tap. Changing the Background repaints the Canvas2D page and the glyph atlas, uploads them and rebuilds the pyramid. That takes 1.4–2.1 ms on the main thread once a scene has been drawn, or 3–10 ms the first time each scene is drawn while Chrome warms its caches (before the page canvas was kept and the glyphs moved into an atlas: 2–7 ms, and 5–15 ms the first time).
gl.finish()adds nothing measurable. - Memory at 2560×1440: page 14.7 MB + mips 4.9 MB, glyph atlas 1.3 MB (720×440), frost pyramid 9.7 MB (RGBA16F, one target per level). That is about 31 MB of textures. The page’s Canvas2D (14.7 MB) and the atlas canvas (1.3 MB) are kept, so a Background change repaints without reallocating them. Add to that the canvas’s own drawing buffer. During a repaint only, one blur scratch target of at most 7.4 MB also exists.
- Requirements: WebGL2 and
EXT_color_buffer_float(for the RGBA16F pyramid). Without them the shell shows a message over the poster frame. Shaders use only GLSL ES 3.00 with constant-bounded loops. - Mobile: DPR is capped at 2, so the canvas-drawn type is as sharp as the DOM HUD beside it (a 390 px phone renders 780×1688). In the tablet and phone frames the lens radius is 12 % of max(short side, 0.6 × long side), so it stays finger-sized. In the landscape frame it is 12 % of 768 frame units (92 CSS px at 1280×720). The phone layout fits the height it has: at 390×664 (Safari with its toolbars) or 360×640, the widgets row drops out and the photo shrinks above the tab bar. Squarer screens (an iPad in portrait, or a 1000×1000 window) get the stacked tablet frame. The harness measured 48–51 fps on an emulated 390 px touch drag.
- Idle and reduced motion: the loop stops 7 s after the last input (harness: idle after 7.1 s, 0 frames after). With
prefers-reduced-motionit renders one still, with the drop at rest on the photo card fused with the segmented control. The layout lifts the toolbar, and shrinks the column above it, so the toolbar stays clear of the shell’s note. The still re-renders when a control changes or a tab is tapped, and “Play anyway” gives the toolbar its usual place back. The gallery embed runs at DPR 1 on the autopilot loop, phased so the poster frame shows the drop merging with the toolbar.
References & credits
- kube.io, “Liquid Glass in the Browser: Refraction with CSS and SVG” (2025): the convex-squircle bezel profile and the one-interface refraction model. kube.io/blog/liquid-glass-css-svg. Article, license not stated; formulas reimplemented, no code used.
- iyinchao, Liquid Glass Studio: smooth-min merging of glass shapes, and per-channel dispersion. github.com/iyinchao/liquid-glass-studio. MIT; ideas only, no code copied.
- Inigo Quilez, “Smooth minimum” and “2D distance functions” (
sdUnevenCapsule). iquilezles.org/articles/smin, iquilezles.org/articles/distfunctions2d. Articles, license not stated; formulas reimplemented (here with analytic gradients), no code used. - Dave Hoskins, “Hash without Sine”: the dither hash. shadertoy.com/view/4djSRW. MIT, attributed in the shader.
- C. Schlick, “An Inexpensive BRDF Model for Physically-based Rendering”, Computer Graphics Forum 13(3), 233–246 (1994): the Fresnel approximation. doi.org/10.1111/1467-8659.1330233. Paper; formula reimplemented, no code used.
- Apple, WWDC25 session 219 “Meet Liquid Glass”: the reference look (lensing over fading, a flat centre, a compressed rim). developer.apple.com/videos/play/wwdc2025/219. Look only; no code exists to copy.
- Library research notes:
research/distortion-glass-post.md(Liquid glass),research/rd-metaballs-sdf.md(smooth-min, SDF blobs). Everything on this page, including the canvas-drawn interface, was written from scratch for the FX library.