
WebGL2 Liquid Glass Floating Dock
Real-time WebGL2 convex SDF refraction shader with smooth optical lensing across floating monochrome dock icons.
CSS backdrop-filter applies a flat Gaussian blur that feels like frosted plastic. Real optical glass needs analytical SDF edge refraction, 1.12 / 1.00 / 0.88 RGB chromatic dispersion, and dual-direction Fresnel rim highlights. Try 7 free MIT single-file WebGL2 components live below, inspect the shader math, and paste straight into Grok Build (ex-Cursor), Gemini, or Claude Code.
FREE & MIT OPEN SOURCE

Real-time WebGL2 convex SDF refraction shader with smooth optical lensing across floating monochrome dock icons.

WebGL2 segmented control with crisp RGB chromatic dispersion (1.12/1.00/0.88) and liquid lensing across tabs.

Draggable WebGL2 spherical glass magnifier lens with physically-inspired edge refraction over crisp typography.

WebGL2 smooth-min metaball Dynamic Island layered with Canvas 2D live equalizer UI and detached satellite ring.

Two optical glass droplets fusing via smooth-min SDF over crisp typography with real-time lensing and sky-blue aura.

Velocity-stretched liquid glass toggle switch with smooth optical highlights and crisp tactile state morph.

WebGL2 liquid-glass morphing action pill with smooth SDF metaball fusion and keynote spring overshoot.
OPTICAL COMPARISON
| Optical Property | CSS backdrop-filter | Dinggao WebGL2 SDF |
|---|---|---|
| Edge optical refraction | None — uniform flat blur | Analytical SDF normal bending (pow(edgeT, 2.05)) |
| Core lens magnification | Not possible with CSS blur | Subtle radial lens magnification over crisp 2× texture |
| RGB chromatic dispersion | Requires heavy SVG filter hacks | Native 3-channel UV split (1.12 / 1.00 / 0.88) |
| Specular Fresnel rim | Static 1px border | Dual-direction Fresnel key + cold-sky bounce light |
| Runtime bundle & FPS | Can lag on mobile compositors | 0 KB dependencies · single fullscreen pass · 60fps |
PRODUCTION SHADER ARCHITECTURE
Never scale glass width by viewport width and height by viewport height independently. Derive a single uniform fitW and clamp corner radius r = min(halfSize.x, halfSize.y) in GLSL so desktop ultrawides and 390px mobile viewports stay optically proportional.
function getLayout(w, h) {
const safeW = Math.max(2, w);
const safeH = Math.max(2, h);
const aspect = safeW / safeH;
const portraitBoost = aspect < 1 ? clamp(1.0 + (1.0 - aspect) * 0.55, 1.0, 1.28) : 1.0;
const fitW = Math.min(safeW * portraitBoost, safeH * 1.6);
const sc = fitW / 640;
return { fitW, sc, cx: safeW * 0.5, cy: safeH * 0.52 };
}Instead of heavy 3D raymarching, compute an analytical rounded-box SDF and its exact normal gradient. Using pow(edgeT, 2.05) keeps the interior readable while bending pixels sharply across the curved outer 74% bevel.
// Analytical rounded-capsule SDF + convex bezel refraction (#version 300 es) float r = min(u_halfSize.x, u_halfSize.y); float halfLen = max(0.0, u_halfSize.x - r); float d = sdRoundedBox(p, u_halfSize, r); vec2 grad = gradCapsule(p, halfLen); float bezelW = r * 0.74; float edgeT = clamp(1.0 + d / bezelW, 0.0, 1.0); float rimProfile = pow(edgeT, 2.05); vec2 rimRefract = -grad * rimProfile * (25.5 * u_scale) / u_res; vec2 coreMag = -p * 0.115 / u_res; vec2 baseDisp = rimRefract + coreMag;
Heavy rainbow aberration looks like cheap neon. Splitting Red, Green, and Blue UV offsets by 1.12 / 1.00 / 0.88 alongside an opposing white key light and cold-sky (#38BDF8) bounce delivers studio-grade glass without color noise.
// Subtle RGB chromatic dispersion (1.12 / 1.00 / 0.88) + dual Fresnel rim highlights vec2 uvR = clamp(v_uv + baseDisp * 1.12, 0.001, 0.999); vec2 uvG = clamp(v_uv + baseDisp * 1.00, 0.001, 0.999); vec2 uvB = clamp(v_uv + baseDisp * 0.88, 0.001, 0.999); vec3 refracted = vec3(sampleScene(uvR).r, sampleScene(uvG).g, sampleScene(uvB).b); float rimBand = pow(edgeT, 3.3); vec2 dirA = normalize(vec2(-0.62, 0.78)); vec2 dirB = normalize(vec2( 0.62, -0.78)); float fresnelA = pow(max(0.0, dot(grad, dirA)), 1.5) * rimBand; float fresnelB = pow(max(0.0, dot(grad, dirB)), 1.9) * rimBand; vec3 glass = mix(refracted, vec3(0.99, 0.995, 1.0), clamp(fresnelA * 0.95, 0.0, 1.0)); glass += vec3(0.220, 0.741, 0.973) * fresnelB * 0.56;
PRO OPTICAL SERIES · 114 PRO FINALS IN LIBRARY

WebGL2 · Liquid Glass

WebGL2 · Torus SDF

WebGL2 · Fluted Glass

WebGL2 · Liquid Glass

Fresnel · WebGL2

Water Drops · Glass
FAQ
Yes. Every Dinggao Liquid Glass component caps devicePixelRatio at 2, locks geometry to an aspect-safe uniform scale (preventing portrait capsule distortion), and renders a single fullscreen triangle pass with pre-baked 2D Canvas textures so iOS Safari and modern Android browsers stay locked at 60fps.
Zero external dependencies. Each component is a single self-contained HTML file (~12–22 KB uncompressed) using raw WebGL2 (#version 300 es) and Vanilla JS—no 600 KB 3D engine, no bundler lock-in, and trivial for Grok Build (formerly Cursor), Gemini, or Claude Code to port into React, Vue, or Next.js.
Yes. All 12 free finals on Dinggao (including the 7 Liquid Glass pieces on this page) are open-sourced under the MIT license on GitHub and free for personal and commercial products. The remaining Pro pieces unlock with a single Founding Lifetime pass ($49 one-time) or subscription.