Liquid Glass Material (Web Recipe) new 液态玻璃材质(网页做法) web
A six-layer glass surface for the web: shadow, blur and light, edge refraction, tint, rim light, and adaptive ink
网页上的六层玻璃材质:投影、模糊提亮、边缘折射、着色、边缘光和自适应文字色
A card with no material: the text fights the wallpaper.
luminance 0.00 · ink fixed · tint 0%
标本可交互,可以直接操作。
Anatomy — every part, named解剖 —— 每个部件的名字
-
1 Shadow投影
box-shadowA soft drop shadow gives the card volume and lifts it off the wallpaper.
柔和的投影给卡片体积感,让它从壁纸上浮起来。
Prompt fragmentPrompt 片段the shadow layer: a soft, wide drop shadow plus a tighter contact shadow under the glass card
投影层:玻璃卡片下方一层宽而柔的投影,加一层更贴近的接触阴影
-
2 Blur & light模糊与提亮
backdrop-filterA small blur softens what is behind, while higher saturation and brightness keep the glass clear and vivid.
轻微模糊背后的内容,同时提高饱和度和亮度,让玻璃更通透鲜亮。
Prompt fragmentPrompt 片段the blur and light layer: backdrop-filter blur(2px) saturate(180%) brightness(1.06) on light glass, saturate(160%) brightness(0.8) on dark glass
模糊提亮层:浅色玻璃 backdrop-filter blur(2px) saturate(180%) brightness(1.06),深色玻璃 saturate(160%) brightness(0.8)
-
3 Edge refraction (lens)边缘折射(透镜)
feDisplacementMapNear the rim the backdrop bends inward, more the closer it is to the edge; the middle stays flat. Red bends a little more than blue, creating dispersion.
越靠近边缘,背景向内偏移越多,中间保持平整;红光比蓝光偏折多一点,形成色散。
Prompt fragmentPrompt 片段the lens layer: an SVG displacement map with a 44px rim band, edge offset 1.1x the band width, red and blue scales at plus and minus 15%
透镜层:SVG 位移贴图,边缘带 44px,边缘偏移 1.1 倍边宽,红、蓝比例各 ±15%
-
4 Tint着色
backgroundA thin translucent colour wash whose opacity rises with background complexity.
一层薄薄的半透明颜色,背景越复杂,透明度越低。
Prompt fragmentPrompt 片段the tint layer: white 6%-22% on light glass or rgb(20 20 24) 16%-38% on dark glass, thicker over busy wallpaper
着色层:浅色玻璃白色 6%–22%,深色玻璃 rgb(20 20 24) 16%–38%,背景越花越浓
-
5 Rim light边缘光
box-shadow: insetOne highlight top-left, one bottom-right, and a softer line set further in, so the edge catches light like a real slab of glass.
左上、右下各一道高光,再往里收一道更柔的线,让边缘像真的玻璃一样接住光。
Prompt fragmentPrompt 片段the rim light: inset highlights on the top-left and bottom-right edges plus a softer inner line
边缘光:左上和右下边缘各一道内高光,再加一道更柔的内线
-
6 Ink文字着色
mix-blend-modeText samples the average luminance behind the card: dark ink multiplies into light glass, and below 0.5 it switches to light ink that lightens dark glass.
文字采样卡片背后的平均亮度:浅色玻璃上深色字正片叠底;亮度低于 0.5 时换成浅色字,在深色玻璃上叠加提亮。
Prompt fragmentPrompt 片段the ink: sample backdrop luminance; dark text with multiply above 0.5, light text with plus-lighter below 0.5
文字着色:采样背景亮度,高于 0.5 用深色字 + multiply,低于 0.5 用浅色字 + plus-lighter
Prompt — paste into your agentPrompt —— 直接粘贴给你的代理
Turn this card into a liquid glass material built from six layers, exposed as four declarations: background: var(--glass-tint); backdrop-filter: var(--glass-blur) var(--glass-lens); box-shadow: var(--glass-edge); color: var(--glass-ink). 1 Shadow: a soft drop shadow so the card floats. 2 Blur and light: backdrop-filter blur(2px) saturate(180%) brightness(1.06) for light glass, blur(2px) saturate(160%) brightness(0.8) for dark glass. 3 Edge refraction: an SVG feDisplacementMap whose map is neutral in the middle and, within a 44px rim band, offsets the backdrop by up to 1.1x the band width so it bends inward near the edges; run three displacements with red at +15% and blue at -15% scale for a slight chromatic fringe; apply it with backdrop-filter: url(#lens) and fall back to blur only where unsupported. 4 Tint: white at 6%-22% for light glass or rgb(20 20 24) at 16%-38% for dark glass, thicker over busier backgrounds. 5 Rim light: inset highlights top-left and bottom-right plus a softer inner line. 6 Ink: sample the average luminance behind the card; at 0.5 or above use rgb(0 0 0 / 86%) text with mix-blend-mode: multiply, below 0.5 switch to light text that lightens with plus-lighter. Keep content legible at every position and honor prefers-reduced-transparency with an opaque fallback.
把这张卡片改成液态玻璃材质,由六层组成,对外只暴露四条声明:background: var(--glass-tint); backdrop-filter: var(--glass-blur) var(--glass-lens); box-shadow: var(--glass-edge); color: var(--glass-ink)。1 投影:柔和的投影,让卡片浮起来。2 模糊与提亮:浅色玻璃 backdrop-filter blur(2px) saturate(180%) brightness(1.06),深色玻璃 blur(2px) saturate(160%) brightness(0.8)。3 边缘折射:用 SVG feDisplacementMap,贴图中间不偏移,在 44px 宽的边缘带里把背景最多偏移 1.1 倍边宽,越靠边越向内弯;做三次位移,红色比例 +15%、蓝色 -15%,形成轻微色散;用 backdrop-filter: url(#lens) 套到背景上,不支持的浏览器退回只模糊。4 着色:浅色玻璃用白色 6%–22%,深色玻璃用 rgb(20 20 24) 16%–38%,背景越复杂越浓。5 边缘光:左上、右下各一道内高光,再往里收一道更柔的。6 文字着色:采样卡片背后的平均亮度,≥0.5 用 rgb(0 0 0 / 86%) 加 mix-blend-mode: multiply,<0.5 切换成浅色字并用 plus-lighter 提亮。卡片移到任何位置文字都要清楚,并在 prefers-reduced-transparency 时退回不透明背景。
Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时
Debug my liquid glass card. Check each layer separately: the shadow lifts the card without a dark halo; blur is small enough that the backdrop is still recognizable and saturation/brightness are applied after it; the displacement map is neutral grey (128,128) in the flat middle, uses color-interpolation-filters="sRGB", and its rim band matches the card's corner radius; the red/green/blue displacement scales differ by only about 15%; the tint strength follows background complexity instead of a fixed opacity; the rim highlights sit inside the radius; and the ink flips at luminance 0.5 with some hysteresis so it does not flicker. Also verify the Safari/Firefox fallback when backdrop-filter: url() is unsupported. The symptom:
调试我的液态玻璃卡片,逐层检查:投影是否让卡片浮起来而没有一圈黑边;模糊是否足够小、背景仍认得出来,饱和度和亮度是否在模糊之后生效;位移贴图中间是否是中性灰(128,128),是否设置了 color-interpolation-filters="sRGB",边缘带是否和卡片圆角对齐;红绿蓝三次位移的比例是否只相差 15% 左右;着色浓度是否跟着背景复杂度变化而不是固定值;边缘高光是否在圆角以内;文字颜色是否在亮度 0.5 附近切换,并带一点回差避免来回闪。另外检查 Safari / Firefox 不支持 backdrop-filter: url() 时的退回效果。症状是:
In code代码里叫什么
| Framework框架 | Symbol符号 | Note说明 |
|---|---|---|
| CSS | backdrop-filter: blur() saturate() brightness() | the blur and light layer; keep blur small (about 2px) so the backdrop stays recognizable模糊提亮层;模糊保持很小(约 2px),背景仍认得出来 |
| SVG | <feDisplacementMap> + <feImage> | edge refraction: a displacement map that is neutral in the middle and pushes sampling outward near the rim边缘折射:中间不偏移、靠近边缘时把取样点往外推的位移贴图 |
| CSS | backdrop-filter: url(#lens) | applies the SVG lens to the live backdrop; Chromium only, so keep blur-only as the fallback把 SVG 透镜作用到实时背景上;只有 Chromium 支持,其它浏览器退回只模糊 |
| CSS | box-shadow: inset … | rim light: one highlight top-left, one bottom-right, plus a softer inner line边缘光:左上一道、右下一道,再往里收一道更柔的 |
| CSS | mix-blend-mode: multiply / plus-lighter | ink: dark text multiplies into light glass; light text adds onto dark glass文字着色:深色字在浅玻璃上正片叠底,浅色字在深玻璃上叠加提亮 |
| SwiftUI | .glassEffect() | the native material on Apple platforms; use it instead of rebuilding the recipe there苹果平台上的原生材质,在那里直接用它,不要自己重做 |