vireglass 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/{chunk-BZC2WHCK.js → chunk-2XJJO7SC.js} +4 -4
- package/dist/{chunk-BZC2WHCK.js.map → chunk-2XJJO7SC.js.map} +1 -1
- package/dist/{chunk-3PGYF2NK.js → chunk-CTTZNZFV.js} +3 -3
- package/dist/{chunk-3PGYF2NK.js.map → chunk-CTTZNZFV.js.map} +1 -1
- package/dist/{chunk-FL5UZPY5.js → chunk-H5QTBF67.js} +4 -4
- package/dist/{chunk-FL5UZPY5.js.map → chunk-H5QTBF67.js.map} +1 -1
- package/dist/{chunk-TTOKBARR.js → chunk-MMPK6DCK.js} +10 -3
- package/dist/chunk-MMPK6DCK.js.map +1 -0
- package/dist/{chunk-P2ZOODXD.js → chunk-SLRPHDV7.js} +3 -3
- package/dist/{chunk-P2ZOODXD.js.map → chunk-SLRPHDV7.js.map} +1 -1
- package/dist/dom.cjs +48 -20
- package/dist/dom.cjs.map +1 -1
- package/dist/dom.d.cts +15 -3
- package/dist/dom.d.ts +15 -3
- package/dist/dom.js +44 -23
- package/dist/dom.js.map +1 -1
- package/dist/index.cjs +1 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -5
- package/dist/law.cjs +8 -1
- package/dist/law.cjs.map +1 -1
- package/dist/law.d.cts +7 -0
- package/dist/law.d.ts +7 -0
- package/dist/law.js +1 -1
- package/dist/reference.js +2 -2
- package/dist/web/index.cjs +1 -2
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.js +4 -4
- package/docs/law.md +2 -2
- package/package.json +11 -9
- package/src/dom/body.ts +24 -9
- package/src/dom/index.ts +43 -10
- package/src/dom/probe.ts +27 -3
- package/src/law.ts +7 -0
- package/dist/chunk-TTOKBARR.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/optics.ts","../src/material.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,OAAO,KAAA,IAAS,CAAA;AAC7D,EAAA,MAAM,SAAS,MAAA,CAAO,MAAA,GAAA,CAAU,MAAA,CAAO,MAAA,GAAS,OAAO,MAAA,IAAU,CAAA;AACjE,EAAA,MAAM,eAAe,MAAA,CAAO,YAAA,GAAA,CAAgB,MAAA,CAAO,YAAA,GAAe,OAAO,YAAA,IAAgB,CAAA;AACzF,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,GAAA,CAAI,SAAA,CAAU,MAAM,CAAA,EAAG,IAAA,CAAK,GAAA,CAAI,KAAA,EAAO,MAAM,CAAA,GAAI,CAAC,CAAA;AACpE,EAAA,OAAO;AAAA,IACL,SAAS,OAAA,GAAU,CAAA;AAAA,IACnB,SAAS,OAAA,GAAU,CAAA;AAAA,IACnB,KAAA;AAAA,IACA,MAAA;AAAA,IACA,YAAA;AAAA;AAAA;AAAA,IAGA,SAAA,EAAW,OAAA,CAAQ,IAAA,EAAM,MAAA,CAAO,KAAA,EAAO,MAAA,CAAO,MAAA,EAAQ,KAAA,EAAO,MAAA,EAAQ,OAAA,GAAU,CAAA,EAAG,OAAA,GAAU,CAAC;AAAA,GAC/F;AACF","file":"chunk-FL5UZPY5.js","sourcesContent":["// Deriving optics from the medium's properties. The material describes CAUSES (index of\n// refraction, thickness, bevel, roughness); the shaders need EFFECTS — this file translates one\n// into the other. Pure functions: the physics is checked by tests, not on a device.\n//\n// The normalisations themselves are in `law.ts` under DERIVE, with the rest of the calibration.\n// They are honestly labelled there: the rendering is stylised, and literal physical values (glass\n// reflects 4% at normal incidence) produce effects right at the threshold of visibility. Each is\n// monotonic in its own cause, so \"denser medium → more visible rim\" always holds, and no\n// impossible combination can arise.\nimport { DERIVE } from './law';\n\nconst clamp = (v: number, lo: number, hi: number) => (v < lo ? lo : v > hi ? hi : v);\nconst clamp01 = (v: number) => clamp(v, 0, 1);\n\n/** Reflectance at normal incidence: ((n−1)/(n+1))². For glass, n=1.5 gives 0.04. */\nexport const fresnelF0 = (ior: number) => ((ior - 1) / (ior + 1)) ** 2;\n\nexport const fresnelStrength = (ior: number) => clamp01(fresnelF0(ior) * DERIVE.fresnelGain);\n\n/** Exponent in the Schlick approximation — a constant of the model, not a knob. */\nexport const FRESNEL_EXPONENT = DERIVE.fresnelExponent;\n\n/** Strength of ray bending. As n→1 the medium is indistinguishable from air; n=1.6 is taken as\n * full strength. */\nexport const refractionStrength = (ior: number) => clamp01((ior - 1) / DERIVE.iorFullBend);\n\nexport const refractionScale = (ior: number, thicknessDp: number) =>\n 1 + DERIVE.magnifyPerDp * thicknessDp * (1 - 1 / Math.max(ior, 1));\n\nexport const dispersion = (ior: number) => clamp01((ior - 1) * DERIVE.dispersionPerIor);\n\nexport const iorSpread = (ior: number) => dispersion(ior) * DERIVE.iorSpreadPerDispersion;\n\nexport const absorption = (pathDp: number) =>\n 1 - Math.exp(-DERIVE.absorbPerDp * Math.max(pathDp, 0));\n\n/**\n * Density at the bevel relative to the body. Not a separate quantity: at the rim the ray travels\n * LONGER through the medium by the bevel's width, and absorption over that path is greater. This\n * used to be a separate `edgeDensity` slider, which is how a thin bevel with a milky rim got\n * built — a state that doesn't occur in real glass.\n */\nexport const edgeDensity = (thicknessDp: number, bevelDp: number) => {\n const body = absorption(thicknessDp);\n if (body <= 0) return 1;\n return clamp(absorption(thicknessDp + bevelDp) / body, 1, DERIVE.edgeDensityMax);\n};\n\n/**\n * Backdrop haziness — surface roughness, not a separate blur setting.\n *\n * The ceiling is deliberately low. Blur in this model is a SUPPORTING device: it helps ink sit\n * over glass, but doesn't improve the picture on its own. Past roughly a dozen dp, letters under\n * the glass stop being letters and turn into a mush of pixels — no amount of legibility justifies\n * that. Separating content from the ink is body density's job, not blur's.\n */\nexport const blur = (roughness: number) => clamp01(roughness) * DERIVE.blurMaxDp;\n\n/** A smooth surface gives a narrow highlight, a rough one a spread-out one. */\nexport const specularPower = (roughness: number) =>\n DERIVE.specularPowerSmooth -\n clamp01(roughness) * (DERIVE.specularPowerSmooth - DERIVE.specularPowerRough);\n\n/** Highlight brightness — the same reflectance as Fresnel, damped by roughness. */\nexport const specularStrength = (ior: number, roughness: number) =>\n clamp01(fresnelStrength(ior) * (1 - clamp01(roughness) * DERIVE.specularRoughDamping));\n\n/**\n * Color of the medium. Never set by hand: in transparent media, hue is tied to density. Water\n * absorbs red and skews cool, ordinary glass is nearly neutral with a faint green, dense\n * high-index media skew warm. Lightness follows reflectance: the denser the medium, the more of\n * its surroundings it returns, and the lighter its body reads.\n */\ntype Hue = readonly [number, number, number];\nconst mixHue = (a: Hue, b: Hue, t: number): Hue => [\n a[0] + (b[0] - a[0]) * t,\n a[1] + (b[1] - a[1]) * t,\n a[2] + (b[2] - a[2]) * t,\n];\n\nexport function mediumTint(ior: number): { r: number; g: number; b: number } {\n const t = clamp01((ior - DERIVE.hueFromIor) / DERIVE.hueSpan);\n const hue =\n t < 0.5\n ? mixHue(DERIVE.hueCool, DERIVE.hueNeutral, t * 2)\n : mixHue(DERIVE.hueNeutral, DERIVE.hueWarm, (t - 0.5) * 2);\n const lift = DERIVE.bodyLiftBase + fresnelF0(ior) * DERIVE.bodyLiftPerF0;\n return { r: clamp01(hue[0] * lift), g: clamp01(hue[1] * lift), b: clamp01(hue[2] * lift) };\n}\n\n/**\n * How far the rim gathers light AROUND the element.\n *\n * On real glass, at a grazing angle the eye receives not what's under the glass but the\n * surroundings: an object on a black table next to a lamp catches the lamp. So the radius is\n * noticeably larger than the bevel — it's the element's vicinity, not its rim. Without this,\n * glass on an empty black background has no source at all and honestly disappears.\n */\n/**\n * Ceiling on the radius. Without it, a wide bevel would gather its surroundings from fifty-odd dp\n * away, and a READABLE copy of whatever sits nearby would appear inside the glass: eight samples\n * aren't enough to blur a disc that large (E-33, E-37). Real rims also gather light mostly from\n * nearby — an unbounded radius was a modeling mistake.\n */\nexport const gatherRadius = (bevelDp: number) =>\n clamp(Math.max(bevelDp, 1) * DERIVE.gatherPerBevel, DERIVE.gatherMinDp, DERIVE.gatherMaxDp);\n\n/**\n * The body's own density from absorption through its thickness. Small: glass has no color of its\n * own, the body only moves toward the tint under the legibility requirement (HIG \"Color\"),\n * otherwise it dims the content.\n */\nexport const bodyDensity = (thicknessDp: number) =>\n DERIVE.bodyDensity * absorption(thicknessDp);\n\n/**\n * Highlight normalization. `fresnelStrength`'s ×17.5 factor is tuned for the rim highlight's\n * visibility and saturates at one for dense media; applying it to the highlight too would raise\n * body lightness harder than the glass had just separated it from the ink — eating its own\n * legibility work. This uses the physical scale instead.\n */\n/** How much the rim picks up the light and color of its surroundings. The same reflectance as\n * Fresnel: no separate knob — a dense medium returns more of its surroundings by construction. */\n\nexport const edgeLight = (ior: number) => clamp01(fresnelF0(ior) * DERIVE.edgeLightGain);\n\n/**\n * THE SPECTRAL PART. Three phenomena — dispersion, diffraction and interference — share one\n * cause: index of refraction and phase both depend on wavelength. So there are no separate\n * \"rainbow strength\" knobs here: everything is derived from the medium's density and film\n * thickness.\n */\n\n/**\n * Rim iridescence is visible exactly as much as the REFLECTION is bright: interference lives in\n * the reflected ray, not the transmitted one. Hence the tie to Fresnel — there's no strength knob\n * of its own.\n */\nexport const iridescence = (ior: number, filmNm: number) =>\n filmNm <= 0 ? 0 : clamp01(fresnelStrength(ior) * DERIVE.iridescencePerFresnel);\n\n/**\n * Edge diffraction. Same λ-dependence as dispersion, so it shares its strength; the bevel sets\n * the fringe frequency — wide bevels give sparse fringes, sharp ones frequent (in the shader this\n * is divided by bevel width). The 0.5 normalization reflects the stylized render: at the physical\n * amplitude the fringes aren't visible at all.\n */\nexport const diffraction = (ior: number) =>\n clamp01(dispersion(ior) * DERIVE.diffractionPerDispersion);\n\n/**\n * How much the body picks up the COLOR of its surroundings. This is multiple internal reflection:\n * the denser the medium, the more light it circulates inside itself, and the more strongly it's\n * tinted by what's around it. The ceiling is deliberately low — the tint has to stay a medium, not\n * become a flat color fill.\n */\nexport const colorPickup = (ior: number) =>\n clamp(fresnelStrength(ior) * DERIVE.colorPickupPerFresnel, 0, DERIVE.colorPickupMax);\n","// VireGlass material model.\n//\n// Two distinct objects, and they must not be confused:\n//\n// VireGlassMaterial — CAUSES. What a piece of glass is described by: index of refraction,\n// thickness, bevel width, roughness, absorption color. This is what gets\n// configured.\n// VireGlassOptics — EFFECTS. Eighteen values the shaders need. Not configured: they're\n// derived (`resolveOptics`, physics in `optics.ts`).\n//\n// Before v4, what was exposed were the effects themselves — eighteen independent sliders. Half of\n// them are physically dependent, so combining them produced states that don't occur in real\n// glass: a thin bevel with a dense white rim, rim optics as a fraction of the element's own size.\n// Every such case was patched by adding yet another slider (`edgeDensity`, a size compensation) —\n// that is, compensating for physics that wasn't there. Here there's one cause, and the effects\n// are derived.\n\nimport {\n absorption,\n blur as blurFrom,\n dispersion as dispersionFrom,\n edgeDensity as edgeDensityFrom,\n gatherRadius as gatherRadiusFrom,\n fresnelStrength,\n FRESNEL_EXPONENT,\n mediumTint,\n refractionScale as refractionScaleFrom,\n refractionStrength,\n specularPower as specularPowerFrom,\n bodyDensity as bodyDensityFrom,\n edgeLight as edgeLightFrom,\n iridescence as iridescenceFrom,\n diffraction as diffractionFrom,\n colorPickup as colorPickupFrom,\n specularStrength,\n iorSpread as iorSpreadFrom,\n} from './optics';\n\nexport type VireGlassTint = { r: number; g: number; b: number };\n\nexport type VireGlassMaterial = {\n /** Index of refraction of the medium. Water 1.33, glass 1.5, sapphire 1.77. */\n ior: number;\n /** Glass thickness, dp. Drives center magnification and absorption. */\n thickness: number;\n /** Bevel width, dp. Absolute: on real glass the rim doesn't depend on the piece's size. */\n bevel: number;\n /** Surface roughness: backdrop haziness and highlight blur. */\n roughness: number;\n /** Response to device orientation, 0 means the light is locked to the screen. */\n environment: number;\n /** Not physics but a legibility requirement: how strongly the glass has to separate its own\n * lightness from the ink drawn over it. 0 means the glass is simply transparent. */\n legibility: number;\n /** Dimming layer UNDER the glass, 0..1. For the transparent (Clear) variant this is what\n * provides legibility: that glass has no adaptation, and without dimming the ink drowns over\n * bright content.\n *\n * Not to be confused with the mobile surface's `dim` prop: that one compensates for a platform\n * capture quirk (BlurView can't see a scrim drawn over the content), while this is a property\n * of the material itself. */\n dimming: number;\n /** Lightness of what the app draws OVER the glass: 1 is light icons and text, 0 is dark. A\n * cause, not a knob: the calling screen knows it. */\n ink: number;\n /** Minimum PRESENCE of the element itself: how far its body must stand off in lightness from\n * the backdrop behind it. Not the same as `legibility` — that's about the ink OVER the glass,\n * this is about the element itself. Over a uniform backdrop the glass has nothing to refract,\n * and the element disappears; for a control that's unacceptable. 0 means no presence is\n * required.\n *\n * The sign is taken FROM THE BACKDROP, not from ink polarity: over dark the body lightens,\n * over light it darkens. So the requirement works the same way on any backdrop. */\n presence: number;\n /** Surface film thickness, nm. This is where interference comes from: the optical path\n * difference in the film becomes comparable to the wavelength, and the reflection picks up\n * iridescence. 0 means no film. */\n film: number;\n};\n\nexport const MATERIAL_RANGES = {\n ior: [1, 2],\n thickness: [0, 60],\n bevel: [0, 40],\n roughness: [0, 1],\n environment: [0, 1],\n legibility: [0, 1],\n dimming: [0, 0.5],\n ink: [0, 1],\n presence: [0, 0.6],\n film: [0, 900],\n} as const satisfies Record<string, readonly [number, number]>;\n\nexport type VireGlassNumericKey = keyof typeof MATERIAL_RANGES;\n\n/** Radius over which the LOCAL backdrop lightness is taken, dp. Not per-pixel: otherwise the\n * glass chases individual strokes and a halo appears around letters beneath it. */\nexport const ADAPT_RADIUS = 22;\n\n/** Lens dimming on product surfaces — a flat fill over the backdrop. */\nexport const PRODUCT_DIM = 0.2;\n\nconst clamp = (v: number, lo: number, hi: number) => (v < lo ? lo : v > hi ? hi : v);\n\n/** The values the shaders need. Assembled from the material, never set by hand. */\nexport type VireGlassOptics = {\n blur: number;\n refraction: number;\n refractionScale: number;\n /** Bevel width in dp — an absolute property of the medium. */\n bevelDp: number;\n /** Radius over which the rim gathers light around the element. */\n gatherRadiusDp: number;\n fresnel: number;\n fresnelPower: number;\n specular: number;\n specularPower: number;\n dispersion: number;\n tint: VireGlassTint;\n tintStrength: number;\n edgeDensity: number;\n environment: number;\n legibility: number;\n /** Dimming of the content under the glass — the very layer of the Clear variant. */\n dimming: number;\n ink: number;\n /** Minimum presence of the element against the backdrop — in units of lightness. */\n presence: number;\n adaptRadius: number;\n bodyDensity: number;\n edgeLight: number;\n /** Film thickness, nm — passed straight to the shader: the path difference is computed in the\n * same units. */\n film: number;\n /** Strength of reflection iridescence. */\n iridescence: number;\n /** Strength of the edge diffraction fringes. */\n diffraction: number;\n /** How much the body is tinted by the color of its surroundings. */\n colorPickup: number;\n /** Index of refraction: the shader computes ray bending from it via Snell's law. */\n ior: number;\n /** Plate thickness, dp — before the correction for element size. */\n thicknessDp: number;\n /** Spread of the index between the red and blue channels — dispersion. */\n iorSpread: number;\n};\n\n// The product default — \"water\": lower index of refraction, thinner medium and bevel, an almost\n// smooth surface. Chosen on-device at the bench.\nexport const VIREGLASS_MATERIAL_V4: VireGlassMaterial = {\n ior: 1.33,\n thickness: 14,\n bevel: 5,\n roughness: 0.05,\n environment: 0.27,\n legibility: 0.26,\n dimming: 0,\n ink: 1,\n presence: 0.05,\n film: 340,\n};\n\n\n/**\n * Glass, not water. v4's index of refraction, 1.33, is water: almost no reflection at the rim,\n * almost no dispersion, 2% magnification. On screen that surface honestly reads as \"nothing much\",\n * and it was being mistaken for glass that wasn't rendering at all.\n *\n * 1.5 is ordinary glass. The effects follow from it on their own: reflection at the rim twice as\n * strong, dispersion one and a half times, ambient color pickup at its ceiling. Thickness is\n * raised a little too: it drives magnification, but absorption comes along with it, and\n * absorption is blackness.\n */\nexport const VIREGLASS_MATERIAL_V5: VireGlassMaterial = {\n ior: 1.5,\n thickness: 28,\n bevel: 6,\n roughness: 0.06,\n environment: 0.27,\n legibility: 0.26,\n dimming: 0,\n ink: 1,\n presence: 0.05,\n film: 340,\n};\n\n/**\n * Frosted sheet glass. The sheet sits over a LIVE screen, and it can't be transparent: transport\n * buttons and progress used to read right through it — the layout looked broken. Dimming doesn't\n * fix this (a flat scrim over a sharp picture doesn't hide it), so roughness is raised instead: it\n * drives `u_frost`, a floor on backdrop blur that the adaptive-blur ceiling doesn't reach.\n */\nexport const VIREGLASS_SHEET_MATERIAL: VireGlassMaterial = {\n ...VIREGLASS_MATERIAL_V5,\n roughness: 0.85,\n};\n/** The product's material. Consumers use this, not a specific version by name. */\n/**\n * Glass under large text (the lyrics panel in the player).\n *\n * The product material with NO change to optics — only `legibility` is raised. That's exactly its\n * reason to exist: \"text on me must stay readable.\" It adds density locally — denser over light\n * and busy backdrops, more transparent over an even dark one.\n *\n * A dedicated thick material (thickness 52, ior 1.58) used to sit here and was removed: medium\n * absorption grows with thickness, and the panel picked up a black fringe around its perimeter —\n * a sooty plate instead of glass. Don't turn thickness into a legibility knob; that's what\n * `legibility` is for.\n */\nexport const VIREGLASS_LYRICS_MATERIAL: VireGlassMaterial = {\n ...VIREGLASS_MATERIAL_V5,\n legibility: 0.95,\n};\n\n/**\n * Glass for controls — buttons, tiles, anything that gets pressed.\n *\n * THICK AND CLEAR, not the baseline: wider bevel, thickness up by half, higher index of\n * refraction and almost no roughness. Baseline glass is a lens over a calm backdrop; a control has\n * to read as an object you can pick up, and that's not done by a fill but by volume: a wide bevel\n * gives the rim something to catch, and thickness gives it depth.\n *\n * Thickness is set by BUILDUP AT THE RIM: on the reference control the stripe image under the\n * element bulges there by a factor of 1.85; ours came out at 1.36 at 30. Saturation sets in around\n * 44, and any extra thickness past that only adds absorption — hence 44, not more.\n *\n * It also drags `tintStrength` (= `absorption(thickness)`) along with it, and on the path WITHOUT\n * a native lens that sets body density: there the element is denser by 2.4 percentage points. On\n * the web the surface has no body at all; the effect only shows on Android below 13.\n *\n * `presence` is raised for the same reason: a piece of background is allowed to disappear over a\n * uniform canvas, a control isn't — it has to be visible before it's been tapped.\n *\n * IMPORTANT about size. The bevel is specified by the medium in dp and doesn't depend on the\n * element's size, but the geometry clamps it to half the smaller half-size (`MAX_BEVEL_FRACTION`).\n * On a 52 dp button that's 13 instead of 16 — a small element made of this glass ends up being\n * bevel all the way through. That's by design: a small piece of thick glass is supposed to look\n * like a lens, not a slab.\n */\nexport const VIREGLASS_CONTROL_MATERIAL: VireGlassMaterial = {\n ...VIREGLASS_MATERIAL_V5,\n ior: 1.69,\n thickness: 44,\n bevel: 8,\n roughness: 0.035,\n presence: 0.176,\n};\n\nexport const VIREGLASS_MATERIAL = VIREGLASS_MATERIAL_V5;\n\n/**\n * An element that CARRIES app ink (an icon, a line of text, cover art) has to keep it legible —\n * that's the reason `legibility` exists. An element with no ink has nothing to separate lightness\n * from, so the requirement is turned off for it: the model just promises it plain transparent\n * glass.\n *\n * The rule lives here, not with the consumer: otherwise the same icon button would get different\n * legibility on the web and on Android.\n */\nexport function materialForInk(material: VireGlassMaterial, carriesInk: boolean): VireGlassMaterial {\n // For the transparent variant, legibility is held by the dimming layer, not the body. Raising\n // its requirement would just turn it into ordinary glass, and the variants don't mix (219 §Clear).\n if (material.dimming > 0) return material;\n return { ...material, legibility: carriesInk ? VIREGLASS_LYRICS_MATERIAL.legibility : 0 };\n}\n\n/**\n * The transparent material variant (Clear). It has no adaptation — the glass stays consistently\n * more transparent, content beneath it shows through almost as-is, and legibility of the ink is\n * held by the dimming layer instead. Fit only where the reference's three conditions hold: the\n * element sits over media, the content can tolerate dimming, and the ink over it is large and\n * bright.\n */\nexport const VIREGLASS_CLEAR_MATERIAL: VireGlassMaterial = {\n ...VIREGLASS_MATERIAL,\n legibility: 0,\n presence: 0,\n // Apple's own numbers: 0.35 in the HIG Materials text, 0.3 in its own sample code. We take the\n // lower one — it comes from working code, not from prose, and Clear has to stay a window.\n dimming: 0.3,\n};\n\n/**\n * ACTIVE STATE as a state of the MEDIUM, not a highlight drawn over it.\n *\n * An active element is denser, clearer glass: higher index of refraction, thicker body, wider\n * bevel, less roughness. A bright rim, a strong highlight and greater presence all follow from\n * these causes on their own — assembling them separately would produce a state that doesn't occur\n * in real glass.\n *\n * `environment` is deliberately left untouched here. It sets how much the body is tinted by\n * what's beneath it, and at full strength an active button over cover art turned into a colored\n * blob: the state read as \"smudged\" rather than \"selected.\" A state indicator must not depend on\n * the backdrop — otherwise any image sliding underneath the element would fake it.\n */\nexport function activeMaterial(material: VireGlassMaterial, on: number): VireGlassMaterial {\n const k = Math.min(Math.max(on, 0), 1);\n return {\n ...material,\n ior: material.ior + 0.35 * k,\n thickness: material.thickness * (1 + 0.9 * k),\n bevel: material.bevel * (1 + 1.8 * k),\n roughness: material.roughness * (1 - 0.75 * k),\n presence: material.presence + 0.12 * k,\n };\n}\n\nexport function resolveMaterial(patch: Partial<VireGlassMaterial> = {}): VireGlassMaterial {\n const m = { ...VIREGLASS_MATERIAL, ...patch };\n const out = { ...m };\n for (const key of Object.keys(MATERIAL_RANGES) as VireGlassNumericKey[]) {\n const [lo, hi] = MATERIAL_RANGES[key];\n out[key] = clamp(out[key], lo, hi);\n }\n return out;\n}\n\n/** Causes → effects. All of the transition's physics lives in `optics.ts`. */\nexport function resolveOptics(patch: Partial<VireGlassMaterial> = {}): VireGlassOptics {\n const m = resolveMaterial(patch);\n return {\n blur: blurFrom(m.roughness),\n refraction: refractionStrength(m.ior),\n refractionScale: refractionScaleFrom(m.ior, m.thickness),\n bevelDp: m.bevel,\n gatherRadiusDp: gatherRadiusFrom(m.bevel),\n fresnel: fresnelStrength(m.ior),\n fresnelPower: FRESNEL_EXPONENT,\n specular: specularStrength(m.ior, m.roughness),\n specularPower: specularPowerFrom(m.roughness),\n dispersion: dispersionFrom(m.ior),\n tint: mediumTint(m.ior),\n tintStrength: absorption(m.thickness),\n edgeDensity: edgeDensityFrom(m.thickness, m.bevel),\n environment: m.environment,\n legibility: m.legibility,\n dimming: m.dimming,\n ink: m.ink,\n presence: m.presence,\n adaptRadius: ADAPT_RADIUS,\n bodyDensity: bodyDensityFrom(m.thickness),\n edgeLight: edgeLightFrom(m.ior),\n film: m.film,\n iridescence: iridescenceFrom(m.ior, m.film),\n diffraction: diffractionFrom(m.ior),\n colorPickup: colorPickupFrom(m.ior),\n ior: m.ior,\n thicknessDp: m.thickness,\n iorSpread: iorSpreadFrom(m.ior),\n };\n}\n\n/**\n * Frozen snapshots of the EFFECTS from the previous model. Kept as reference points until v4\n * settles: they can't be converted to causes — some of the values are internally inconsistent\n * (exactly why the move was made in the first place), and any \"equivalent\" material would be a\n * lie.\n */\nexport const LEGACY_OPTICS = {\n 'v3-manual': {\n blur: 4.32,\n refraction: 0.49,\n refractionScale: 1.05,\n bevelDp: 12.6,\n gatherRadiusDp: 40,\n fresnel: 0.77,\n fresnelPower: 2.86,\n specular: 0.3,\n specularPower: 74.58,\n dispersion: 0.54,\n tint: { r: 0.4, g: 0.4, b: 0.44 },\n tintStrength: 0.35,\n edgeDensity: 1.5,\n environment: 0.27,\n legibility: 0.55,\n dimming: 0,\n ink: 1,\n presence: 0,\n adaptRadius: ADAPT_RADIUS,\n bodyDensity: 0.14,\n edgeLight: 0.35,\n film: 0,\n iridescence: 0,\n diffraction: 0,\n colorPickup: 0,\n ior: 1.5,\n thicknessDp: 16,\n iorSpread: 0,\n },\n 'v2': {\n blur: 5,\n refraction: 0.95,\n refractionScale: 1.34,\n bevelDp: 14,\n gatherRadiusDp: 40,\n fresnel: 0.72,\n fresnelPower: 2.4,\n specular: 0.38,\n specularPower: 46,\n dispersion: 0.3,\n tint: { r: 0.4, g: 0.4, b: 0.44 },\n tintStrength: 0.1,\n edgeDensity: 3.63,\n environment: 0,\n legibility: 0,\n dimming: 0,\n ink: 1,\n presence: 0,\n adaptRadius: ADAPT_RADIUS,\n bodyDensity: 0.14,\n edgeLight: 0.35,\n film: 0,\n iridescence: 0,\n diffraction: 0,\n colorPickup: 0,\n ior: 1.5,\n thicknessDp: 16,\n iorSpread: 0,\n },\n 'v1': {\n blur: 12,\n refraction: 0.55,\n refractionScale: 1.14,\n bevelDp: 10,\n gatherRadiusDp: 40,\n fresnel: 0.5,\n fresnelPower: 3.2,\n specular: 0.42,\n specularPower: 58,\n dispersion: 0.22,\n tint: { r: 0.4, g: 0.4, b: 0.44 },\n tintStrength: 0.16,\n edgeDensity: 3.63,\n environment: 0,\n legibility: 0,\n dimming: 0,\n ink: 1,\n presence: 0,\n adaptRadius: ADAPT_RADIUS,\n bodyDensity: 0.14,\n edgeLight: 0.35,\n film: 0,\n iridescence: 0,\n diffraction: 0,\n colorPickup: 0,\n ior: 1.5,\n thicknessDp: 16,\n iorSpread: 0,\n },\n} as const satisfies Record<string, VireGlassOptics>;\n\nexport type LegacyOpticsName = keyof typeof LEGACY_OPTICS;\nexport const LEGACY_NAMES = Object.keys(LEGACY_OPTICS) as LegacyOpticsName[];\n\n/** Material presets: points in the space of CAUSES, not a set of ready-made effects. */\nexport const MATERIAL_PRESETS = {\n water: VIREGLASS_MATERIAL_V4,\n glass: { ...VIREGLASS_MATERIAL_V4, ior: 1.45, thickness: 25, bevel: 12.6, roughness: 0.17 },\n crystal: { ...VIREGLASS_MATERIAL_V4, ior: 1.7, thickness: 30, bevel: 16, roughness: 0.02 },\n frosted: { ...VIREGLASS_MATERIAL_V4, roughness: 0.55 },\n thick: { ...VIREGLASS_MATERIAL_V4, thickness: 48, bevel: 22 },\n thin: { ...VIREGLASS_MATERIAL_V4, thickness: 4, bevel: 3 },\n iridescent: { ...VIREGLASS_MATERIAL_V4, ior: 1.5, thickness: 8, bevel: 6, film: 620 },\n} as const satisfies Record<string, VireGlassMaterial>;\n\nexport type MaterialPresetName = keyof typeof MATERIAL_PRESETS;\nexport const PRESET_NAMES = Object.keys(MATERIAL_PRESETS) as MaterialPresetName[];\n\nexport const EFFECTS = [\n 'backdrop',\n 'blur',\n 'refraction',\n 'fresnel',\n 'bevel',\n 'specular',\n 'dispersion',\n 'tint',\n 'environment',\n 'legibility',\n 'interference',\n 'diffraction',\n] as const;\n\nexport type VireGlassEffect = (typeof EFFECTS)[number];\nexport type VireGlassToggles = Record<VireGlassEffect, boolean>;\n\nexport const ALL_EFFECTS_ON: VireGlassToggles = EFFECTS.reduce(\n (acc, e) => ({ ...acc, [e]: true }),\n {} as VireGlassToggles,\n);\n\n/**\n * A toggle zeroes out an EFFECT, it isn't a branch in the shader: the ON/OFF comparison runs on\n * one shader variant, otherwise two different programs would be getting compared. It operates on\n * optics, not on the material: a cause can't be zeroed out — it drags half a dozen effects along\n * with it. `backdrop` isn't handled by a toggle here: it decides whether to mount the BlurView at\n * all.\n */\nexport function applyToggles(\n optics: VireGlassOptics,\n toggles: Partial<VireGlassToggles> = {},\n): VireGlassOptics {\n const on = { ...ALL_EFFECTS_ON, ...toggles };\n const o = { ...optics, tint: { ...optics.tint } };\n if (!on.blur) o.blur = 0;\n if (!on.refraction) {\n o.refraction = 0;\n o.refractionScale = 1;\n o.ior = 1;\n }\n if (!on.fresnel) o.fresnel = 0;\n if (!on.bevel) o.bevelDp = 1;\n if (!on.specular) o.specular = 0;\n if (!on.dispersion) {\n o.dispersion = 0;\n o.iorSpread = 0;\n }\n if (!on.tint) o.tintStrength = 0;\n if (!on.environment) o.environment = 0;\n if (!on.legibility) {\n o.legibility = 0;\n // The dimming layer is the same answer to the legibility requirement, just for the\n // transparent variant.\n o.dimming = 0;\n }\n if (!on.interference) o.iridescence = 0;\n if (!on.diffraction) o.diffraction = 0;\n return o;\n}\n\n/** Order = the `u_debug` value in both shaders. Bench-only. */\nexport const DEBUG_MODES = [\n 'normal',\n 'sdf',\n 'mask',\n 'edge',\n 'fresnel',\n 'refraction',\n 'backdrop',\n 'specular',\n 'dispersion',\n 'normals',\n 'spectral',\n 'adapt',\n 'probe',\n] as const;\n\nexport type VireGlassDebugMode = (typeof DEBUG_MODES)[number];\n\nexport function debugIndex(mode: VireGlassDebugMode): number {\n return DEBUG_MODES.indexOf(mode);\n}\n","// The single description of VireGlass geometry. Both shaders draw it from here: the SKSL surface\n// (`surface-shader.ts`) and the AGSL lens (`lens-shader.ts`, shipped as a string into the native\n// view). AGSL and SKSL are the same language, so the SDF no longer needs duplicating in Kotlin:\n// before, the surface's circle and the lens's rounded rectangle described different pieces of\n// glass, and the bevel constant had to be kept in sync by hand (docs/adr-001-rendering.md §3).\nimport { BEVEL, EPSILON, TOUCH } from './law';\n\n/** 2π. Structural, not a law — but the shader has no built-in for it. */\nconst VG_TAU = 6.28318530718;\n\nexport const VG_SDF = `\nfloat vgRoundRect(float2 p, float2 halfSize, float corner) {\n float2 q = abs(p) - halfSize + corner;\n return min(max(q.x, q.y), 0.0) + length(max(q, float2(0.0))) - corner;\n}\n\nfloat vgSmin(float a, float b, float k) {\n float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);\n return mix(b, a, h) - k * h * (1.0 - h);\n}\n\n// A scene is a single shape, and when k > 0 a smooth union with one or two neighbors. A third\n// shape exists to break the control into pieces (docs/reference.md §5): there are two bridges\n// there. It's turned off with a zero size, not its own k: the fused body shares one bridge.\nfloat vgScene(float2 p, float2 halfSize, float corner,\n float2 offsetB, float2 halfB, float cornerB, float k,\n float2 offsetC, float2 halfC, float cornerC) {\n float a = vgRoundRect(p, halfSize, corner);\n if (k <= 0.0) { return a; }\n float ab = vgSmin(a, vgRoundRect(p - offsetB, halfB, cornerB), k);\n if (halfC.x <= 0.0) { return ab; }\n return vgSmin(ab, vgRoundRect(p - offsetC, halfC, cornerC), k);\n}\n\n// Response to a finger. It's the FIELD around the touch point that deforms, not the shape's\n// bounding box: scaling width to pull the right edge would also pull the left one — liquid\n// doesn't behave that way. Here the displacement falls off with distance from the finger, so the\n// far edge stays put.\n//\n// The order of the terms matters: drag shifts the field, press pulls it toward the finger, the\n// wave rides on top of the already-shifted field — otherwise the ripple decouples from the\n// deformation and lives a life of its own.\nfloat2 vgTouchWarp(float2 p, float2 touch, float2 pull, float press, float radius,\n float waveAmp, float wavePhase) {\n if (radius <= 0.0) { return p; }\n // Under the finger the whole element grows (M 3:51; HIG: interactive \"expands\").\n p /= 1.0 + ${TOUCH.pressGrow} * press;\n float2 d = p - touch;\n float r = length(d);\n\n // The finger is a BLOB, not a point, but not a hard stamp either: a wide peak, soft edges. A\n // flat plateau with a sharp cutoff at the edge shifts the region as a block, and a straight\n // line under the glass breaks into a step — the deformation reads as rectangular even though\n // the finger is round. A double smoothstep gives the same contact width without that step.\n //\n // The influence cuts off at the radius rather than fading into an infinite tail like a\n // Gaussian: with a tail the deformation spreads into a \"rubber mattress\" bulge.\n float k = clamp((radius - r) / radius, 0.0, 1.0);\n float s = k * k * (3.0 - 2.0 * k);\n float core = s * s * (3.0 - 2.0 * s);\n // A ring around the blob: material displaced from under the finger has to end up somewhere.\n // Without this ridge the shape just balloons, and a dense medium doesn't behave that way.\n float rim = k * k * (1.0 - k) * 4.0;\n\n float2 q = p - pull * (core - ${TOUCH.ridge} * rim);\n q -= d * (press * ${TOUCH.pressPull} * core);\n\n // The wave has its own scale, twice the drag radius: the ripple has to reach the far edge,\n // otherwise it reads as jitter under the finger rather than a wave across the surface. The\n // wavelength is short: in a dense medium ripples are frequent and small, long shallow swells\n // are water.\n if (waveAmp > 0.0 && r > 0.0001) {\n float span = radius * ${TOUCH.waveSpan}.0;\n float ring = sin(r / (span * ${TOUCH.waveLength}) - wavePhase * ${VG_TAU}) * exp(-r / (span * ${TOUCH.waveDecay}));\n q -= (d / r) * ring * waveAmp;\n }\n return q;\n}\n\n// Analytical normal of a single shape: radial on the rounded part, axis-aligned on the straight\n// segments.\nfloat2 vgRoundRectNormal(float2 p, float2 halfSize, float corner) {\n float2 q = abs(p) - halfSize + corner;\n float2 g = (q.x > 0.0 && q.y > 0.0)\n ? normalize(max(q, float2(0.0001)))\n : (q.x > q.y ? float2(1.0, 0.0) : float2(0.0, 1.0));\n return g * sign(p);\n}\n\n// Normal of the union — ANALYTICAL, no more finite differences here.\n//\n// Derivation: smin has two terms, mix(b,a,h) and −k·h·(1−h). Their derivatives with respect to h\n// contain a factor of (1−2h) with opposite signs and cancel exactly, because h is linear in\n// (b−a)/k. What's left is mix(∇b, ∇a, h) — that is, the two shapes' normals, blended with the\n// same weight that blends the distances themselves.\n//\n// The previous version took four ADDITIONAL scene evaluations per pixel (each one — two shapes\n// plus smin) and was still an approximation. Here there are two shapes, exactly.\nfloat2 vgSceneNormal(float2 p, float2 halfSize, float corner,\n float2 offsetB, float2 halfB, float cornerB, float k,\n float2 offsetC, float2 halfC, float cornerC) {\n float2 na = vgRoundRectNormal(p, halfSize, corner);\n if (k <= 0.0) { return na; }\n float2 q = p - offsetB;\n float a = vgRoundRect(p, halfSize, corner);\n float b = vgRoundRect(q, halfB, cornerB);\n float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);\n float2 nab = normalize(mix(vgRoundRectNormal(q, halfB, cornerB), na, h) + float2(${EPSILON}, ${EPSILON}));\n if (halfC.x <= 0.0) { return nab; }\n // Same derivation as for the pair: normals blend with the same weight as the distances.\n float2 qc = p - offsetC;\n float ab = vgSmin(a, b, k);\n float c = vgRoundRect(qc, halfC, cornerC);\n float hc = clamp(0.5 + 0.5 * (c - ab) / k, 0.0, 1.0);\n return normalize(mix(vgRoundRectNormal(qc, halfC, cornerC), nab, hc) + float2(${EPSILON}, ${EPSILON}));\n}\n\n// Position within the bevel: 0 is the flat middle, 1 is the very edge. This one value feeds the\n// mask, thickness, refraction, aberrations and the width of the light rim.\nfloat vgBevelT(float sd, float bevel) {\n return clamp((sd + bevel) / bevel, 0.0, 1.0);\n}\n\n// Slope of the bevel profile — spherical: t / sqrt(1 - t²), like a spherical cap. The previous t²\n// kept the slope near zero through almost the whole bevel and then shot up right at the edge, so\n// all the optics bunched into a narrow ring and the element read as a PUCK — a flat top and a\n// wall around the rim. Here curvature is spread across the bevel, and the rim stops being a line.\n//\n// This still doesn't control the field of view: only the bevel bends, the middle stays flat,\n// otherwise the surface reads as a soap bubble.\nfloat vgBevelSlope(float t) {\n return min(t * inversesqrt(max(1.0 - t * t * ${BEVEL.sphere}, ${BEVEL.floor})), ${BEVEL.slopeMax});\n}\n\n// PROGRESS FRACTION. Progress is an active state turned into a FIELD: to the left of the boundary\n// the element is active, to the right it stays regular glass, and the boundary moves. A negative\n// value turns the field off entirely — zero is taken by the start of the track and can't also\n// mean off.\n//\n// The boundary is SOFT. A hard seam reads as two different materials glued together rather than\n// two states of one; the transition width is a fraction of the half-width, so it doesn't read as\n// a thread on a large element and doesn't swallow a small one whole.\nfloat vgProgress(float2 p, float2 halfSize, float progress) {\n if (progress < 0.0) { return 0.0; }\n float edge = mix(-halfSize.x, halfSize.x, clamp(progress, 0.0, 1.0));\n float soft = max(halfSize.x * 0.05, 1.0);\n return 1.0 - smoothstep(edge - soft, edge + soft, p.x);\n}\n`;\n\n/** Rate at which the offset builds toward the rim. Shared between the lens (actual sampling\n * offset) and the surface (visualizing the displacement field in debug mode) — otherwise they'd\n * drift apart. */\nexport const VG_FALLOFF = 2.6;\n\n// JS twin of `vgRoundRect`/`vgRoundRectNormal` above, for targets with no GPU to run the shader on\n// (the DOM displacement map). Term-for-term against the GLSL text: a second geometry that behaves\n// differently is exactly the class of bug `check:optics` exists to catch on the shader side, and\n// there is no such gate for this one.\n\n/** Signed distance from `(x, y)` to a rounded rect of size `w`×`h` centered on the origin. */\nexport function sdfRoundedRect(x: number, y: number, w: number, h: number, r: number): number {\n const qx = Math.abs(x) - w / 2 + r;\n const qy = Math.abs(y) - h / 2 + r;\n return Math.min(Math.max(qx, qy), 0) + Math.hypot(Math.max(qx, 0), Math.max(qy, 0)) - r;\n}\n\n/**\n * Closed-form gradient of `sdfRoundedRect`, unit length everywhere except the exact center (where\n * it's genuinely undefined — the medial axis of the shape). NOT finite differences: differencing\n * quantizes the gradient to the sampling step, and the displacement map needs sub-pixel accuracy\n * right at the rim.\n */\nexport function sdfRoundedRectGradient(x: number, y: number, w: number, h: number, r: number): [number, number] {\n const qx = Math.abs(x) - w / 2 + r;\n const qy = Math.abs(y) - h / 2 + r;\n let gx: number;\n let gy: number;\n if (qx > 0 && qy > 0) {\n const cx = Math.max(qx, 0.0001);\n const cy = Math.max(qy, 0.0001);\n const len = Math.hypot(cx, cy);\n gx = cx / len;\n gy = cy / len;\n } else if (qx > qy) {\n gx = 1;\n gy = 0;\n } else {\n gx = 0;\n gy = 1;\n }\n return [gx * Math.sign(x), gy * Math.sign(y)];\n}\n\n// ---------------------------------------------------------------------------\n// JS twins of the shader functions above. The DOM renderer needs this geometry\n// as numbers, not as a string it hands to a compiler. Each mirrors its `vg*`\n// counterpart term for term — a second geometry that drifts is the failure the\n// platform-parity gate exists to catch.\n// ---------------------------------------------------------------------------\n\n/** Mirrors `vgSmin`. */\nexport function smin(a: number, b: number, k: number): number {\n const h = Math.min(Math.max(0.5 + (0.5 * (b - a)) / k, 0), 1);\n return b + (a - b) * h - k * h * (1 - h);\n}\n\n/**\n * The smallest `k` at which `smin` joins two surfaces `gap` apart into one body. Exact for this\n * smin rather than fitted: at the midpoint the two distances are both gap/2, so h = 0.5 and the\n * result is gap/2 − k/4, which reaches zero at k = 2·gap.\n *\n * It is the number `morphBetween` was missing. A neck sized only as a fraction of the element's\n * own half-size has nothing to do with the distance it has to span, so two controls a hundred\n * pixels apart stayed two controls at every t — including t = 1, where the contract says they are\n * one shared medium.\n */\nexport function neckToBridge(gap: number): number {\n return gap > 0 ? gap * 2 : 0;\n}\n\nexport type MorphShape = {\n offsetX: number;\n offsetY: number;\n width: number;\n height: number;\n cornerRadius: number;\n};\n\n/**\n * Mirrors the scene distance: one shape, smoothly unioned with any number of neighbours when\n * `smoothing` is positive. §5's merging and splitting are this union opening and closing.\n *\n * A fold, not a pair. The count used to be in the ARGUMENT NAMES — `b` and `c`, and a fourth\n * shape would have been `d` — which is not a limit the material has. Several independent elements\n * flowing into one whole is the behaviour; how many of them there happen to be is the host's.\n */\nexport function sceneDistance(\n x: number,\n y: number,\n w: number,\n h: number,\n r: number,\n smoothing = 0,\n ...shapes: (MorphShape | undefined)[]\n): number {\n let d = sdfRoundedRect(x, y, w, h, r);\n if (smoothing <= 0) return d;\n for (const s of shapes) {\n if (!s || s.width <= 0) continue;\n d = smin(d, sdfRoundedRect(x - s.offsetX, y - s.offsetY, s.width, s.height, s.cornerRadius), smoothing);\n }\n return d;\n}\n\n/**\n * Mirrors `vgSceneNormal`: normals blend with the same weight that blends the distances, which the\n * shader derives rather than approximates. The same fold as `sceneDistance`, carrying the running\n * distance alongside the running normal because each step's weight is measured against it.\n */\nexport function sceneGradient(\n x: number,\n y: number,\n w: number,\n h: number,\n r: number,\n smoothing = 0,\n ...shapes: (MorphShape | undefined)[]\n): [number, number] {\n let d = sdfRoundedRect(x, y, w, h, r);\n let [gx, gy] = sdfRoundedRectGradient(x, y, w, h, r);\n let blended = false;\n if (smoothing > 0) {\n for (const s of shapes) {\n if (!s || s.width <= 0) continue;\n const sx = x - s.offsetX;\n const sy = y - s.offsetY;\n const ds = sdfRoundedRect(sx, sy, s.width, s.height, s.cornerRadius);\n const weight = Math.min(Math.max(0.5 + (0.5 * (ds - d)) / smoothing, 0), 1);\n const [nx, ny] = sdfRoundedRectGradient(sx, sy, s.width, s.height, s.cornerRadius);\n gx = nx + (gx - nx) * weight;\n gy = ny + (gy - ny) * weight;\n d = smin(d, ds, smoothing);\n blended = true;\n }\n }\n // With nothing blended in, the base gradient is already a unit vector and is returned untouched —\n // the shader takes the same early exit (`if (k <= 0.0) return na;`), and nudging it here instead\n // would put the two renderers a rounding step apart on every flat edge in the material.\n if (!blended) return [gx, gy];\n // The shader's `+ float2(${EPSILON}, ${EPSILON})` before normalising, and it is not decoration:\n // where two shapes meet head-on their normals cancel exactly and the blend lands on zero.\n gx += EPSILON;\n gy += EPSILON;\n const len = Math.hypot(gx, gy) || 1;\n return [gx / len, gy / len];\n}\n\nexport type TouchWarp = {\n x: number;\n y: number;\n pullX: number;\n pullY: number;\n press: number;\n radius: number;\n waveAmp: number;\n wavePhase: number;\n};\n\n/**\n * Mirrors `vgTouchWarp`. The FIELD around the finger deforms, not the bounding box: scaling the\n * width to pull the right edge would pull the left one too, and liquid does not do that.\n *\n * Term order is load-bearing — drag shifts the field, press pulls it toward the finger, the wave\n * rides on the already-shifted field. Reordered, the ripple decouples and lives its own life.\n */\nexport function touchWarp(x: number, y: number, t: TouchWarp): [number, number] {\n if (t.radius <= 0) return [x, y];\n const grow = 1 + TOUCH.pressGrow * t.press;\n let px = x / grow;\n let py = y / grow;\n const dx = px - t.x;\n const dy = py - t.y;\n const r = Math.hypot(dx, dy);\n\n const k = Math.min(Math.max((t.radius - r) / t.radius, 0), 1);\n const s = k * k * (3 - 2 * k);\n const core = s * s * (3 - 2 * s);\n // The ridge around the blob: material pushed out from under the finger has to go somewhere.\n const rim = k * k * (1 - k) * 4;\n\n px -= t.pullX * (core - TOUCH.ridge * rim);\n py -= t.pullY * (core - TOUCH.ridge * rim);\n px -= dx * (t.press * TOUCH.pressPull * core);\n py -= dy * (t.press * TOUCH.pressPull * core);\n\n if (t.waveAmp > 0 && r > 0.0001) {\n const span = t.radius * TOUCH.waveSpan;\n const ring = Math.sin(r / (span * TOUCH.waveLength) - t.wavePhase * VG_TAU) * Math.exp(-r / (span * TOUCH.waveDecay));\n px -= (dx / r) * ring * t.waveAmp;\n py -= (dy / r) * ring * t.waveAmp;\n }\n return [px, py];\n}\n","import { ACCENT, BODY, DISPERSION, LENS, MEDIUM, RIM, SPECTRAL } from './law';\nimport { VG_SDF } from './sdf';\n\n// The lens source is assembled HERE and ships to the native view as a prop: AGSL and SKSL are one\n// language, so the lens's and the surface's geometry are literally the same string (`VG_SDF`).\n//\n// Glass is a thick plate with a convex rounded edge (docs/reference.md §1). A ray from above\n// refracts at the top face and lands on the content shifted INWARD relative to the shape: the\n// middle isn't shifted, the rim shows what lies beneath the body of the element.\n//\n// Uniforms, apart from the view's own geometry, arrive over a SHARED CHANNEL (`adapters.ts` →\n// `uniformNames`/`uniformSizes`/`uniformValues`). There are no more separate Props per value:\n// those were exactly what let a typo silently turn the lens off (docs/material-lab.md E-01).\nexport const LENS_SHADER = `\nuniform shader content;\n\n// Known only to the view itself: its own size and its own place on screen.\nuniform float2 u_center;\nuniform float u_reach;\nuniform float2 u_contentMin;\nuniform float2 u_contentMax;\n// Backdrop estimate UNDER the glass from the native probe: lightness, variegation and average\n// color, already smoothed over time. Negative lightness means the probe hasn't reported yet —\n// fall back to our own samples.\nuniform float u_probeLuma;\nuniform float u_probeBusy;\n// The endpoints of the lightness range under the glass: right at a black/white border the\n// average reads as a gray that says \"everything's fine,\" while the ink drowns over the light\n// half.\nuniform float2 u_probeRange;\n// Slope of lightness across the surface, fraction per half-size: tinting is a gradient — one\n// density per element wouldn't separate the ink from both halves of the backdrop.\nuniform float2 u_probeSlope;\nuniform float3 u_probe;\n\n// Material — over the shared channel from JS, already in device pixels.\nuniform float2 u_halfSize;\nuniform float u_corner;\nuniform float u_bevel;\nuniform float u_thick;\nuniform float u_rim;\nuniform float u_ior;\nuniform float u_iorSpread;\nuniform float2 u_light;\nuniform float u_appear;\nuniform float4 u_accent;\nuniform float u_frost;\nuniform float u_ink;\nuniform float u_legibility;\nuniform float u_dim;\nuniform float u_presence;\nuniform float u_progress;\nuniform float u_adaptRadius;\nuniform float u_bodyDensity;\nuniform float u_edgeLight;\nuniform float u_fresnel;\nuniform float u_specular;\nuniform float u_reflectReach;\nuniform float u_film;\nuniform float u_iridescence;\nuniform float u_diffraction;\nuniform float u_colorPickup;\nuniform float2 u_morphOffset;\nuniform float2 u_morphHalf;\nuniform float u_morphCorner;\nuniform float u_morphK;\nuniform float2 u_morph2Offset;\nuniform float2 u_morph2Half;\nuniform float u_morph2Corner;\nuniform float u_debug;\nuniform float2 u_touch;\nuniform float2 u_pull;\nuniform float u_touchPress;\nuniform float u_touchRadius;\nuniform float2 u_wave;\n\n${VG_SDF}\n\n// Sample count for the disc gather: fewer than this reads as a staircase of copies at a sharp edge.\nconst int VG_FROST_TAPS = 20;\n// The sample count grows with the disc's area: estimator noise is the spread under the glass\n// divided by the square root of the sample count. The ceiling is cost: texture sampling is the\n// most expensive thing here.\nconst int VG_FROST_TAPS_MAX = 64;\n// The radius correction for backdrop compression at the rim is capped: at the silhouette it goes\n// to infinity.\nconst float VG_FOOTPRINT_MAX = ${LENS.footprintMax};\nconst float VG_TAU = 6.28318530718;\n// Ceiling on body lightness under light ink (and the mirrored floor under dark ink). This is a\n// ceiling, not a difference: \"0.14 darker than white\" is a lightness of 0.86, at which white text\n// is invisible.\nconst float VG_BODY_CAP_LOOSE = ${BODY.capLoose};\nconst float VG_BODY_CAP_TIGHT = ${BODY.capTight};\n// Tint lightness in both directions: real glass is never coal-black or paper-white.\nconst float VG_TINT_DARK = ${BODY.tintDark};\nconst float VG_TINT_LIGHT = ${BODY.tintLight};\n// Reference channel wavelengths, nm — for diffraction and interference.\nconst float3 VG_LAMBDA = float3(${LENS.lambdaR}.0, ${LENS.lambdaG}.0, ${LENS.lambdaB}.0);\n// Film index of refraction: every thin film on glass sits around this value.\nconst float VG_FILM_IOR = ${LENS.filmIor};\n// Ceiling on the profile's slope right at the silhouette: it goes to infinity there.\nconst float VG_SLOPE_MAX = ${LENS.slopeMax}.0;\n// Fraction of the gather radius that scattering reaches over a busy backdrop under ink (M 11:47).\n// Set against the reference: there, structure under the capsule fades by a factor of 9-10, not\n// thirty.\nconst float VG_SCATTER_MAX = ${MEDIUM.scatterMax};\nconst float VG_SCATTER_BASE = ${MEDIUM.scatterBase};\n// The response to structure under the glass saturates early: what competes with the ink isn't\n// the area of foreign text but the mere fact that it's there (a line under a tile gives a busy\n// of about 0.12).\nconst float VG_STRUCTURE_GAIN = ${MEDIUM.structureGain}.0;\n// How much denser the body with ink gets over a BUSY backdrop than over a calm one. There's no\n// flat floor here: legibility picks up its own targeted requirement further down, and base\n// frosting comes from VG_MATTE_LIFT.\nconst float VG_GROUND_SPAN = ${BODY.groundSpan};\n// Scattered light on a frosted element is an ADDITION on top of the backdrop, not a fraction of\n// the way to the tint: the fraction goes to zero once the canvas reaches the tint's lightness,\n// and darkens past it (docs/benchmarks.md).\nconst float VG_MATTE_LIFT = ${MEDIUM.matteLift};\n// The fraction of backdrop spread that survives through to the body past scattering: the\n// legibility requirement is computed from this edge, not from the spot's average lightness.\nconst float VG_BUSY_EDGE = ${BODY.busyEdge};\n// Light concentration: the body is a touch lighter than what's beneath it (M 2:29).\nconst float VG_CONCENTRATE = ${MEDIUM.concentrate};\n// The lightness the medium pulls content under the glass toward, and the strength of that pull.\n// The medium both removes light and mixes in scattered light: over a light backdrop the body\n// darkens, over a dark one it lightens.\nconst float VG_MEDIUM_LUMA = ${MEDIUM.luma};\nconst float VG_MEDIUM_PULL = ${MEDIUM.pull};\n// How much ambient light reaches the body on top of the pull.\nconst float VG_AMBIENT_SPILL = ${MEDIUM.ambientSpill};\n\nfloat vgLuma(float3 c) { return dot(c, float3(0.2126, 0.7152, 0.0722)); }\n\n// Un-premultiply into ordinary color. One division, done in float: near zero, half's step is too\n// coarse, and several divisions in a row raise noise.\nfloat3 vgUnpack(half4 c) {\n float a = float(c.a);\n return a > 0.004 ? float3(c.rgb) / a : float3(0.0);\n}\n\n// The capture ends at the screen edge: samples are clamped to the rectangle where content\n// actually exists, otherwise full-width glass picked up a band of emptiness along its edges.\nfloat2 vgInContent(float2 q) { return clamp(q, u_contentMin, u_contentMax); }\n\n// Hue without lightness. Below the threshold the color has no hue, and the division blows up.\nfloat3 vgHue(float3 c) {\n float l = vgLuma(c);\n if (l < 0.02) { return float3(1.0); }\n return clamp(c / l, float3(0.0), float3(2.0));\n}\n\n// Edge profile — a convex squircle: x = 0 at the silhouette, 1 where the rounding turns flat.\nfloat vgRimQ(float x) {\n float k = 1.0 - x;\n return sqrt(sqrt(max(1.0 - k * k * k * k, 0.0)));\n}\n\nfloat vgRimQd(float x) {\n float k = 1.0 - x;\n return k * k * k / pow(max(1.0 - k * k * k * k, 1e-5), 0.75);\n}\n\n// Glass height above the content at distance e from the silhouette.\nfloat vgHeight(float e, float w) {\n return mix(u_rim, u_thick, vgRimQ(clamp(e / w, 0.0, 1.0)));\n}\n\n// Slope of the top face at the same point: the derivative of height with respect to distance\n// from the silhouette.\nfloat vgSlope(float e, float w) {\n if (e >= w) { return 0.0; }\n return min((u_thick - u_rim) / w * vgRimQd(clamp(e / w, 0.0, 1.0)), VG_SLOPE_MAX);\n}\n\n// Where a ray falling from above lands on a face with normal N: Snell's law refraction, then a\n// path of length z through the medium to the content. The convex face bends the ray toward the\n// normal — that is, inward relative to the shape.\nfloat2 vgShift(float3 N, float z, float ior) {\n float3 T = refract(float3(0.0, 0.0, -1.0), N, 1.0 / ior);\n return z * T.xy / max(-T.z, 0.05);\n}\n\n// Thin-film interference: optical path difference 2·n·d·cosθt, each channel with its own λ.\n// Returns a hue normalized to its own average — it colors, but doesn't lighten.\nfloat3 vgInterference(float cosI) {\n float sinT2 = (1.0 - cosI * cosI) / (VG_FILM_IOR * VG_FILM_IOR);\n float cosT = sqrt(max(1.0 - sinT2, 0.0));\n float opd = 2.0 * VG_FILM_IOR * u_film * cosT;\n float3 i = 0.5 + 0.5 * cos(VG_TAU * opd / VG_LAMBDA + 3.14159265);\n return i / max((i.r + i.g + i.b) / 3.0, 0.001);\n}\n\n// Edge diffraction: fringes get denser the sharper the bevel. Also a hue, not a brightness.\nfloat3 vgDiffraction(float distFromEdge, float bevel) {\n float phase = VG_TAU * ${SPECTRAL.diffractionFringes}.0 * distFromEdge / max(bevel, 1.0);\n float3 d = 0.5 + 0.5 * cos(phase * (${SPECTRAL.referenceLambda}.0 / VG_LAMBDA));\n return d / max((d.r + d.g + d.b) / 3.0, 0.001);\n}\n\nfloat vgHash(float2 p) {\n return fract(sin(dot(p, float2(12.9898, 78.233))) * 43758.5453);\n}\n\n// Soft compression instead of a hard clamp: over a white backdrop, additions used to knock a\n// channel to one, and the glass turned into a flat blob with no detail.\nfloat3 vgSoftClip(float3 c) {\n float3 over = max(c - 0.86, float3(0.0));\n return min(c, float3(0.86)) + over * 0.14 / (0.14 + over);\n}\n\n// Our own blur: the capture is left clean, the shader does the blurring — averaging in float\n// smooths banding on its own and adds no noise of its own. A golden-angle spiral, rotated to its\n// own angle at every pixel: with a shared angle, neighboring pixels took the same samples, and\n// texture under the glass read in clumps. Accumulated premultiplied — one shared un-premultiply\n// at the end.\nfloat4 vgGather(float2 q, float radius, float2 seed) {\n float4 acc = float4(content.eval(vgInContent(q)));\n if (radius <= 0.25) { return acc; }\n if (radius < 4.0) {\n float r = radius * 0.7;\n acc += float4(content.eval(vgInContent(q + float2(r, 0.0))))\n + float4(content.eval(vgInContent(q - float2(r, 0.0))))\n + float4(content.eval(vgInContent(q + float2(0.0, r))))\n + float4(content.eval(vgInContent(q - float2(0.0, r))));\n return acc * 0.2;\n }\n float ca = cos(2.39996323);\n float sa = sin(2.39996323);\n float a0 = vgHash(seed) * 6.28318530718;\n float2 dir = float2(cos(a0), sin(a0));\n float wide = radius * 0.5;\n int taps = int(clamp(float(VG_FROST_TAPS) * wide * wide, float(VG_FROST_TAPS), float(VG_FROST_TAPS_MAX)));\n for (int i = 1; i <= VG_FROST_TAPS_MAX; i++) {\n if (i > taps) { break; }\n dir = float2(dir.x * ca - dir.y * sa, dir.x * sa + dir.y * ca);\n float r = radius * sqrt(float(i) / float(taps));\n acc += float4(content.eval(vgInContent(q + dir * r)));\n }\n return acc / float(taps + 1);\n}\n\nhalf4 main(float2 xy) {\n float2 p = vgTouchWarp(xy - u_center, u_touch, u_pull, u_touchPress, u_touchRadius, u_wave.x, u_wave.y);\n float sd = vgScene(p, u_halfSize, u_corner, u_morphOffset, u_morphHalf, u_morphCorner, u_morphK,\n u_morph2Offset, u_morph2Half, u_morph2Corner);\n // There's nothing outside the glass — except the light it spills onto the backdrop under the\n // finger (M 3:38): the same concentrated ambient as inside, so no white halo appears over a\n // dark backdrop.\n if (sd > 1.0) {\n float spill = u_touchPress * exp(-sd / max(min(u_halfSize.x, u_halfSize.y) * 0.5, 4.0)) * 0.5 * u_appear;\n if (spill < 0.004) { return half4(0.0); }\n float3 lit = clamp((u_probeLuma >= 0.0 ? u_probe : float3(0.35)) * 1.6 + float3(0.1), float3(0.0), float3(1.0));\n return half4(half3(lit * spill), half(spill));\n }\n\n float bevel = max(u_bevel, 1.0);\n float e = max(-sd, 0.0);\n // 0 in the flat middle, 1 at the silhouette.\n float t = 1.0 - clamp(e / bevel, 0.0, 1.0);\n float2 n = vgSceneNormal(p, u_halfSize, u_corner, u_morphOffset, u_morphHalf, u_morphCorner, u_morphK,\n u_morph2Offset, u_morph2Half, u_morph2Corner);\n\n // \"backdrop\" mode hands back the content as-is — a reference point for comparing the optics.\n float on = u_debug > 5.5 && u_debug < 6.5 ? 0.0 : 1.0;\n float lens = on * u_appear;\n\n float z = vgHeight(e, bevel);\n float slope = vgSlope(e, bevel);\n float3 N = normalize(float3(n * slope, 1.0));\n float2 shift = vgShift(N, z, u_ior) * lens;\n float2 s = u_center + p + shift;\n\n // The area the lens gathers into one pixel: a one-pixel step inward on screen, measured\n // against the sampling step. At the silhouette it's large — a stripe of backdrop is compressed\n // into a line there, and a point sample gives grain.\n float e1 = e + 1.0;\n float3 N1 = normalize(float3(n * vgSlope(e1, bevel), 1.0));\n float2 shift1 = vgShift(N1, vgHeight(e1, bevel), u_ior) * lens;\n float footprint = length(shift1 - shift - n);\n float spread = max(footprint - 1.0, 0.0) * 0.5 * on;\n\n // Dispersion: the same ray with each channel's own index. Blue bends more than red.\n float2 dR = vgShift(N, z, u_ior + ${DISPERSION.redShift} * u_iorSpread) * lens - shift;\n float2 dB = vgShift(N, z, u_ior + ${DISPERSION.blueShift} * u_iorSpread) * lens - shift;\n float chroma = length(dB - dR);\n\n float3 rgb;\n float srcA;\n\n if (chroma + spread < 0.25) {\n // In the flat body all the samples would land at the same point, and the body is almost the\n // whole area of the glass.\n half4 c = content.eval(vgInContent(s));\n srcA = float(c.a);\n rgb = srcA > 0.004 ? float3(c.rgb) / srcA : float3(0.0);\n } else {\n // Accumulate premultiplied and divide once per pair: channels from different points with\n // different alpha would otherwise produce a colored fringe at content edges that isn't\n // really there.\n float2 ev = n * spread;\n half4 c0 = content.eval(vgInContent(s + dR - ev));\n half4 c1 = content.eval(vgInContent(s + dR + ev));\n half4 c2 = content.eval(vgInContent(s - ev));\n half4 c3 = content.eval(vgInContent(s + ev));\n half4 c4 = content.eval(vgInContent(s + dB - ev));\n half4 c5 = content.eval(vgInContent(s + dB + ev));\n\n float aR = float(c0.a + c1.a) * 0.5;\n float aG = float(c2.a + c3.a) * 0.5;\n float aB = float(c4.a + c5.a) * 0.5;\n rgb = float3(\n aR > 0.004 ? float(c0.r + c1.r) * 0.5 / aR : 0.0,\n aG > 0.004 ? float(c2.g + c3.g) * 0.5 / aG : 0.0,\n aB > 0.004 ? float(c4.b + c5.b) * 0.5 / aB : 0.0);\n srcA = (aR + aG + aB) / 3.0;\n }\n\n // \"backdrop\" mode checks the CAPTURE, not a simplified version of the optics. What follows are\n // layers that aren't tied to the lens (body, medium, scattering), and they used to conflate\n // \"did the pixels arrive\" with \"how did we process them.\" Here the element must DISAPPEAR: a\n // visible silhouette means a capture loss.\n if (u_debug > 5.5 && u_debug < 6.5) {\n float bypass = srcA * (1.0 - smoothstep(-1.0, 1.0, sd));\n return half4(half3(clamp(rgb, float3(0.0), float3(1.0)) * bypass), half(bypass));\n }\n\n // The transparent variant's dimming layer holds legibility instead of the body. A\n // multiplication, not a tint: the content has to stay visible, just quieter.\n rgb *= 1.0 - u_dim * u_appear;\n\n // REFLECTION. Fresnel from the face's actual slope: at the silhouette the view is grazing and\n // reflection is nearly total, which is why the rim reads as a thin line on its own. What's\n // reflected is the element's surroundings and the key light.\n float cosT = clamp(N.z, 0.0, 1.0);\n float f0 = (u_ior - 1.0) / (u_ior + 1.0);\n f0 *= f0;\n float fres = (f0 + (1.0 - f0) * pow(1.0 - cosT, 5.0)) * u_fresnel * lens;\n\n float lineW = clamp(min(u_halfSize.x, u_halfSize.y) * 0.03, 1.5, 5.0);\n float3 refl;\n if (e < lineW * 2.0 || fres > 0.01) {\n float2 around = u_center + p + n * (u_reflectReach * mix(0.35, 1.0, clamp(slope / 3.2, 0.0, 1.0)));\n // Two rings of eight samples total: a single offset sample is an undistorted COPY of\n // neighboring content inside the glass (docs/material-lab.md E-33).\n float p1 = u_reflectReach * 0.75;\n float p2 = u_reflectReach * 0.4;\n float d = 0.7071;\n float4 rsum = float4(content.eval(vgInContent(around + float2(p1, 0.0))))\n + float4(content.eval(vgInContent(around - float2(p1, 0.0))))\n + float4(content.eval(vgInContent(around + float2(0.0, p1))))\n + float4(content.eval(vgInContent(around - float2(0.0, p1))))\n + float4(content.eval(vgInContent(around + float2(p2, p2) * d)))\n + float4(content.eval(vgInContent(around + float2(-p2, p2) * d)))\n + float4(content.eval(vgInContent(around + float2(p2, -p2) * d)))\n + float4(content.eval(vgInContent(around + float2(-p2, -p2) * d)));\n float ra = rsum.a * 0.125;\n refl = ra > 0.004 ? rsum.rgb * 0.125 / ra : float3(0.0);\n } else {\n refl = u_probeLuma >= 0.0 ? u_probe : rgb;\n }\n\n // Light reaching the body is the same across the whole element: blending with the surroundings\n // over the bevel's band used to paint a ring-shaped seam on the body.\n float3 ambient = u_probeLuma >= 0.0 ? u_probe : rgb;\n\n // Light comes from wherever the surroundings are brighter (M 11:04): the lightness slope under\n // the element pulls the key light toward itself, and over a flat backdrop it stays at rest.\n float2 bright = u_probeLuma >= 0.0 ? u_probeSlope : float2(0.0);\n float brightLen = length(bright);\n float2 L = normalize(mix(u_light, bright / max(brightLen, 1e-4), smoothstep(0.03, 0.2, brightLen)) + float2(1e-5));\n // The key light's reflection uses the face's actual normal: at the flat top it points straight\n // up, and there's nothing there for direction to depend on. Using the SDF normal instead\n // painted the body as a cone.\n float facing = dot(N.xy, L);\n float key = u_specular * (pow(max(facing, 0.0), ${RIM.lobeExponent}.0) + ${RIM.opposingArc} * pow(max(-facing, 0.0), ${RIM.lobeExponent}.0));\n float rimFacing = dot(n, L);\n float rimKey = u_specular * (pow(max(rimFacing, 0.0), ${RIM.lobeExponent}.0) + ${RIM.opposingArc} * pow(max(-rimFacing, 0.0), ${RIM.lobeExponent}.0));\n // Wherever the key light doesn't fall, the face reflects its shaded surroundings — hence the\n // dark outline.\n float3 env = refl * (0.55 + 0.45 * min(key, 1.0)) + float3(1.2 * key);\n\n // Interference and diffraction live in the reflected ray at a grazing angle — a single hue\n // multiplier applied to the reflection, no extra samples.\n float3 spectral = float3(1.0);\n if (u_iridescence > 0.001) {\n spectral *= mix(float3(1.0), vgInterference(cosT), u_iridescence);\n }\n if (u_diffraction > 0.001) {\n float w = u_diffraction * smoothstep(${SPECTRAL.diffractionOnset}, 1.0, t);\n spectral *= mix(float3(1.0), vgDiffraction(e, bevel), w);\n }\n\n // The BACKDROP ESTIMATE arrives from the probe as one value per surface: computing it here\n // from samples isn't an option — a kink in density used to turn the estimate's discreteness\n // into ghost copies of text.\n float3 wide;\n float busy;\n if (u_probeLuma >= 0.0) {\n wide = u_probe;\n busy = u_probeBusy;\n } else {\n // The probe hasn't reported yet (first frames) — fall back to our own samples.\n float2 wx = float2(u_adaptRadius, 0.0);\n float2 wy = float2(0.0, u_adaptRadius);\n float3 w0 = vgUnpack(content.eval(vgInContent(s + wx)));\n float3 w1 = vgUnpack(content.eval(vgInContent(s - wx)));\n float3 w2 = vgUnpack(content.eval(vgInContent(s + wy)));\n float3 w3 = vgUnpack(content.eval(vgInContent(s - wy)));\n wide = (w0 + w1 + w2 + w3) * 0.25;\n float lw = vgLuma(wide);\n // The same statistic the probe uses (twice the mean deviation): both blur and the ink's\n // contrast margin depend on it, and the two paths' scales must not diverge.\n busy = clamp(0.5 * (abs(vgLuma(w0) - lw) + abs(vgLuma(w1) - lw)\n + abs(vgLuma(w2) - lw) + abs(vgLuma(w3) - lw)), 0.0, 1.0);\n }\n // Lightness AT THIS SPOT on the surface: the probe's plane, clamped to the measured range.\n float2 nrm = p / max(u_halfSize, float2(1.0));\n float local = u_probeLuma >= 0.0\n ? clamp(u_probeLuma + dot(u_probeSlope, nrm), u_probeRange.x, u_probeRange.y)\n : vgLuma(wide);\n float mean = u_probeLuma >= 0.0 ? u_probeLuma : vgLuma(wide);\n\n // SCATTERING. Regular mutes foreign structure under its own ink with blur, not a fill (M\n // 11:47): text under a capsule turns into blotches. Uniform across the whole lens; the radius\n // is measured in backdrop space — the lens compresses it at the silhouette.\n float structure = 1.0 - exp(-busy * VG_STRUCTURE_GAIN);\n // Under ink, Regular always scatters the backdrop; over a busy one, more strongly.\n float adaptBlur = max(\n (structure * VG_SCATTER_MAX + VG_SCATTER_BASE) * u_legibility * u_adaptRadius\n * min(max(footprint, 1.0), VG_FOOTPRINT_MAX),\n u_frost) * u_appear;\n if (adaptBlur > 0.5) {\n float reach = max(u_reach - length(p), 1.0);\n float4 g = vgGather(s, min(adaptBlur, reach), xy);\n float ga = g.a;\n float3 blurred = ga > 0.004 ? g.rgb / ga : float3(0.0);\n rgb = mix(rgb, blurred, smoothstep(0.5, 2.0, adaptBlur));\n }\n\n // AFTER scattering, not before: scattering is a property of TRANSMITTED light and replaces rgb\n // wholesale, so doing it the other way around erased the reflection over the whole element\n // (issue #106).\n rgb = mix(rgb, env * spectral, fres);\n\n // BODY. Tint and dynamic range under the glass compress just enough for ink over it to stay\n // legible (M 6:42). u_ink is ink POLARITY (1 light, 0 dark): the requirements are computed at\n // the two ends and blended by it, otherwise the glass dips toward the middle during a recolor.\n float strict = clamp(u_legibility * 2.0, 0.0, 1.0);\n float capLight = mix(VG_BODY_CAP_LOOSE, VG_BODY_CAP_TIGHT, strict);\n float floorDark = 1.0 - capLight;\n float pol = clamp(u_ink, 0.0, 1.0);\n // The requirement fades together with legibility: an element with no ink is promised\n // transparent glass by the model.\n float demand = clamp(u_legibility * 4.0, 0.0, 1.0);\n\n // Where there's no ink, the glass tints away from the backdrop. The direction is chosen by the\n // average lightness under the element, not the local spot's lightness: otherwise on a gradient\n // the threshold cuts across the body as a diagonal step.\n float darkSide = smoothstep(${BODY.darkSideFrom}, ${BODY.darkSideTo}, mean);\n float away = mix(VG_TINT_LIGHT, VG_TINT_DARK, darkSide);\n float tintLuma = mix(away, mix(VG_TINT_LIGHT, VG_TINT_DARK, pol), demand);\n\n // How much medium it takes to push lightness under the ink past the threshold — locally.\n // Computed from whichever edge of the backdrop's spread is closer to the ink: a light ink\n // drowns in a light spot right beneath it, and the spot's average lightness knows nothing\n // about that spot.\n float edge = busy * VG_BUSY_EDGE;\n float inkHi = min(local + edge, 1.0);\n float inkLo = max(local - edge, 0.0);\n float needForLight = inkHi > capLight\n ? clamp((inkHi - capLight) / max(inkHi - VG_TINT_DARK, 1e-4), 0.0, ${BODY.maxDemand})\n : 0.0;\n float needForDark = inkLo < floorDark\n ? clamp((floorDark - inkLo) / max(VG_TINT_LIGHT - inkLo, 1e-4), 0.0, ${BODY.maxDemand})\n : 0.0;\n float needForInk = mix(needForDark, needForLight, pol) * demand;\n\n float ground = structure * u_legibility * VG_GROUND_SPAN;\n float density = max(max(u_bodyDensity, ground), needForInk);\n\n // PRESENCE (§3). Over a uniform backdrop there is nothing to refract, and an element that is\n // only a rim honestly disappears — right for a piece of background, wrong for a control.\n //\n // This used to live on the rim line alone, as lit = max(rimKey, u_presence x 2), while the\n // DOM path has always implemented it as a floor on the BODY. Two renderers, one field, two\n // meanings. Measured on Apple's own control over a flat page (frames/verify/m-707), the body\n // carries 16 levels of separation there and the rim 11.6 — so the body is where it belongs,\n // and the rim's reading was the wrong one.\n // The separation asked for is capped by the range that is left: over a backdrop at 0.96 there\n // is no room to go 0.05 lighter. And what it is DIVIDED by is the distance to the tint's own\n // end, not to the tint the body currently sits at — dividing by the latter explodes wherever\n // the two are close, which is how the first version of this drove density to its ceiling at\n // both extremes and took the window down to 7%.\n bool lighter = local < 0.5;\n float target = lighter ? min(local + u_presence, 1.0) : max(local - u_presence, 0.0);\n float separation = abs(target - local);\n float reached = abs(tintLuma - local) * density;\n if (u_presence > 0.0 && reached < separation) {\n float toEnd = abs((lighter ? VG_TINT_LIGHT : VG_TINT_DARK) - local);\n density = max(density, min(separation / max(toEnd, 1e-4), ${BODY.maxDemand}));\n }\n\n // Glass has no color of its own — only the color of what's beneath it (HIG \"Color\").\n float3 tintHue = mix(float3(1.0), vgHue(wide * 0.5 + ambient * 0.5), u_colorPickup);\n // The element appears by the lens and body building up, not by fading in (M 2:55): at\n // u_appear = 0 it's indistinguishable from the backdrop beneath it.\n rgb = mix(rgb, tintHue * tintLuma, density * u_appear);\n rgb += tintHue * (u_legibility * VG_MATTE_LIFT * u_appear);\n\n // TINTING — colored glass, not a fill (M 16:31, 17:03): the backdrop's lightness drives the\n // tone — deeper over dark, lighter over light — and the content's texture still shows through\n // the color.\n if (u_accent.a > 0.0) {\n float3 tone = u_accent.rgb * mix(${ACCENT.deep}, ${ACCENT.light}, local);\n float3 through = tone * (0.85 + 0.3 * vgLuma(rgb));\n rgb = mix(rgb, clamp(through, float3(0.0), float3(1.0)), u_accent.a * u_appear);\n }\n\n // CONTRAST COMPRESSION. The medium removes some light and mixes in scattered light, so content\n // under the glass moves toward the middle rather than simply getting lighter (M 2:35). The\n // previous layer only added light and, over a light backdrop, pushed the body the opposite way\n // from the reference.\n rgb = mix(rgb, vgHue(ambient) * VG_MEDIUM_LUMA, VG_MEDIUM_PULL * u_appear);\n // Ambient light reaches the body the same way across the whole element.\n rgb += ambient * u_edgeLight * VG_AMBIENT_SPILL * u_appear;\n // Glass concentrates light; the played portion is the segment where there's more of it.\n float glow = VG_CONCENTRATE + 0.08 * vgProgress(p, u_halfSize, u_progress);\n rgb += (1.0 - rgb) * glow * lens;\n\n // Under the finger and during morphing, glass concentrates light into a spot (M 4:56, 5:11).\n // This is a CONCENTRATION of the surroundings, not the glass's own whiteness: over a dark\n // backdrop the element lightens but never turns white, and ink over it stays legible.\n if (u_touchPress > 0.001) {\n float2 fromTouch = p - u_touch;\n float spotR = max(min(u_halfSize.x, u_halfSize.y) * 1.2, 1.0);\n float spot = u_touchPress * (0.3 + 0.55 * exp(-dot(fromTouch, fromTouch) / (spotR * spotR)));\n rgb = mix(rgb, clamp(ambient * 1.6 + float3(0.1), float3(0.0), float3(1.0)), spot * lens);\n }\n\n // RIM LIGHT — a separate layer, a line about 1 pt wide along the silhouette (M 2:36, 11:04):\n // brighter where the face faces the key light, weaker opposite it; where no light falls, a\n // dark outline. This line is what holds the element's presence, not a fill on the body: over a\n // flat backdrop a control is visible along its whole silhouette because of it.\n float line = (1.0 - smoothstep(0.0, lineW, e)) * lens;\n float outline = (1.0 - smoothstep(0.0, lineW * 0.6, e)) * lens;\n float lit = clamp(max(rimKey * 1.4, u_presence * 2.0), 0.0, 1.0);\n // The dark rim is its own layer around the whole silhouette, and the highlight sits ON TOP of\n // it (iOS 27). While the outline used to fade via a (1 − lit) multiplier, the silhouette read\n // as a single arc: highlight OR shadow.\n rgb *= 1.0 - ${RIM.darkEdge} * outline;\n rgb = mix(rgb, mix(refl, float3(1.0), 0.75), line * lit);\n\n if (u_debug > 9.5 && u_debug < 10.5) { rgb = spectral * 0.5; }\n if (u_debug > 10.5 && u_debug < 11.5) { rgb = float3(density, needForInk, structure); }\n // WHAT THE PROBE SAID ABOUT THE BACKDROP — three values that drive all the tinting: the\n // average lightness under the element, the vertical lightness slope, and the lightness AT THIS\n // SPOT. The slope is shown offset and squeezed by half: it's signed and rarely exceeds a\n // magnitude of one half.\n if (u_debug > 11.5) { rgb = float3(max(u_probeLuma, 0.0), 0.5 + u_probeSlope.y * 0.5, local); }\n\n rgb = vgSoftClip(rgb);\n\n // Sample alpha has to survive to the result: un-premultiplying color by its original alpha and\n // then returning it with a different one (the shape mask) would make a transparent backdrop\n // opaque and blow it out.\n float alpha = srcA * (1.0 - smoothstep(-1.0, 1.0, sd));\n return half4(half3(clamp(rgb, float3(0.0), float3(1.0)) * alpha), half(alpha));\n}\n`;\n","import { ACCENT, MORPH } from './law';\nimport {\n bevelDp,\n bevelFraction,\n halfMinDp,\n rimDp,\n shadowReachDp,\n surfacePadDp,\n thicknessDp,\n type VireGlassGeometry,\n} from './geometry';\nimport { LENS_SHADER } from './lens-shader';\nimport { neckToBridge } from './sdf';\nimport { debugIndex, type VireGlassDebugMode, type VireGlassOptics } from './material';\n\n/** Smooth union with a second shape — bench morphing experiment only. */\nexport type VireGlassMorph = {\n offsetX: number;\n offsetY: number;\n width: number;\n height: number;\n cornerRadius: number;\n /** Seam smoothing radius in dp; 0 turns the second shape off. */\n smoothing: number;\n};\n\n\n/** Surface response to a finger: the field around the touch point deforms, not the shape's\n * bounding box (`vgTouchWarp` in `sdf.ts`). Lengths in dp; `radius` = 0 turns the response off\n * entirely. */\nexport type VireGlassTouch = {\n x: number;\n y: number;\n pullX: number;\n pullY: number;\n press: number;\n radius: number;\n waveAmp: number;\n wavePhase: number;\n};\n\nconst NO_TOUCH: VireGlassTouch = {\n x: 0, y: 0, pullX: 0, pullY: 0, press: 0, radius: 0, waveAmp: 0, wavePhase: 0,\n};\n\nconst NO_MORPH = { offsetX: 0, offsetY: 0, width: 0, height: 0, cornerRadius: 0, smoothing: 0 };\n\n/** No progress. Negative rather than zero: zero is the start of the track, a legitimate value. */\nconst NO_PROGRESS = -1;\n\n/** Tinted glass for the primary action (M 16:08). Color is RGB 0…1. */\nexport type VireGlassAccent = { color: readonly [number, number, number]; amount?: number };\n\n/** Default tint fraction: the color reads, but content beneath it is still visible. */\nexport const ACCENT_AMOUNT = ACCENT.amount;\nconst NO_ACCENT = [0, 0, 0, 0] as const;\n\n\n\n/** Magnification at the flat center. Kept separate from the uniform channel: it's also used by\n * the fallback below Android 13, where there's no RuntimeShader and only an affine magnifier is\n * left. */\nexport const lensMagnify = (o: VireGlassOptics) => 1 + (o.refractionScale - 1) * o.refraction;\n\n/**\n * Lens uniforms. Assembled as ONE channel: name, size and values travel together, so a mismatch\n * with the shader is caught immediately, with the name right there in the log. There used to be a\n * separate Kotlin `Prop` per value — Expo swallows an unknown prop silently, and the lens simply\n * never turned on (docs/material-lab.md E-01, which is how refraction ended up disabled for an\n * entire phase).\n *\n * Everything with a dimension is converted to PIXELS right here. The native view is left with\n * only the uniforms it alone knows: its own size and its own place on screen.\n */\n// The lens's uniform names and sizes are always the same — the set is fixed. They're handed over\n// as ONE instance for the whole process: otherwise every frame of a drag would send three dozen\n// fresh strings to the native side, React can't tell \"unchanged\" from \"a new array\", and motion\n// goes stepwise. The values are the only thing that actually changes.\nconst shapes = new Map<number, { names: string[]; sizes: number[] }>();\n\nfunction channel(entries: [string, number | readonly number[]][]) {\n const uniformValues: number[] = [];\n let shape = shapes.get(entries.length);\n let same = shape !== undefined;\n for (let i = 0; i < entries.length; i += 1) {\n const [name, value] = entries[i];\n const v = typeof value === 'number' ? [value] : value;\n if (same && (shape!.names[i] !== name || shape!.sizes[i] !== v.length)) same = false;\n for (const x of v) uniformValues.push(x);\n }\n if (!same) {\n shape = {\n names: entries.map((e) => e[0]),\n sizes: entries.map((e) => (typeof e[1] === 'number' ? 1 : e[1].length)),\n };\n shapes.set(entries.length, shape);\n }\n return { uniformNames: shape!.names, uniformSizes: shape!.sizes, uniformValues };\n}\n\n/** Props for the native view. Besides the uniform channel, only what the view uses itself lives\n * here: the shader source and the visible glass's size (the probe rectangle is taken from it). */\nexport function toLensProps(\n optics: VireGlassOptics,\n geometry: VireGlassGeometry,\n density: number,\n options: {\n debug?: VireGlassDebugMode;\n morph?: VireGlassMorph;\n /** Third shape of the fused body; a zero size turns it off. */\n morph2?: VireGlassMorph;\n groupProbe?: number[];\n touch?: VireGlassTouch;\n /** Progress fraction, 0…1: to the left of the boundary the element is active. `undefined` means no progress. */\n progress?: number;\n /** Key light direction in screen space; defaults to the light at rest. */\n light?: readonly [number, number];\n /** 0…1: the lens builds up as the element appears — instead of a plain fade. */\n appear?: number;\n /** Tint for the primary action: the glass color and the fraction it lays over the content. */\n accent?: VireGlassAccent;\n } = {},\n) {\n const morph = options.morph ?? NO_MORPH;\n const morph2 = options.morph2 ?? NO_MORPH;\n const touch = options.touch ?? NO_TOUCH;\n // Backdrop estimate for the whole surface group. Travels through the same channel as the\n // material and applies AFTER the lens's own estimate — that is, it simply overrides it. It\n // can't travel as a separate prop: the lens view is wrapped in an animated component.\n const g = options.groupProbe;\n const group: [string, number | readonly number[]][] =\n g && g.length >= 9\n ? [\n ['u_probeLuma', g[0]],\n ['u_probeBusy', g[1]],\n ['u_probeRange', [g[2], g[3]]],\n ['u_probeSlope', [g[4], g[5]]],\n ['u_probe', [g[6], g[7], g[8]]],\n ]\n : [];\n const d = density;\n const halfW = (geometry.width * d) / 2;\n const halfH = (geometry.height * d) / 2;\n const halfMin = Math.min(halfW, halfH);\n\n return {\n shaderSource: LENS_SHADER,\n glassWidth: geometry.width,\n glassHeight: geometry.height,\n ...channel([\n ['u_halfSize', [halfW, halfH]],\n ['u_corner', Math.min(geometry.cornerRadius * d, halfMin)],\n ['u_bevel', Math.max(bevelDp(geometry, optics) * d, 1)],\n ['u_thick', thicknessDp(geometry, optics) * d],\n ['u_rim', rimDp(geometry, optics) * d],\n ['u_ior', optics.ior],\n ['u_iorSpread', optics.iorSpread],\n ['u_light', options.light ?? REST_LIGHT],\n ['u_appear', options.appear ?? 1],\n ['u_accent', options.accent ? [...options.accent.color, options.accent.amount ?? ACCENT_AMOUNT] : NO_ACCENT],\n // Haze from surface roughness. Lives in the same disc-gather pass as adaptive scattering,\n // and fades out toward the bevel: that's a different job there — bending the ray and\n // splitting it.\n ['u_frost', optics.blur * d],\n ['u_ink', optics.ink],\n ['u_legibility', optics.legibility],\n ['u_dim', optics.dimming],\n ['u_presence', optics.presence],\n ['u_adaptRadius', optics.adaptRadius * d],\n ['u_bodyDensity', optics.bodyDensity],\n ['u_edgeLight', optics.edgeLight],\n ['u_fresnel', optics.fresnel],\n ['u_specular', optics.specular],\n // The rim gathers light from the element's vicinity — this is a radius around the shape,\n // not its bevel.\n ['u_reflectReach', optics.gatherRadiusDp * d],\n ['u_film', optics.film],\n ['u_iridescence', optics.iridescence],\n ['u_diffraction', optics.diffraction],\n ['u_colorPickup', optics.colorPickup],\n ['u_morphOffset', [morph.offsetX * d, morph.offsetY * d]],\n ['u_morphHalf', [(morph.width * d) / 2, (morph.height * d) / 2]],\n ['u_morphCorner', morph.cornerRadius * d],\n ['u_morphK', morph.smoothing * d],\n ['u_morph2Offset', [morph2.offsetX * d, morph2.offsetY * d]],\n ['u_morph2Half', [(morph2.width * d) / 2, (morph2.height * d) / 2]],\n ['u_morph2Corner', morph2.cornerRadius * d],\n ['u_touch', [touch.x * d, touch.y * d]],\n ['u_pull', [touch.pullX * d, touch.pullY * d]],\n ['u_touchPress', touch.press],\n ['u_touchRadius', touch.radius * d],\n ['u_wave', [touch.waveAmp * d, touch.wavePhase]],\n ['u_progress', options.progress ?? NO_PROGRESS],\n ['u_debug', debugIndex(options.debug ?? 'normal')],\n ...group,\n ]),\n };\n}\n\n/** Static part of the surface uniforms. Dynamics (gesture, press, light) get mixed in inside the\n * component's worklet — the adapter must stay an ordinary function. */\nexport function toSurfaceUniforms(\n optics: VireGlassOptics,\n geometry: VireGlassGeometry,\n options: {\n debug?: VireGlassDebugMode;\n morph?: VireGlassMorph;\n /** Third shape of the fused body; a zero size turns it off. */\n morph2?: VireGlassMorph;\n dragLimit?: number;\n shadow?: number;\n /** Average ambient color around the element: light from it bleeds into the shadow (reference 219 @8:22). */\n ambient?: readonly [number, number, number];\n /** The lens draws the glass body — the surface is left with the highlight, shadow and icon. */\n bodyInLens?: boolean;\n touch?: VireGlassTouch;\n /** Progress fraction, 0…1: to the left of the boundary the element is active. `undefined` means no progress. */\n progress?: number;\n /** 0…1: the element is appearing — shadow and ink build up together with the lens. */\n appear?: number;\n /** 0 — the element sinks in under the finger, 1 — it rises into glass (reference §5). */\n lift?: number;\n } = {},\n) {\n const morph = options.morph ?? NO_MORPH;\n const morph2 = options.morph2 ?? NO_MORPH;\n const touch = options.touch ?? NO_TOUCH;\n const pad = surfacePadDp(geometry, options.dragLimit ?? 0, morph);\n return {\n u_center: [geometry.width / 2 + pad, geometry.height / 2 + pad],\n u_halfSize: [geometry.width / 2, geometry.height / 2],\n u_corner: Math.min(geometry.cornerRadius, halfMinDp(geometry)),\n u_bevel: bevelDp(geometry, optics),\n u_thickness: bevelFraction(geometry, optics),\n u_morphOffset: [morph.offsetX, morph.offsetY],\n u_morphHalf: [morph.width / 2, morph.height / 2],\n u_morphCorner: morph.cornerRadius,\n u_morphK: morph.smoothing,\n u_morph2Offset: [morph2.offsetX, morph2.offsetY],\n u_morph2Half: [morph2.width / 2, morph2.height / 2],\n u_morph2Corner: morph2.cornerRadius,\n u_edgeDensity: optics.edgeDensity,\n u_dispersion: optics.dispersion,\n u_refraction: optics.refraction,\n // Tint density is suppressed when the lens is drawing the body: painting it twice would\n // double the fill, and adaptation is impossible on the surface anyway — it can't see the\n // backdrop. The color itself stays: it drives absorption at the rim.\n u_tint: [\n optics.tint.r,\n optics.tint.g,\n optics.tint.b,\n options.bodyInLens ? 0 : optics.tintStrength,\n ],\n u_shadow: options.shadow ?? 1,\n // Neutral by default: without an ambient sample, the shadow stays exactly as it was.\n u_ambient: options.ambient ?? [0, 0, 0],\n u_shadowReach: shadowReachDp(geometry),\n u_touch: [touch.x, touch.y],\n u_pull: [touch.pullX, touch.pullY],\n u_touchPress: touch.press,\n u_touchRadius: touch.radius,\n u_wave: [touch.waveAmp, touch.wavePhase],\n u_presence: optics.presence,\n u_progress: options.progress ?? NO_PROGRESS,\n u_appear: options.appear ?? 1,\n // Zero by default: buttons sink in, the way every element behaved before this rule existed.\n u_lift: options.lift ?? 0,\n\n u_debug: debugIndex(options.debug ?? 'normal'),\n };\n}\n\n/**\n * Surface fields that are LENGTHS: the adapter's contract is specified in dp, and on the web each\n * one of them has to be multiplied by screen density. The list lives here rather than in the\n * renderer, where it used to be a dozen and a half manual multiplications in a row: a missed\n * field there was only caught by eye, and the miss isn't visible everywhere — at density 1,\n * multiplying is indistinguishable from not doing it.\n */\nexport type SurfaceUniforms = ReturnType<typeof toSurfaceUniforms>;\n\nexport const SURFACE_LENGTH_UNIFORMS = [\n 'u_halfSize',\n 'u_corner',\n 'u_bevel',\n 'u_morphOffset',\n 'u_morphHalf',\n 'u_morphCorner',\n 'u_morphK',\n 'u_morph2Offset',\n 'u_morph2Half',\n 'u_morph2Corner',\n 'u_shadowReach',\n 'u_touch',\n 'u_pull',\n 'u_touchRadius',\n // `satisfies`, not just `as const`: otherwise a typo in the name compiles silently and makes it\n // to runtime — the field with the garbage name gets NaN, and the real one is left un-multiplied.\n] as const satisfies readonly (keyof SurfaceUniforms)[];\n\n/**\n * Surface uniforms in device pixels. Android draws in dp and calls the adapter as-is; the web\n * needs this conversion. `u_center` isn't part of it: the renderer knows the element's center on\n * its own.\n */\nexport function toDeviceSurfaceUniforms(raw: SurfaceUniforms, density: number): SurfaceUniforms {\n const scaled: Record<string, unknown> = { ...raw };\n for (const key of SURFACE_LENGTH_UNIFORMS) {\n const value: unknown = scaled[key];\n scaled[key] = Array.isArray(value)\n ? (value as number[]).map((v) => v * density)\n : (value as number) * density;\n }\n // Of the wave, only the amplitude has a length; the phase is in turns and knows nothing about density.\n scaled.u_wave = [raw.u_wave[0] * density, raw.u_wave[1]];\n return scaled as SurfaceUniforms;\n}\n\n/** Key light direction in screen coordinates, for when the orientation response is off. */\nexport const REST_LIGHT: readonly [number, number] = [-0.577, -0.817];\n\n/** Uniforms the component mixes in inside the worklet (press, active, light direction) and via\n * the icon layer. Listed here so a test can check the shader contract's completeness without\n * importing the component itself (it pulls in Skia and doesn't come up in a node environment). */\nexport const DYNAMIC_UNIFORMS = ['u_press', 'u_active'] as const;\n\nexport const ICON_UNIFORMS = ['u_iconOn', 'u_iconScale', 'u_inkIdle', 'u_inkActive'] as const;\n\n/** App-colored overlay layer on the glass. The `u_overlay` sampler shares its contract with the\n * ink mask and is sampled at the SAME coordinate — otherwise deformation would carry them apart. */\nexport const OVERLAY_UNIFORMS = ['u_overlayOn'] as const;\n\n/**\n * Fusing two surfaces into one continuous medium.\n *\n * The second shape is described RELATIVE to the first one's center, because both live in the\n * same shader: the union has no \"two pieces of glass,\" just one body with two bulges — the mask,\n * the refraction and the rim are all computed from a single shared scene.\n *\n * `t` — how fused the shapes are: 0 turns the second shape off before any computation, 1 gives a\n * single shared medium. The seam's smoothing radius is a fraction of the smaller half-size: on\n * large elements the bridge has to be wider, otherwise the seam is left with a sharp corner,\n * which doesn't happen in a liquid.\n */\n\n\n/**\n * How wide the neck between two lobes has to be: enough to soften the seam on a large element, and\n * enough to actually SPAN whatever is between them. The second term is the one that was missing.\n */\nfunction neckFor(\n half: number,\n aw: number,\n ah: number,\n bw: number,\n bh: number,\n offsetX: number,\n offsetY: number,\n): number {\n // Surface-to-surface, measured between the bounding boxes. The rounded corners put the true\n // surfaces slightly further apart, so this errs toward a wider neck, which is the safe side.\n const gx = Math.abs(offsetX) - (aw + bw) / 2;\n const gy = Math.abs(offsetY) - (ah + bh) / 2;\n const gap = Math.hypot(Math.max(gx, 0), Math.max(gy, 0));\n // Capped at the narrowest of the two bodies. A neck wider than what it joins is not a neck, and\n // past that width the honest answer is that these are two things rather than one — a menu that\n // has finished leaving its button, two controls too far apart to be a segmented control. Being\n // separate is a legitimate state; being joined by a blob larger than either shape is not.\n const widest = Math.min(aw, ah, bw, bh);\n return Math.min(Math.max(half * MORPH.neck, neckToBridge(gap) * MORPH.fuse), widest);\n}\n\nexport function morphBetween(\n a: VireGlassGeometry,\n b: VireGlassGeometry,\n offsetX: number,\n offsetY: number,\n t: number,\n): VireGlassMorph | undefined {\n if (t <= 0) return undefined;\n const half = Math.min(halfMinDp(a), halfMinDp(b));\n return {\n offsetX,\n offsetY,\n width: b.width,\n height: b.height,\n cornerRadius: b.cornerRadius,\n smoothing: neckFor(half, a.width, a.height, b.width, b.height, offsetX, offsetY) * Math.min(t, 1),\n };\n}\n\n/**\n * MITOSIS: the second shape grows OUT OF the first and travels to its place, instead of appearing\n * beside it at full size. A menu coming out of its button, a control dividing into segments.\n *\n * `morphBetween` is the other half — two shapes that are both already where they belong, fusing\n * into one body — and run backwards it is meiosis, the neck thinning until it breaks. What neither\n * of them may do is pop: at any `t` above zero this returns one continuous body, because that is\n * the whole of what the reference says a material transition is.\n *\n * The choreography stays the host's: what the shapes MEAN is the app's business. How a silhouette\n * emerges from another silhouette is the material's, the same way the spring under a finger is.\n */\nexport function morphOutOf(\n source: VireGlassGeometry,\n target: VireGlassGeometry,\n offsetX: number,\n offsetY: number,\n t: number,\n): VireGlassMorph | undefined {\n if (t <= 0) return undefined;\n const k = Math.min(t, 1);\n // At t = 0 the lobe IS the parent, in the parent's place: the transition starts from one body and\n // never has a first frame in which a second one exists. The parent's own surface is what the neck\n // attaches to, so nothing has to be budded off to give it something to hold.\n const width = source.width + (target.width - source.width) * k;\n const height = source.height + (target.height - source.height) * k;\n const cornerRadius = source.cornerRadius + (target.cornerRadius - source.cornerRadius) * k;\n const half = Math.min(halfMinDp(source), Math.min(width, height) / 2);\n return {\n offsetX: offsetX * k,\n offsetY: offsetY * k,\n width,\n height,\n cornerRadius,\n // The lobe travels as it grows, so the span changes every frame and the neck is measured\n // against where the lobe actually is, not against where it will end up.\n smoothing: neckFor(half, source.width, source.height, width, height, offsetX * k, offsetY * k),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/optics.ts","../src/material.ts","../src/sdf.ts","../src/lens-shader.ts","../src/adapters.ts"],"names":["thicknessDp","bevelDp","clamp","shapes"],"mappings":";;;;AAWA,IAAM,KAAA,GAAQ,CAAC,CAAA,EAAW,EAAA,EAAY,EAAA,KAAgB,IAAI,EAAA,GAAK,EAAA,GAAK,CAAA,GAAI,EAAA,GAAK,EAAA,GAAK,CAAA;AAClF,IAAM,UAAU,CAAC,CAAA,KAAc,KAAA,CAAM,CAAA,EAAG,GAAG,CAAC,CAAA;AAGrC,IAAM,YAAY,CAAC,GAAA,KAAA,CAAA,CAAkB,GAAA,GAAM,CAAA,KAAM,MAAM,CAAA,CAAA,KAAO;AAE9D,IAAM,eAAA,GAAkB,CAAC,GAAA,KAAgB,OAAA,CAAQ,UAAU,GAAG,CAAA,GAAI,OAAO,WAAW;AAGpF,IAAM,mBAAmB,MAAA,CAAO;AAIhC,IAAM,qBAAqB,CAAC,GAAA,KAAgB,SAAS,GAAA,GAAM,CAAA,IAAK,OAAO,WAAW;AAElF,IAAM,eAAA,GAAkB,CAAC,GAAA,EAAaA,YAAAA,KAC3C,CAAA,GAAI,MAAA,CAAO,YAAA,GAAeA,YAAAA,IAAe,CAAA,GAAI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BF67.js","sourcesContent":["// Deriving optics from the medium's properties. The material describes CAUSES (index of\n// refraction, thickness, bevel, roughness); the shaders need EFFECTS — this file translates one\n// into the other. Pure functions: the physics is checked by tests, not on a device.\n//\n// The normalisations themselves are in `law.ts` under DERIVE, with the rest of the calibration.\n// They are honestly labelled there: the rendering is stylised, and literal physical values (glass\n// reflects 4% at normal incidence) produce effects right at the threshold of visibility. Each is\n// monotonic in its own cause, so \"denser medium → more visible rim\" always holds, and no\n// impossible combination can arise.\nimport { DERIVE } from './law';\n\nconst clamp = (v: number, lo: number, hi: number) => (v < lo ? lo : v > hi ? hi : v);\nconst clamp01 = (v: number) => clamp(v, 0, 1);\n\n/** Reflectance at normal incidence: ((n−1)/(n+1))². For glass, n=1.5 gives 0.04. */\nexport const fresnelF0 = (ior: number) => ((ior - 1) / (ior + 1)) ** 2;\n\nexport const fresnelStrength = (ior: number) => clamp01(fresnelF0(ior) * DERIVE.fresnelGain);\n\n/** Exponent in the Schlick approximation — a constant of the model, not a knob. */\nexport const FRESNEL_EXPONENT = DERIVE.fresnelExponent;\n\n/** Strength of ray bending. As n→1 the medium is indistinguishable from air; n=1.6 is taken as\n * full strength. */\nexport const refractionStrength = (ior: number) => clamp01((ior - 1) / DERIVE.iorFullBend);\n\nexport const refractionScale = (ior: number, thicknessDp: number) =>\n 1 + DERIVE.magnifyPerDp * thicknessDp * (1 - 1 / Math.max(ior, 1));\n\nexport const dispersion = (ior: number) => clamp01((ior - 1) * DERIVE.dispersionPerIor);\n\nexport const iorSpread = (ior: number) => dispersion(ior) * DERIVE.iorSpreadPerDispersion;\n\nexport const absorption = (pathDp: number) =>\n 1 - Math.exp(-DERIVE.absorbPerDp * Math.max(pathDp, 0));\n\n/**\n * Density at the bevel relative to the body. Not a separate quantity: at the rim the ray travels\n * LONGER through the medium by the bevel's width, and absorption over that path is greater. This\n * used to be a separate `edgeDensity` slider, which is how a thin bevel with a milky rim got\n * built — a state that doesn't occur in real glass.\n */\nexport const edgeDensity = (thicknessDp: number, bevelDp: number) => {\n const body = absorption(thicknessDp);\n if (body <= 0) return 1;\n return clamp(absorption(thicknessDp + bevelDp) / body, 1, DERIVE.edgeDensityMax);\n};\n\n/**\n * Backdrop haziness — surface roughness, not a separate blur setting.\n *\n * The ceiling is deliberately low. Blur in this model is a SUPPORTING device: it helps ink sit\n * over glass, but doesn't improve the picture on its own. Past roughly a dozen dp, letters under\n * the glass stop being letters and turn into a mush of pixels — no amount of legibility justifies\n * that. Separating content from the ink is body density's job, not blur's.\n */\nexport const blur = (roughness: number) => clamp01(roughness) * DERIVE.blurMaxDp;\n\n/** A smooth surface gives a narrow highlight, a rough one a spread-out one. */\nexport const specularPower = (roughness: number) =>\n DERIVE.specularPowerSmooth -\n clamp01(roughness) * (DERIVE.specularPowerSmooth - DERIVE.specularPowerRough);\n\n/** Highlight brightness — the same reflectance as Fresnel, damped by roughness. */\nexport const specularStrength = (ior: number, roughness: number) =>\n clamp01(fresnelStrength(ior) * (1 - clamp01(roughness) * DERIVE.specularRoughDamping));\n\n/**\n * Color of the medium. Never set by hand: in transparent media, hue is tied to density. Water\n * absorbs red and skews cool, ordinary glass is nearly neutral with a faint green, dense\n * high-index media skew warm. Lightness follows reflectance: the denser the medium, the more of\n * its surroundings it returns, and the lighter its body reads.\n */\ntype Hue = readonly [number, number, number];\nconst mixHue = (a: Hue, b: Hue, t: number): Hue => [\n a[0] + (b[0] - a[0]) * t,\n a[1] + (b[1] - a[1]) * t,\n a[2] + (b[2] - a[2]) * t,\n];\n\nexport function mediumTint(ior: number): { r: number; g: number; b: number } {\n const t = clamp01((ior - DERIVE.hueFromIor) / DERIVE.hueSpan);\n const hue =\n t < 0.5\n ? mixHue(DERIVE.hueCool, DERIVE.hueNeutral, t * 2)\n : mixHue(DERIVE.hueNeutral, DERIVE.hueWarm, (t - 0.5) * 2);\n const lift = DERIVE.bodyLiftBase + fresnelF0(ior) * DERIVE.bodyLiftPerF0;\n return { r: clamp01(hue[0] * lift), g: clamp01(hue[1] * lift), b: clamp01(hue[2] * lift) };\n}\n\n/**\n * How far the rim gathers light AROUND the element.\n *\n * On real glass, at a grazing angle the eye receives not what's under the glass but the\n * surroundings: an object on a black table next to a lamp catches the lamp. So the radius is\n * noticeably larger than the bevel — it's the element's vicinity, not its rim. Without this,\n * glass on an empty black background has no source at all and honestly disappears.\n */\n/**\n * Ceiling on the radius. Without it, a wide bevel would gather its surroundings from fifty-odd dp\n * away, and a READABLE copy of whatever sits nearby would appear inside the glass: eight samples\n * aren't enough to blur a disc that large (E-33, E-37). Real rims also gather light mostly from\n * nearby — an unbounded radius was a modeling mistake.\n */\nexport const gatherRadius = (bevelDp: number) =>\n clamp(Math.max(bevelDp, 1) * DERIVE.gatherPerBevel, DERIVE.gatherMinDp, DERIVE.gatherMaxDp);\n\n/**\n * The body's own density from absorption through its thickness. Small: glass has no color of its\n * own, the body only moves toward the tint under the legibility requirement (HIG \"Color\"),\n * otherwise it dims the content.\n */\nexport const bodyDensity = (thicknessDp: number) =>\n DERIVE.bodyDensity * absorption(thicknessDp);\n\n/**\n * Highlight normalization. `fresnelStrength`'s ×17.5 factor is tuned for the rim highlight's\n * visibility and saturates at one for dense media; applying it to the highlight too would raise\n * body lightness harder than the glass had just separated it from the ink — eating its own\n * legibility work. This uses the physical scale instead.\n */\n/** How much the rim picks up the light and color of its surroundings. The same reflectance as\n * Fresnel: no separate knob — a dense medium returns more of its surroundings by construction. */\n\nexport const edgeLight = (ior: number) => clamp01(fresnelF0(ior) * DERIVE.edgeLightGain);\n\n/**\n * THE SPECTRAL PART. Three phenomena — dispersion, diffraction and interference — share one\n * cause: index of refraction and phase both depend on wavelength. So there are no separate\n * \"rainbow strength\" knobs here: everything is derived from the medium's density and film\n * thickness.\n */\n\n/**\n * Rim iridescence is visible exactly as much as the REFLECTION is bright: interference lives in\n * the reflected ray, not the transmitted one. Hence the tie to Fresnel — there's no strength knob\n * of its own.\n */\nexport const iridescence = (ior: number, filmNm: number) =>\n filmNm <= 0 ? 0 : clamp01(fresnelStrength(ior) * DERIVE.iridescencePerFresnel);\n\n/**\n * Edge diffraction. Same λ-dependence as dispersion, so it shares its strength; the bevel sets\n * the fringe frequency — wide bevels give sparse fringes, sharp ones frequent (in the shader this\n * is divided by bevel width). The 0.5 normalization reflects the stylized render: at the physical\n * amplitude the fringes aren't visible at all.\n */\nexport const diffraction = (ior: number) =>\n clamp01(dispersion(ior) * DERIVE.diffractionPerDispersion);\n\n/**\n * How much the body picks up the COLOR of its surroundings. This is multiple internal reflection:\n * the denser the medium, the more light it circulates inside itself, and the more strongly it's\n * tinted by what's around it. The ceiling is deliberately low — the tint has to stay a medium, not\n * become a flat color fill.\n */\nexport const colorPickup = (ior: number) =>\n clamp(fresnelStrength(ior) * DERIVE.colorPickupPerFresnel, 0, DERIVE.colorPickupMax);\n","// VireGlass material model.\n//\n// Two distinct objects, and they must not be confused:\n//\n// VireGlassMaterial — CAUSES. What a piece of glass is described by: index of refraction,\n// thickness, bevel width, roughness, absorption color. This is what gets\n// configured.\n// VireGlassOptics — EFFECTS. Eighteen values the shaders need. Not configured: they're\n// derived (`resolveOptics`, physics in `optics.ts`).\n//\n// Before v4, what was exposed were the effects themselves — eighteen independent sliders. Half of\n// them are physically dependent, so combining them produced states that don't occur in real\n// glass: a thin bevel with a dense white rim, rim optics as a fraction of the element's own size.\n// Every such case was patched by adding yet another slider (`edgeDensity`, a size compensation) —\n// that is, compensating for physics that wasn't there. Here there's one cause, and the effects\n// are derived.\n\nimport {\n absorption,\n blur as blurFrom,\n dispersion as dispersionFrom,\n edgeDensity as edgeDensityFrom,\n gatherRadius as gatherRadiusFrom,\n fresnelStrength,\n FRESNEL_EXPONENT,\n mediumTint,\n refractionScale as refractionScaleFrom,\n refractionStrength,\n specularPower as specularPowerFrom,\n bodyDensity as bodyDensityFrom,\n edgeLight as edgeLightFrom,\n iridescence as iridescenceFrom,\n diffraction as diffractionFrom,\n colorPickup as colorPickupFrom,\n specularStrength,\n iorSpread as iorSpreadFrom,\n} from './optics';\n\nexport type VireGlassTint = { r: number; g: number; b: number };\n\nexport type VireGlassMaterial = {\n /** Index of refraction of the medium. Water 1.33, glass 1.5, sapphire 1.77. */\n ior: number;\n /** Glass thickness, dp. Drives center magnification and absorption. */\n thickness: number;\n /** Bevel width, dp. Absolute: on real glass the rim doesn't depend on the piece's size. */\n bevel: number;\n /** Surface roughness: backdrop haziness and highlight blur. */\n roughness: number;\n /** Response to device orientation, 0 means the light is locked to the screen. */\n environment: number;\n /** Not physics but a legibility requirement: how strongly the glass has to separate its own\n * lightness from the ink drawn over it. 0 means the glass is simply transparent. */\n legibility: number;\n /** Dimming layer UNDER the glass, 0..1. For the transparent (Clear) variant this is what\n * provides legibility: that glass has no adaptation, and without dimming the ink drowns over\n * bright content.\n *\n * Not to be confused with the mobile surface's `dim` prop: that one compensates for a platform\n * capture quirk (BlurView can't see a scrim drawn over the content), while this is a property\n * of the material itself. */\n dimming: number;\n /** Lightness of what the app draws OVER the glass: 1 is light icons and text, 0 is dark. A\n * cause, not a knob: the calling screen knows it. */\n ink: number;\n /** Minimum PRESENCE of the element itself: how far its body must stand off in lightness from\n * the backdrop behind it. Not the same as `legibility` — that's about the ink OVER the glass,\n * this is about the element itself. Over a uniform backdrop the glass has nothing to refract,\n * and the element disappears; for a control that's unacceptable. 0 means no presence is\n * required.\n *\n * The sign is taken FROM THE BACKDROP, not from ink polarity: over dark the body lightens,\n * over light it darkens. So the requirement works the same way on any backdrop. */\n presence: number;\n /** Surface film thickness, nm. This is where interference comes from: the optical path\n * difference in the film becomes comparable to the wavelength, and the reflection picks up\n * iridescence. 0 means no film. */\n film: number;\n};\n\nexport const MATERIAL_RANGES = {\n ior: [1, 2],\n thickness: [0, 60],\n bevel: [0, 40],\n roughness: [0, 1],\n environment: [0, 1],\n legibility: [0, 1],\n dimming: [0, 0.5],\n ink: [0, 1],\n presence: [0, 0.6],\n film: [0, 900],\n} as const satisfies Record<string, readonly [number, number]>;\n\nexport type VireGlassNumericKey = keyof typeof MATERIAL_RANGES;\n\n/** Radius over which the LOCAL backdrop lightness is taken, dp. Not per-pixel: otherwise the\n * glass chases individual strokes and a halo appears around letters beneath it. */\nexport const ADAPT_RADIUS = 22;\n\n/** Lens dimming on product surfaces — a flat fill over the backdrop. */\nexport const PRODUCT_DIM = 0.2;\n\nconst clamp = (v: number, lo: number, hi: number) => (v < lo ? lo : v > hi ? hi : v);\n\n/** The values the shaders need. Assembled from the material, never set by hand. */\nexport type VireGlassOptics = {\n blur: number;\n refraction: number;\n refractionScale: number;\n /** Bevel width in dp — an absolute property of the medium. */\n bevelDp: number;\n /** Radius over which the rim gathers light around the element. */\n gatherRadiusDp: number;\n fresnel: number;\n fresnelPower: number;\n specular: number;\n specularPower: number;\n dispersion: number;\n tint: VireGlassTint;\n tintStrength: number;\n edgeDensity: number;\n environment: number;\n legibility: number;\n /** Dimming of the content under the glass — the very layer of the Clear variant. */\n dimming: number;\n ink: number;\n /** Minimum presence of the element against the backdrop — in units of lightness. */\n presence: number;\n adaptRadius: number;\n bodyDensity: number;\n edgeLight: number;\n /** Film thickness, nm — passed straight to the shader: the path difference is computed in the\n * same units. */\n film: number;\n /** Strength of reflection iridescence. */\n iridescence: number;\n /** Strength of the edge diffraction fringes. */\n diffraction: number;\n /** How much the body is tinted by the color of its surroundings. */\n colorPickup: number;\n /** Index of refraction: the shader computes ray bending from it via Snell's law. */\n ior: number;\n /** Plate thickness, dp — before the correction for element size. */\n thicknessDp: number;\n /** Spread of the index between the red and blue channels — dispersion. */\n iorSpread: number;\n};\n\n// The product default — \"water\": lower index of refraction, thinner medium and bevel, an almost\n// smooth surface. Chosen on-device at the bench.\nexport const VIREGLASS_MATERIAL_V4: VireGlassMaterial = {\n ior: 1.33,\n thickness: 14,\n bevel: 5,\n roughness: 0.05,\n environment: 0.27,\n legibility: 0.26,\n dimming: 0,\n ink: 1,\n presence: 0.05,\n film: 340,\n};\n\n\n/**\n * Glass, not water. v4's index of refraction, 1.33, is water: almost no reflection at the rim,\n * almost no dispersion, 2% magnification. On screen that surface honestly reads as \"nothing much\",\n * and it was being mistaken for glass that wasn't rendering at all.\n *\n * 1.5 is ordinary glass. The effects follow from it on their own: reflection at the rim twice as\n * strong, dispersion one and a half times, ambient color pickup at its ceiling. Thickness is\n * raised a little too: it drives magnification, but absorption comes along with it, and\n * absorption is blackness.\n */\nexport const VIREGLASS_MATERIAL_V5: VireGlassMaterial = {\n ior: 1.5,\n thickness: 28,\n bevel: 6,\n roughness: 0.06,\n environment: 0.27,\n legibility: 0.26,\n dimming: 0,\n ink: 1,\n presence: 0.05,\n film: 340,\n};\n\n/**\n * Frosted sheet glass. The sheet sits over a LIVE screen, and it can't be transparent: transport\n * buttons and progress used to read right through it — the layout looked broken. Dimming doesn't\n * fix this (a flat scrim over a sharp picture doesn't hide it), so roughness is raised instead: it\n * drives `u_frost`, a floor on backdrop blur that the adaptive-blur ceiling doesn't reach.\n */\nexport const VIREGLASS_SHEET_MATERIAL: VireGlassMaterial = {\n ...VIREGLASS_MATERIAL_V5,\n roughness: 0.85,\n};\n/** The product's material. Consumers use this, not a specific version by name. */\n/**\n * Glass under large text (the lyrics panel in the player).\n *\n * The product material with NO change to optics — only `legibility` is raised. That's exactly its\n * reason to exist: \"text on me must stay readable.\" It adds density locally — denser over light\n * and busy backdrops, more transparent over an even dark one.\n *\n * A dedicated thick material (thickness 52, ior 1.58) used to sit here and was removed: medium\n * absorption grows with thickness, and the panel picked up a black fringe around its perimeter —\n * a sooty plate instead of glass. Don't turn thickness into a legibility knob; that's what\n * `legibility` is for.\n */\nexport const VIREGLASS_LYRICS_MATERIAL: VireGlassMaterial = {\n ...VIREGLASS_MATERIAL_V5,\n legibility: 0.95,\n};\n\n/**\n * Glass for controls — buttons, tiles, anything that gets pressed.\n *\n * THICK AND CLEAR, not the baseline: wider bevel, thickness up by half, higher index of\n * refraction and almost no roughness. Baseline glass is a lens over a calm backdrop; a control has\n * to read as an object you can pick up, and that's not done by a fill but by volume: a wide bevel\n * gives the rim something to catch, and thickness gives it depth.\n *\n * Thickness is set by BUILDUP AT THE RIM: on the reference control the stripe image under the\n * element bulges there by a factor of 1.85; ours came out at 1.36 at 30. Saturation sets in around\n * 44, and any extra thickness past that only adds absorption — hence 44, not more.\n *\n * It also drags `tintStrength` (= `absorption(thickness)`) along with it, and on the path WITHOUT\n * a native lens that sets body density: there the element is denser by 2.4 percentage points. On\n * the web the surface has no body at all; the effect only shows on Android below 13.\n *\n * `presence` is raised for the same reason: a piece of background is allowed to disappear over a\n * uniform canvas, a control isn't — it has to be visible before it's been tapped.\n *\n * IMPORTANT about size. The bevel is specified by the medium in dp and doesn't depend on the\n * element's size, but the geometry clamps it to half the smaller half-size (`MAX_BEVEL_FRACTION`).\n * On a 52 dp button that's 13 instead of 16 — a small element made of this glass ends up being\n * bevel all the way through. That's by design: a small piece of thick glass is supposed to look\n * like a lens, not a slab.\n */\nexport const VIREGLASS_CONTROL_MATERIAL: VireGlassMaterial = {\n ...VIREGLASS_MATERIAL_V5,\n ior: 1.69,\n thickness: 44,\n bevel: 8,\n roughness: 0.035,\n presence: 0.176,\n};\n\nexport const VIREGLASS_MATERIAL = VIREGLASS_MATERIAL_V5;\n\n/**\n * An element that CARRIES app ink (an icon, a line of text, cover art) has to keep it legible —\n * that's the reason `legibility` exists. An element with no ink has nothing to separate lightness\n * from, so the requirement is turned off for it: the model just promises it plain transparent\n * glass.\n *\n * The rule lives here, not with the consumer: otherwise the same icon button would get different\n * legibility on the web and on Android.\n */\nexport function materialForInk(material: VireGlassMaterial, carriesInk: boolean): VireGlassMaterial {\n // For the transparent variant, legibility is held by the dimming layer, not the body. Raising\n // its requirement would just turn it into ordinary glass, and the variants don't mix (219 §Clear).\n if (material.dimming > 0) return material;\n return { ...material, legibility: carriesInk ? VIREGLASS_LYRICS_MATERIAL.legibility : 0 };\n}\n\n/**\n * The transparent material variant (Clear). It has no adaptation — the glass stays consistently\n * more transparent, content beneath it shows through almost as-is, and legibility of the ink is\n * held by the dimming layer instead. Fit only where the reference's three conditions hold: the\n * element sits over media, the content can tolerate dimming, and the ink over it is large and\n * bright.\n */\nexport const VIREGLASS_CLEAR_MATERIAL: VireGlassMaterial = {\n ...VIREGLASS_MATERIAL,\n legibility: 0,\n presence: 0,\n // Apple's own numbers: 0.35 in the HIG Materials text, 0.3 in its own sample code. We take the\n // lower one — it comes from working code, not from prose, and Clear has to stay a window.\n dimming: 0.3,\n};\n\n/**\n * ACTIVE STATE as a state of the MEDIUM, not a highlight drawn over it.\n *\n * An active element is denser, clearer glass: higher index of refraction, thicker body, wider\n * bevel, less roughness. A bright rim, a strong highlight and greater presence all follow from\n * these causes on their own — assembling them separately would produce a state that doesn't occur\n * in real glass.\n *\n * `environment` is deliberately left untouched here. It sets how much the body is tinted by\n * what's beneath it, and at full strength an active button over cover art turned into a colored\n * blob: the state read as \"smudged\" rather than \"selected.\" A state indicator must not depend on\n * the backdrop — otherwise any image sliding underneath the element would fake it.\n */\nexport function activeMaterial(material: VireGlassMaterial, on: number): VireGlassMaterial {\n const k = Math.min(Math.max(on, 0), 1);\n return {\n ...material,\n ior: material.ior + 0.35 * k,\n thickness: material.thickness * (1 + 0.9 * k),\n bevel: material.bevel * (1 + 1.8 * k),\n roughness: material.roughness * (1 - 0.75 * k),\n presence: material.presence + 0.12 * k,\n };\n}\n\nexport function resolveMaterial(patch: Partial<VireGlassMaterial> = {}): VireGlassMaterial {\n const m = { ...VIREGLASS_MATERIAL, ...patch };\n const out = { ...m };\n for (const key of Object.keys(MATERIAL_RANGES) as VireGlassNumericKey[]) {\n const [lo, hi] = MATERIAL_RANGES[key];\n out[key] = clamp(out[key], lo, hi);\n }\n return out;\n}\n\n/** Causes → effects. All of the transition's physics lives in `optics.ts`. */\nexport function resolveOptics(patch: Partial<VireGlassMaterial> = {}): VireGlassOptics {\n const m = resolveMaterial(patch);\n return {\n blur: blurFrom(m.roughness),\n refraction: refractionStrength(m.ior),\n refractionScale: refractionScaleFrom(m.ior, m.thickness),\n bevelDp: m.bevel,\n gatherRadiusDp: gatherRadiusFrom(m.bevel),\n fresnel: fresnelStrength(m.ior),\n fresnelPower: FRESNEL_EXPONENT,\n specular: specularStrength(m.ior, m.roughness),\n specularPower: specularPowerFrom(m.roughness),\n dispersion: dispersionFrom(m.ior),\n tint: mediumTint(m.ior),\n tintStrength: absorption(m.thickness),\n edgeDensity: edgeDensityFrom(m.thickness, m.bevel),\n environment: m.environment,\n legibility: m.legibility,\n dimming: m.dimming,\n ink: m.ink,\n presence: m.presence,\n adaptRadius: ADAPT_RADIUS,\n bodyDensity: bodyDensityFrom(m.thickness),\n edgeLight: edgeLightFrom(m.ior),\n film: m.film,\n iridescence: iridescenceFrom(m.ior, m.film),\n diffraction: diffractionFrom(m.ior),\n colorPickup: colorPickupFrom(m.ior),\n ior: m.ior,\n thicknessDp: m.thickness,\n iorSpread: iorSpreadFrom(m.ior),\n };\n}\n\n/**\n * Frozen snapshots of the EFFECTS from the previous model. Kept as reference points until v4\n * settles: they can't be converted to causes — some of the values are internally inconsistent\n * (exactly why the move was made in the first place), and any \"equivalent\" material would be a\n * lie.\n */\nexport const LEGACY_OPTICS = {\n 'v3-manual': {\n blur: 4.32,\n refraction: 0.49,\n refractionScale: 1.05,\n bevelDp: 12.6,\n gatherRadiusDp: 40,\n fresnel: 0.77,\n fresnelPower: 2.86,\n specular: 0.3,\n specularPower: 74.58,\n dispersion: 0.54,\n tint: { r: 0.4, g: 0.4, b: 0.44 },\n tintStrength: 0.35,\n edgeDensity: 1.5,\n environment: 0.27,\n legibility: 0.55,\n dimming: 0,\n ink: 1,\n presence: 0,\n adaptRadius: ADAPT_RADIUS,\n bodyDensity: 0.14,\n edgeLight: 0.35,\n film: 0,\n iridescence: 0,\n diffraction: 0,\n colorPickup: 0,\n ior: 1.5,\n thicknessDp: 16,\n iorSpread: 0,\n },\n 'v2': {\n blur: 5,\n refraction: 0.95,\n refractionScale: 1.34,\n bevelDp: 14,\n gatherRadiusDp: 40,\n fresnel: 0.72,\n fresnelPower: 2.4,\n specular: 0.38,\n specularPower: 46,\n dispersion: 0.3,\n tint: { r: 0.4, g: 0.4, b: 0.44 },\n tintStrength: 0.1,\n edgeDensity: 3.63,\n environment: 0,\n legibility: 0,\n dimming: 0,\n ink: 1,\n presence: 0,\n adaptRadius: ADAPT_RADIUS,\n bodyDensity: 0.14,\n edgeLight: 0.35,\n film: 0,\n iridescence: 0,\n diffraction: 0,\n colorPickup: 0,\n ior: 1.5,\n thicknessDp: 16,\n iorSpread: 0,\n },\n 'v1': {\n blur: 12,\n refraction: 0.55,\n refractionScale: 1.14,\n bevelDp: 10,\n gatherRadiusDp: 40,\n fresnel: 0.5,\n fresnelPower: 3.2,\n specular: 0.42,\n specularPower: 58,\n dispersion: 0.22,\n tint: { r: 0.4, g: 0.4, b: 0.44 },\n tintStrength: 0.16,\n edgeDensity: 3.63,\n environment: 0,\n legibility: 0,\n dimming: 0,\n ink: 1,\n presence: 0,\n adaptRadius: ADAPT_RADIUS,\n bodyDensity: 0.14,\n edgeLight: 0.35,\n film: 0,\n iridescence: 0,\n diffraction: 0,\n colorPickup: 0,\n ior: 1.5,\n thicknessDp: 16,\n iorSpread: 0,\n },\n} as const satisfies Record<string, VireGlassOptics>;\n\nexport type LegacyOpticsName = keyof typeof LEGACY_OPTICS;\nexport const LEGACY_NAMES = Object.keys(LEGACY_OPTICS) as LegacyOpticsName[];\n\n/** Material presets: points in the space of CAUSES, not a set of ready-made effects. */\nexport const MATERIAL_PRESETS = {\n water: VIREGLASS_MATERIAL_V4,\n glass: { ...VIREGLASS_MATERIAL_V4, ior: 1.45, thickness: 25, bevel: 12.6, roughness: 0.17 },\n crystal: { ...VIREGLASS_MATERIAL_V4, ior: 1.7, thickness: 30, bevel: 16, roughness: 0.02 },\n frosted: { ...VIREGLASS_MATERIAL_V4, roughness: 0.55 },\n thick: { ...VIREGLASS_MATERIAL_V4, thickness: 48, bevel: 22 },\n thin: { ...VIREGLASS_MATERIAL_V4, thickness: 4, bevel: 3 },\n iridescent: { ...VIREGLASS_MATERIAL_V4, ior: 1.5, thickness: 8, bevel: 6, film: 620 },\n} as const satisfies Record<string, VireGlassMaterial>;\n\nexport type MaterialPresetName = keyof typeof MATERIAL_PRESETS;\nexport const PRESET_NAMES = Object.keys(MATERIAL_PRESETS) as MaterialPresetName[];\n\nexport const EFFECTS = [\n 'backdrop',\n 'blur',\n 'refraction',\n 'fresnel',\n 'bevel',\n 'specular',\n 'dispersion',\n 'tint',\n 'environment',\n 'legibility',\n 'interference',\n 'diffraction',\n] as const;\n\nexport type VireGlassEffect = (typeof EFFECTS)[number];\nexport type VireGlassToggles = Record<VireGlassEffect, boolean>;\n\nexport const ALL_EFFECTS_ON: VireGlassToggles = EFFECTS.reduce(\n (acc, e) => ({ ...acc, [e]: true }),\n {} as VireGlassToggles,\n);\n\n/**\n * A toggle zeroes out an EFFECT, it isn't a branch in the shader: the ON/OFF comparison runs on\n * one shader variant, otherwise two different programs would be getting compared. It operates on\n * optics, not on the material: a cause can't be zeroed out — it drags half a dozen effects along\n * with it. `backdrop` isn't handled by a toggle here: it decides whether to mount the BlurView at\n * all.\n */\nexport function applyToggles(\n optics: VireGlassOptics,\n toggles: Partial<VireGlassToggles> = {},\n): VireGlassOptics {\n const on = { ...ALL_EFFECTS_ON, ...toggles };\n const o = { ...optics, tint: { ...optics.tint } };\n if (!on.blur) o.blur = 0;\n if (!on.refraction) {\n o.refraction = 0;\n o.refractionScale = 1;\n o.ior = 1;\n }\n if (!on.fresnel) o.fresnel = 0;\n if (!on.bevel) o.bevelDp = 1;\n if (!on.specular) o.specular = 0;\n if (!on.dispersion) {\n o.dispersion = 0;\n o.iorSpread = 0;\n }\n if (!on.tint) o.tintStrength = 0;\n if (!on.environment) o.environment = 0;\n if (!on.legibility) {\n o.legibility = 0;\n // The dimming layer is the same answer to the legibility requirement, just for the\n // transparent variant.\n o.dimming = 0;\n }\n if (!on.interference) o.iridescence = 0;\n if (!on.diffraction) o.diffraction = 0;\n return o;\n}\n\n/** Order = the `u_debug` value in both shaders. Bench-only. */\nexport const DEBUG_MODES = [\n 'normal',\n 'sdf',\n 'mask',\n 'edge',\n 'fresnel',\n 'refraction',\n 'backdrop',\n 'specular',\n 'dispersion',\n 'normals',\n 'spectral',\n 'adapt',\n 'probe',\n] as const;\n\nexport type VireGlassDebugMode = (typeof DEBUG_MODES)[number];\n\nexport function debugIndex(mode: VireGlassDebugMode): number {\n return DEBUG_MODES.indexOf(mode);\n}\n","// The single description of VireGlass geometry. Both shaders draw it from here: the SKSL surface\n// (`surface-shader.ts`) and the AGSL lens (`lens-shader.ts`, shipped as a string into the native\n// view). AGSL and SKSL are the same language, so the SDF no longer needs duplicating in Kotlin:\n// before, the surface's circle and the lens's rounded rectangle described different pieces of\n// glass, and the bevel constant had to be kept in sync by hand (docs/adr-001-rendering.md §3).\nimport { BEVEL, EPSILON, TOUCH } from './law';\n\n/** 2π. Structural, not a law — but the shader has no built-in for it. */\nconst VG_TAU = 6.28318530718;\n\nexport const VG_SDF = `\nfloat vgRoundRect(float2 p, float2 halfSize, float corner) {\n float2 q = abs(p) - halfSize + corner;\n return min(max(q.x, q.y), 0.0) + length(max(q, float2(0.0))) - corner;\n}\n\nfloat vgSmin(float a, float b, float k) {\n float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);\n return mix(b, a, h) - k * h * (1.0 - h);\n}\n\n// A scene is a single shape, and when k > 0 a smooth union with one or two neighbors. A third\n// shape exists to break the control into pieces (docs/reference.md §5): there are two bridges\n// there. It's turned off with a zero size, not its own k: the fused body shares one bridge.\nfloat vgScene(float2 p, float2 halfSize, float corner,\n float2 offsetB, float2 halfB, float cornerB, float k,\n float2 offsetC, float2 halfC, float cornerC) {\n float a = vgRoundRect(p, halfSize, corner);\n if (k <= 0.0) { return a; }\n float ab = vgSmin(a, vgRoundRect(p - offsetB, halfB, cornerB), k);\n if (halfC.x <= 0.0) { return ab; }\n return vgSmin(ab, vgRoundRect(p - offsetC, halfC, cornerC), k);\n}\n\n// Response to a finger. It's the FIELD around the touch point that deforms, not the shape's\n// bounding box: scaling width to pull the right edge would also pull the left one — liquid\n// doesn't behave that way. Here the displacement falls off with distance from the finger, so the\n// far edge stays put.\n//\n// The order of the terms matters: drag shifts the field, press pulls it toward the finger, the\n// wave rides on top of the already-shifted field — otherwise the ripple decouples from the\n// deformation and lives a life of its own.\nfloat2 vgTouchWarp(float2 p, float2 touch, float2 pull, float press, float radius,\n float waveAmp, float wavePhase) {\n if (radius <= 0.0) { return p; }\n // Under the finger the whole element grows (M 3:51; HIG: interactive \"expands\").\n p /= 1.0 + ${TOUCH.pressGrow} * press;\n float2 d = p - touch;\n float r = length(d);\n\n // The finger is a BLOB, not a point, but not a hard stamp either: a wide peak, soft edges. A\n // flat plateau with a sharp cutoff at the edge shifts the region as a block, and a straight\n // line under the glass breaks into a step — the deformation reads as rectangular even though\n // the finger is round. A double smoothstep gives the same contact width without that step.\n //\n // The influence cuts off at the radius rather than fading into an infinite tail like a\n // Gaussian: with a tail the deformation spreads into a \"rubber mattress\" bulge.\n float k = clamp((radius - r) / radius, 0.0, 1.0);\n float s = k * k * (3.0 - 2.0 * k);\n float core = s * s * (3.0 - 2.0 * s);\n // A ring around the blob: material displaced from under the finger has to end up somewhere.\n // Without this ridge the shape just balloons, and a dense medium doesn't behave that way.\n float rim = k * k * (1.0 - k) * 4.0;\n\n float2 q = p - pull * (core - ${TOUCH.ridge} * rim);\n q -= d * (press * ${TOUCH.pressPull} * core);\n\n // The wave has its own scale, twice the drag radius: the ripple has to reach the far edge,\n // otherwise it reads as jitter under the finger rather than a wave across the surface. The\n // wavelength is short: in a dense medium ripples are frequent and small, long shallow swells\n // are water.\n if (waveAmp > 0.0 && r > 0.0001) {\n float span = radius * ${TOUCH.waveSpan}.0;\n float ring = sin(r / (span * ${TOUCH.waveLength}) - wavePhase * ${VG_TAU}) * exp(-r / (span * ${TOUCH.waveDecay}));\n q -= (d / r) * ring * waveAmp;\n }\n return q;\n}\n\n// Analytical normal of a single shape: radial on the rounded part, axis-aligned on the straight\n// segments.\nfloat2 vgRoundRectNormal(float2 p, float2 halfSize, float corner) {\n float2 q = abs(p) - halfSize + corner;\n float2 g = (q.x > 0.0 && q.y > 0.0)\n ? normalize(max(q, float2(0.0001)))\n : (q.x > q.y ? float2(1.0, 0.0) : float2(0.0, 1.0));\n return g * sign(p);\n}\n\n// Normal of the union — ANALYTICAL, no more finite differences here.\n//\n// Derivation: smin has two terms, mix(b,a,h) and −k·h·(1−h). Their derivatives with respect to h\n// contain a factor of (1−2h) with opposite signs and cancel exactly, because h is linear in\n// (b−a)/k. What's left is mix(∇b, ∇a, h) — that is, the two shapes' normals, blended with the\n// same weight that blends the distances themselves.\n//\n// The previous version took four ADDITIONAL scene evaluations per pixel (each one — two shapes\n// plus smin) and was still an approximation. Here there are two shapes, exactly.\nfloat2 vgSceneNormal(float2 p, float2 halfSize, float corner,\n float2 offsetB, float2 halfB, float cornerB, float k,\n float2 offsetC, float2 halfC, float cornerC) {\n float2 na = vgRoundRectNormal(p, halfSize, corner);\n if (k <= 0.0) { return na; }\n float2 q = p - offsetB;\n float a = vgRoundRect(p, halfSize, corner);\n float b = vgRoundRect(q, halfB, cornerB);\n float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);\n float2 nab = normalize(mix(vgRoundRectNormal(q, halfB, cornerB), na, h) + float2(${EPSILON}, ${EPSILON}));\n if (halfC.x <= 0.0) { return nab; }\n // Same derivation as for the pair: normals blend with the same weight as the distances.\n float2 qc = p - offsetC;\n float ab = vgSmin(a, b, k);\n float c = vgRoundRect(qc, halfC, cornerC);\n float hc = clamp(0.5 + 0.5 * (c - ab) / k, 0.0, 1.0);\n return normalize(mix(vgRoundRectNormal(qc, halfC, cornerC), nab, hc) + float2(${EPSILON}, ${EPSILON}));\n}\n\n// Position within the bevel: 0 is the flat middle, 1 is the very edge. This one value feeds the\n// mask, thickness, refraction, aberrations and the width of the light rim.\nfloat vgBevelT(float sd, float bevel) {\n return clamp((sd + bevel) / bevel, 0.0, 1.0);\n}\n\n// Slope of the bevel profile — spherical: t / sqrt(1 - t²), like a spherical cap. The previous t²\n// kept the slope near zero through almost the whole bevel and then shot up right at the edge, so\n// all the optics bunched into a narrow ring and the element read as a PUCK — a flat top and a\n// wall around the rim. Here curvature is spread across the bevel, and the rim stops being a line.\n//\n// This still doesn't control the field of view: only the bevel bends, the middle stays flat,\n// otherwise the surface reads as a soap bubble.\nfloat vgBevelSlope(float t) {\n return min(t * inversesqrt(max(1.0 - t * t * ${BEVEL.sphere}, ${BEVEL.floor})), ${BEVEL.slopeMax});\n}\n\n// PROGRESS FRACTION. Progress is an active state turned into a FIELD: to the left of the boundary\n// the element is active, to the right it stays regular glass, and the boundary moves. A negative\n// value turns the field off entirely — zero is taken by the start of the track and can't also\n// mean off.\n//\n// The boundary is SOFT. A hard seam reads as two different materials glued together rather than\n// two states of one; the transition width is a fraction of the half-width, so it doesn't read as\n// a thread on a large element and doesn't swallow a small one whole.\nfloat vgProgress(float2 p, float2 halfSize, float progress) {\n if (progress < 0.0) { return 0.0; }\n float edge = mix(-halfSize.x, halfSize.x, clamp(progress, 0.0, 1.0));\n float soft = max(halfSize.x * 0.05, 1.0);\n return 1.0 - smoothstep(edge - soft, edge + soft, p.x);\n}\n`;\n\n/** Rate at which the offset builds toward the rim. Shared between the lens (actual sampling\n * offset) and the surface (visualizing the displacement field in debug mode) — otherwise they'd\n * drift apart. */\nexport const VG_FALLOFF = 2.6;\n\n// JS twin of `vgRoundRect`/`vgRoundRectNormal` above, for targets with no GPU to run the shader on\n// (the DOM displacement map). Term-for-term against the GLSL text: a second geometry that behaves\n// differently is exactly the class of bug `check:optics` exists to catch on the shader side, and\n// there is no such gate for this one.\n\n/** Signed distance from `(x, y)` to a rounded rect of size `w`×`h` centered on the origin. */\nexport function sdfRoundedRect(x: number, y: number, w: number, h: number, r: number): number {\n const qx = Math.abs(x) - w / 2 + r;\n const qy = Math.abs(y) - h / 2 + r;\n return Math.min(Math.max(qx, qy), 0) + Math.hypot(Math.max(qx, 0), Math.max(qy, 0)) - r;\n}\n\n/**\n * Closed-form gradient of `sdfRoundedRect`, unit length everywhere except the exact center (where\n * it's genuinely undefined — the medial axis of the shape). NOT finite differences: differencing\n * quantizes the gradient to the sampling step, and the displacement map needs sub-pixel accuracy\n * right at the rim.\n */\nexport function sdfRoundedRectGradient(x: number, y: number, w: number, h: number, r: number): [number, number] {\n const qx = Math.abs(x) - w / 2 + r;\n const qy = Math.abs(y) - h / 2 + r;\n let gx: number;\n let gy: number;\n if (qx > 0 && qy > 0) {\n const cx = Math.max(qx, 0.0001);\n const cy = Math.max(qy, 0.0001);\n const len = Math.hypot(cx, cy);\n gx = cx / len;\n gy = cy / len;\n } else if (qx > qy) {\n gx = 1;\n gy = 0;\n } else {\n gx = 0;\n gy = 1;\n }\n return [gx * Math.sign(x), gy * Math.sign(y)];\n}\n\n// ---------------------------------------------------------------------------\n// JS twins of the shader functions above. The DOM renderer needs this geometry\n// as numbers, not as a string it hands to a compiler. Each mirrors its `vg*`\n// counterpart term for term — a second geometry that drifts is the failure the\n// platform-parity gate exists to catch.\n// ---------------------------------------------------------------------------\n\n/** Mirrors `vgSmin`. */\nexport function smin(a: number, b: number, k: number): number {\n const h = Math.min(Math.max(0.5 + (0.5 * (b - a)) / k, 0), 1);\n return b + (a - b) * h - k * h * (1 - h);\n}\n\n/**\n * The smallest `k` at which `smin` joins two surfaces `gap` apart into one body. Exact for this\n * smin rather than fitted: at the midpoint the two distances are both gap/2, so h = 0.5 and the\n * result is gap/2 − k/4, which reaches zero at k = 2·gap.\n *\n * It is the number `morphBetween` was missing. A neck sized only as a fraction of the element's\n * own half-size has nothing to do with the distance it has to span, so two controls a hundred\n * pixels apart stayed two controls at every t — including t = 1, where the contract says they are\n * one shared medium.\n */\nexport function neckToBridge(gap: number): number {\n return gap > 0 ? gap * 2 : 0;\n}\n\nexport type MorphShape = {\n offsetX: number;\n offsetY: number;\n width: number;\n height: number;\n cornerRadius: number;\n};\n\n/**\n * Mirrors the scene distance: one shape, smoothly unioned with any number of neighbours when\n * `smoothing` is positive. §5's merging and splitting are this union opening and closing.\n *\n * A fold, not a pair. The count used to be in the ARGUMENT NAMES — `b` and `c`, and a fourth\n * shape would have been `d` — which is not a limit the material has. Several independent elements\n * flowing into one whole is the behaviour; how many of them there happen to be is the host's.\n */\nexport function sceneDistance(\n x: number,\n y: number,\n w: number,\n h: number,\n r: number,\n smoothing = 0,\n ...shapes: (MorphShape | undefined)[]\n): number {\n let d = sdfRoundedRect(x, y, w, h, r);\n if (smoothing <= 0) return d;\n for (const s of shapes) {\n if (!s || s.width <= 0) continue;\n d = smin(d, sdfRoundedRect(x - s.offsetX, y - s.offsetY, s.width, s.height, s.cornerRadius), smoothing);\n }\n return d;\n}\n\n/**\n * Mirrors `vgSceneNormal`: normals blend with the same weight that blends the distances, which the\n * shader derives rather than approximates. The same fold as `sceneDistance`, carrying the running\n * distance alongside the running normal because each step's weight is measured against it.\n */\nexport function sceneGradient(\n x: number,\n y: number,\n w: number,\n h: number,\n r: number,\n smoothing = 0,\n ...shapes: (MorphShape | undefined)[]\n): [number, number] {\n let d = sdfRoundedRect(x, y, w, h, r);\n let [gx, gy] = sdfRoundedRectGradient(x, y, w, h, r);\n let blended = false;\n if (smoothing > 0) {\n for (const s of shapes) {\n if (!s || s.width <= 0) continue;\n const sx = x - s.offsetX;\n const sy = y - s.offsetY;\n const ds = sdfRoundedRect(sx, sy, s.width, s.height, s.cornerRadius);\n const weight = Math.min(Math.max(0.5 + (0.5 * (ds - d)) / smoothing, 0), 1);\n const [nx, ny] = sdfRoundedRectGradient(sx, sy, s.width, s.height, s.cornerRadius);\n gx = nx + (gx - nx) * weight;\n gy = ny + (gy - ny) * weight;\n d = smin(d, ds, smoothing);\n blended = true;\n }\n }\n // With nothing blended in, the base gradient is already a unit vector and is returned untouched —\n // the shader takes the same early exit (`if (k <= 0.0) return na;`), and nudging it here instead\n // would put the two renderers a rounding step apart on every flat edge in the material.\n if (!blended) return [gx, gy];\n // The shader's `+ float2(${EPSILON}, ${EPSILON})` before normalising, and it is not decoration:\n // where two shapes meet head-on their normals cancel exactly and the blend lands on zero.\n gx += EPSILON;\n gy += EPSILON;\n const len = Math.hypot(gx, gy) || 1;\n return [gx / len, gy / len];\n}\n\nexport type TouchWarp = {\n x: number;\n y: number;\n pullX: number;\n pullY: number;\n press: number;\n radius: number;\n waveAmp: number;\n wavePhase: number;\n};\n\n/**\n * Mirrors `vgTouchWarp`. The FIELD around the finger deforms, not the bounding box: scaling the\n * width to pull the right edge would pull the left one too, and liquid does not do that.\n *\n * Term order is load-bearing — drag shifts the field, press pulls it toward the finger, the wave\n * rides on the already-shifted field. Reordered, the ripple decouples and lives its own life.\n */\nexport function touchWarp(x: number, y: number, t: TouchWarp): [number, number] {\n if (t.radius <= 0) return [x, y];\n const grow = 1 + TOUCH.pressGrow * t.press;\n let px = x / grow;\n let py = y / grow;\n const dx = px - t.x;\n const dy = py - t.y;\n const r = Math.hypot(dx, dy);\n\n const k = Math.min(Math.max((t.radius - r) / t.radius, 0), 1);\n const s = k * k * (3 - 2 * k);\n const core = s * s * (3 - 2 * s);\n // The ridge around the blob: material pushed out from under the finger has to go somewhere.\n const rim = k * k * (1 - k) * 4;\n\n px -= t.pullX * (core - TOUCH.ridge * rim);\n py -= t.pullY * (core - TOUCH.ridge * rim);\n px -= dx * (t.press * TOUCH.pressPull * core);\n py -= dy * (t.press * TOUCH.pressPull * core);\n\n if (t.waveAmp > 0 && r > 0.0001) {\n const span = t.radius * TOUCH.waveSpan;\n const ring = Math.sin(r / (span * TOUCH.waveLength) - t.wavePhase * VG_TAU) * Math.exp(-r / (span * TOUCH.waveDecay));\n px -= (dx / r) * ring * t.waveAmp;\n py -= (dy / r) * ring * t.waveAmp;\n }\n return [px, py];\n}\n","import { ACCENT, BODY, DISPERSION, LENS, MEDIUM, RIM, SPECTRAL } from './law';\nimport { VG_SDF } from './sdf';\n\n// The lens source is assembled HERE and ships to the native view as a prop: AGSL and SKSL are one\n// language, so the lens's and the surface's geometry are literally the same string (`VG_SDF`).\n//\n// Glass is a thick plate with a convex rounded edge (docs/reference.md §1). A ray from above\n// refracts at the top face and lands on the content shifted INWARD relative to the shape: the\n// middle isn't shifted, the rim shows what lies beneath the body of the element.\n//\n// Uniforms, apart from the view's own geometry, arrive over a SHARED CHANNEL (`adapters.ts` →\n// `uniformNames`/`uniformSizes`/`uniformValues`). There are no more separate Props per value:\n// those were exactly what let a typo silently turn the lens off (docs/material-lab.md E-01).\nexport const LENS_SHADER = `\nuniform shader content;\n\n// Known only to the view itself: its own size and its own place on screen.\nuniform float2 u_center;\nuniform float u_reach;\nuniform float2 u_contentMin;\nuniform float2 u_contentMax;\n// Backdrop estimate UNDER the glass from the native probe: lightness, variegation and average\n// color, already smoothed over time. Negative lightness means the probe hasn't reported yet —\n// fall back to our own samples.\nuniform float u_probeLuma;\nuniform float u_probeBusy;\n// The endpoints of the lightness range under the glass: right at a black/white border the\n// average reads as a gray that says \"everything's fine,\" while the ink drowns over the light\n// half.\nuniform float2 u_probeRange;\n// Slope of lightness across the surface, fraction per half-size: tinting is a gradient — one\n// density per element wouldn't separate the ink from both halves of the backdrop.\nuniform float2 u_probeSlope;\nuniform float3 u_probe;\n\n// Material — over the shared channel from JS, already in device pixels.\nuniform float2 u_halfSize;\nuniform float u_corner;\nuniform float u_bevel;\nuniform float u_thick;\nuniform float u_rim;\nuniform float u_ior;\nuniform float u_iorSpread;\nuniform float2 u_light;\nuniform float u_appear;\nuniform float4 u_accent;\nuniform float u_frost;\nuniform float u_ink;\nuniform float u_legibility;\nuniform float u_dim;\nuniform float u_presence;\nuniform float u_progress;\nuniform float u_adaptRadius;\nuniform float u_bodyDensity;\nuniform float u_edgeLight;\nuniform float u_fresnel;\nuniform float u_specular;\nuniform float u_reflectReach;\nuniform float u_film;\nuniform float u_iridescence;\nuniform float u_diffraction;\nuniform float u_colorPickup;\nuniform float2 u_morphOffset;\nuniform float2 u_morphHalf;\nuniform float u_morphCorner;\nuniform float u_morphK;\nuniform float2 u_morph2Offset;\nuniform float2 u_morph2Half;\nuniform float u_morph2Corner;\nuniform float u_debug;\nuniform float2 u_touch;\nuniform float2 u_pull;\nuniform float u_touchPress;\nuniform float u_touchRadius;\nuniform float2 u_wave;\n\n${VG_SDF}\n\n// Sample count for the disc gather: fewer than this reads as a staircase of copies at a sharp edge.\nconst int VG_FROST_TAPS = 20;\n// The sample count grows with the disc's area: estimator noise is the spread under the glass\n// divided by the square root of the sample count. The ceiling is cost: texture sampling is the\n// most expensive thing here.\nconst int VG_FROST_TAPS_MAX = 64;\n// The radius correction for backdrop compression at the rim is capped: at the silhouette it goes\n// to infinity.\nconst float VG_FOOTPRINT_MAX = ${LENS.footprintMax};\nconst float VG_TAU = 6.28318530718;\n// Ceiling on body lightness under light ink (and the mirrored floor under dark ink). This is a\n// ceiling, not a difference: \"0.14 darker than white\" is a lightness of 0.86, at which white text\n// is invisible.\nconst float VG_BODY_CAP_LOOSE = ${BODY.capLoose};\nconst float VG_BODY_CAP_TIGHT = ${BODY.capTight};\n// Tint lightness in both directions: real glass is never coal-black or paper-white.\nconst float VG_TINT_DARK = ${BODY.tintDark};\nconst float VG_TINT_LIGHT = ${BODY.tintLight};\n// Reference channel wavelengths, nm — for diffraction and interference.\nconst float3 VG_LAMBDA = float3(${LENS.lambdaR}.0, ${LENS.lambdaG}.0, ${LENS.lambdaB}.0);\n// Film index of refraction: every thin film on glass sits around this value.\nconst float VG_FILM_IOR = ${LENS.filmIor};\n// Ceiling on the profile's slope right at the silhouette: it goes to infinity there.\nconst float VG_SLOPE_MAX = ${LENS.slopeMax}.0;\n// Fraction of the gather radius that scattering reaches over a busy backdrop under ink (M 11:47).\n// Set against the reference: there, structure under the capsule fades by a factor of 9-10, not\n// thirty.\nconst float VG_SCATTER_MAX = ${MEDIUM.scatterMax};\nconst float VG_SCATTER_BASE = ${MEDIUM.scatterBase};\n// The response to structure under the glass saturates early: what competes with the ink isn't\n// the area of foreign text but the mere fact that it's there (a line under a tile gives a busy\n// of about 0.12).\nconst float VG_STRUCTURE_GAIN = ${MEDIUM.structureGain}.0;\n// How much denser the body with ink gets over a BUSY backdrop than over a calm one. There's no\n// flat floor here: legibility picks up its own targeted requirement further down, and base\n// frosting comes from VG_MATTE_LIFT.\nconst float VG_GROUND_SPAN = ${BODY.groundSpan};\n// Scattered light on a frosted element is an ADDITION on top of the backdrop, not a fraction of\n// the way to the tint: the fraction goes to zero once the canvas reaches the tint's lightness,\n// and darkens past it (docs/benchmarks.md).\nconst float VG_MATTE_LIFT = ${MEDIUM.matteLift};\n// The fraction of backdrop spread that survives through to the body past scattering: the\n// legibility requirement is computed from this edge, not from the spot's average lightness.\nconst float VG_BUSY_EDGE = ${BODY.busyEdge};\n// Light concentration: the body is a touch lighter than what's beneath it (M 2:29).\nconst float VG_CONCENTRATE = ${MEDIUM.concentrate};\n// The lightness the medium pulls content under the glass toward, and the strength of that pull.\n// The medium both removes light and mixes in scattered light: over a light backdrop the body\n// darkens, over a dark one it lightens.\nconst float VG_MEDIUM_LUMA = ${MEDIUM.luma};\nconst float VG_MEDIUM_PULL = ${MEDIUM.pull};\n// How much ambient light reaches the body on top of the pull.\nconst float VG_AMBIENT_SPILL = ${MEDIUM.ambientSpill};\n\nfloat vgLuma(float3 c) { return dot(c, float3(0.2126, 0.7152, 0.0722)); }\n\n// Un-premultiply into ordinary color. One division, done in float: near zero, half's step is too\n// coarse, and several divisions in a row raise noise.\nfloat3 vgUnpack(half4 c) {\n float a = float(c.a);\n return a > 0.004 ? float3(c.rgb) / a : float3(0.0);\n}\n\n// The capture ends at the screen edge: samples are clamped to the rectangle where content\n// actually exists, otherwise full-width glass picked up a band of emptiness along its edges.\nfloat2 vgInContent(float2 q) { return clamp(q, u_contentMin, u_contentMax); }\n\n// Hue without lightness. Below the threshold the color has no hue, and the division blows up.\nfloat3 vgHue(float3 c) {\n float l = vgLuma(c);\n if (l < 0.02) { return float3(1.0); }\n return clamp(c / l, float3(0.0), float3(2.0));\n}\n\n// Edge profile — a convex squircle: x = 0 at the silhouette, 1 where the rounding turns flat.\nfloat vgRimQ(float x) {\n float k = 1.0 - x;\n return sqrt(sqrt(max(1.0 - k * k * k * k, 0.0)));\n}\n\nfloat vgRimQd(float x) {\n float k = 1.0 - x;\n return k * k * k / pow(max(1.0 - k * k * k * k, 1e-5), 0.75);\n}\n\n// Glass height above the content at distance e from the silhouette.\nfloat vgHeight(float e, float w) {\n return mix(u_rim, u_thick, vgRimQ(clamp(e / w, 0.0, 1.0)));\n}\n\n// Slope of the top face at the same point: the derivative of height with respect to distance\n// from the silhouette.\nfloat vgSlope(float e, float w) {\n if (e >= w) { return 0.0; }\n return min((u_thick - u_rim) / w * vgRimQd(clamp(e / w, 0.0, 1.0)), VG_SLOPE_MAX);\n}\n\n// Where a ray falling from above lands on a face with normal N: Snell's law refraction, then a\n// path of length z through the medium to the content. The convex face bends the ray toward the\n// normal — that is, inward relative to the shape.\nfloat2 vgShift(float3 N, float z, float ior) {\n float3 T = refract(float3(0.0, 0.0, -1.0), N, 1.0 / ior);\n return z * T.xy / max(-T.z, 0.05);\n}\n\n// Thin-film interference: optical path difference 2·n·d·cosθt, each channel with its own λ.\n// Returns a hue normalized to its own average — it colors, but doesn't lighten.\nfloat3 vgInterference(float cosI) {\n float sinT2 = (1.0 - cosI * cosI) / (VG_FILM_IOR * VG_FILM_IOR);\n float cosT = sqrt(max(1.0 - sinT2, 0.0));\n float opd = 2.0 * VG_FILM_IOR * u_film * cosT;\n float3 i = 0.5 + 0.5 * cos(VG_TAU * opd / VG_LAMBDA + 3.14159265);\n return i / max((i.r + i.g + i.b) / 3.0, 0.001);\n}\n\n// Edge diffraction: fringes get denser the sharper the bevel. Also a hue, not a brightness.\nfloat3 vgDiffraction(float distFromEdge, float bevel) {\n float phase = VG_TAU * ${SPECTRAL.diffractionFringes}.0 * distFromEdge / max(bevel, 1.0);\n float3 d = 0.5 + 0.5 * cos(phase * (${SPECTRAL.referenceLambda}.0 / VG_LAMBDA));\n return d / max((d.r + d.g + d.b) / 3.0, 0.001);\n}\n\nfloat vgHash(float2 p) {\n return fract(sin(dot(p, float2(12.9898, 78.233))) * 43758.5453);\n}\n\n// Soft compression instead of a hard clamp: over a white backdrop, additions used to knock a\n// channel to one, and the glass turned into a flat blob with no detail.\nfloat3 vgSoftClip(float3 c) {\n float3 over = max(c - 0.86, float3(0.0));\n return min(c, float3(0.86)) + over * 0.14 / (0.14 + over);\n}\n\n// Our own blur: the capture is left clean, the shader does the blurring — averaging in float\n// smooths banding on its own and adds no noise of its own. A golden-angle spiral, rotated to its\n// own angle at every pixel: with a shared angle, neighboring pixels took the same samples, and\n// texture under the glass read in clumps. Accumulated premultiplied — one shared un-premultiply\n// at the end.\nfloat4 vgGather(float2 q, float radius, float2 seed) {\n float4 acc = float4(content.eval(vgInContent(q)));\n if (radius <= 0.25) { return acc; }\n if (radius < 4.0) {\n float r = radius * 0.7;\n acc += float4(content.eval(vgInContent(q + float2(r, 0.0))))\n + float4(content.eval(vgInContent(q - float2(r, 0.0))))\n + float4(content.eval(vgInContent(q + float2(0.0, r))))\n + float4(content.eval(vgInContent(q - float2(0.0, r))));\n return acc * 0.2;\n }\n float ca = cos(2.39996323);\n float sa = sin(2.39996323);\n float a0 = vgHash(seed) * 6.28318530718;\n float2 dir = float2(cos(a0), sin(a0));\n float wide = radius * 0.5;\n int taps = int(clamp(float(VG_FROST_TAPS) * wide * wide, float(VG_FROST_TAPS), float(VG_FROST_TAPS_MAX)));\n for (int i = 1; i <= VG_FROST_TAPS_MAX; i++) {\n if (i > taps) { break; }\n dir = float2(dir.x * ca - dir.y * sa, dir.x * sa + dir.y * ca);\n float r = radius * sqrt(float(i) / float(taps));\n acc += float4(content.eval(vgInContent(q + dir * r)));\n }\n return acc / float(taps + 1);\n}\n\nhalf4 main(float2 xy) {\n float2 p = vgTouchWarp(xy - u_center, u_touch, u_pull, u_touchPress, u_touchRadius, u_wave.x, u_wave.y);\n float sd = vgScene(p, u_halfSize, u_corner, u_morphOffset, u_morphHalf, u_morphCorner, u_morphK,\n u_morph2Offset, u_morph2Half, u_morph2Corner);\n // There's nothing outside the glass — except the light it spills onto the backdrop under the\n // finger (M 3:38): the same concentrated ambient as inside, so no white halo appears over a\n // dark backdrop.\n if (sd > 1.0) {\n float spill = u_touchPress * exp(-sd / max(min(u_halfSize.x, u_halfSize.y) * 0.5, 4.0)) * 0.5 * u_appear;\n if (spill < 0.004) { return half4(0.0); }\n float3 lit = clamp((u_probeLuma >= 0.0 ? u_probe : float3(0.35)) * 1.6 + float3(0.1), float3(0.0), float3(1.0));\n return half4(half3(lit * spill), half(spill));\n }\n\n float bevel = max(u_bevel, 1.0);\n float e = max(-sd, 0.0);\n // 0 in the flat middle, 1 at the silhouette.\n float t = 1.0 - clamp(e / bevel, 0.0, 1.0);\n float2 n = vgSceneNormal(p, u_halfSize, u_corner, u_morphOffset, u_morphHalf, u_morphCorner, u_morphK,\n u_morph2Offset, u_morph2Half, u_morph2Corner);\n\n // \"backdrop\" mode hands back the content as-is — a reference point for comparing the optics.\n float on = u_debug > 5.5 && u_debug < 6.5 ? 0.0 : 1.0;\n float lens = on * u_appear;\n\n float z = vgHeight(e, bevel);\n float slope = vgSlope(e, bevel);\n float3 N = normalize(float3(n * slope, 1.0));\n float2 shift = vgShift(N, z, u_ior) * lens;\n float2 s = u_center + p + shift;\n\n // The area the lens gathers into one pixel: a one-pixel step inward on screen, measured\n // against the sampling step. At the silhouette it's large — a stripe of backdrop is compressed\n // into a line there, and a point sample gives grain.\n float e1 = e + 1.0;\n float3 N1 = normalize(float3(n * vgSlope(e1, bevel), 1.0));\n float2 shift1 = vgShift(N1, vgHeight(e1, bevel), u_ior) * lens;\n float footprint = length(shift1 - shift - n);\n float spread = max(footprint - 1.0, 0.0) * 0.5 * on;\n\n // Dispersion: the same ray with each channel's own index. Blue bends more than red.\n float2 dR = vgShift(N, z, u_ior + ${DISPERSION.redShift} * u_iorSpread) * lens - shift;\n float2 dB = vgShift(N, z, u_ior + ${DISPERSION.blueShift} * u_iorSpread) * lens - shift;\n float chroma = length(dB - dR);\n\n float3 rgb;\n float srcA;\n\n if (chroma + spread < 0.25) {\n // In the flat body all the samples would land at the same point, and the body is almost the\n // whole area of the glass.\n half4 c = content.eval(vgInContent(s));\n srcA = float(c.a);\n rgb = srcA > 0.004 ? float3(c.rgb) / srcA : float3(0.0);\n } else {\n // Accumulate premultiplied and divide once per pair: channels from different points with\n // different alpha would otherwise produce a colored fringe at content edges that isn't\n // really there.\n float2 ev = n * spread;\n half4 c0 = content.eval(vgInContent(s + dR - ev));\n half4 c1 = content.eval(vgInContent(s + dR + ev));\n half4 c2 = content.eval(vgInContent(s - ev));\n half4 c3 = content.eval(vgInContent(s + ev));\n half4 c4 = content.eval(vgInContent(s + dB - ev));\n half4 c5 = content.eval(vgInContent(s + dB + ev));\n\n float aR = float(c0.a + c1.a) * 0.5;\n float aG = float(c2.a + c3.a) * 0.5;\n float aB = float(c4.a + c5.a) * 0.5;\n rgb = float3(\n aR > 0.004 ? float(c0.r + c1.r) * 0.5 / aR : 0.0,\n aG > 0.004 ? float(c2.g + c3.g) * 0.5 / aG : 0.0,\n aB > 0.004 ? float(c4.b + c5.b) * 0.5 / aB : 0.0);\n srcA = (aR + aG + aB) / 3.0;\n }\n\n // \"backdrop\" mode checks the CAPTURE, not a simplified version of the optics. What follows are\n // layers that aren't tied to the lens (body, medium, scattering), and they used to conflate\n // \"did the pixels arrive\" with \"how did we process them.\" Here the element must DISAPPEAR: a\n // visible silhouette means a capture loss.\n if (u_debug > 5.5 && u_debug < 6.5) {\n float bypass = srcA * (1.0 - smoothstep(-1.0, 1.0, sd));\n return half4(half3(clamp(rgb, float3(0.0), float3(1.0)) * bypass), half(bypass));\n }\n\n // The transparent variant's dimming layer holds legibility instead of the body. A\n // multiplication, not a tint: the content has to stay visible, just quieter.\n rgb *= 1.0 - u_dim * u_appear;\n\n // REFLECTION. Fresnel from the face's actual slope: at the silhouette the view is grazing and\n // reflection is nearly total, which is why the rim reads as a thin line on its own. What's\n // reflected is the element's surroundings and the key light.\n float cosT = clamp(N.z, 0.0, 1.0);\n float f0 = (u_ior - 1.0) / (u_ior + 1.0);\n f0 *= f0;\n float fres = (f0 + (1.0 - f0) * pow(1.0 - cosT, 5.0)) * u_fresnel * lens;\n\n float lineW = clamp(min(u_halfSize.x, u_halfSize.y) * 0.03, 1.5, 5.0);\n float3 refl;\n if (e < lineW * 2.0 || fres > 0.01) {\n float2 around = u_center + p + n * (u_reflectReach * mix(0.35, 1.0, clamp(slope / 3.2, 0.0, 1.0)));\n // Two rings of eight samples total: a single offset sample is an undistorted COPY of\n // neighboring content inside the glass (docs/material-lab.md E-33).\n float p1 = u_reflectReach * 0.75;\n float p2 = u_reflectReach * 0.4;\n float d = 0.7071;\n float4 rsum = float4(content.eval(vgInContent(around + float2(p1, 0.0))))\n + float4(content.eval(vgInContent(around - float2(p1, 0.0))))\n + float4(content.eval(vgInContent(around + float2(0.0, p1))))\n + float4(content.eval(vgInContent(around - float2(0.0, p1))))\n + float4(content.eval(vgInContent(around + float2(p2, p2) * d)))\n + float4(content.eval(vgInContent(around + float2(-p2, p2) * d)))\n + float4(content.eval(vgInContent(around + float2(p2, -p2) * d)))\n + float4(content.eval(vgInContent(around + float2(-p2, -p2) * d)));\n float ra = rsum.a * 0.125;\n refl = ra > 0.004 ? rsum.rgb * 0.125 / ra : float3(0.0);\n } else {\n refl = u_probeLuma >= 0.0 ? u_probe : rgb;\n }\n\n // Light reaching the body is the same across the whole element: blending with the surroundings\n // over the bevel's band used to paint a ring-shaped seam on the body.\n float3 ambient = u_probeLuma >= 0.0 ? u_probe : rgb;\n\n // Light comes from wherever the surroundings are brighter (M 11:04): the lightness slope under\n // the element pulls the key light toward itself, and over a flat backdrop it stays at rest.\n float2 bright = u_probeLuma >= 0.0 ? u_probeSlope : float2(0.0);\n float brightLen = length(bright);\n float2 L = normalize(mix(u_light, bright / max(brightLen, 1e-4), smoothstep(0.03, 0.2, brightLen)) + float2(1e-5));\n // The key light's reflection uses the face's actual normal: at the flat top it points straight\n // up, and there's nothing there for direction to depend on. Using the SDF normal instead\n // painted the body as a cone.\n float facing = dot(N.xy, L);\n float key = u_specular * (pow(max(facing, 0.0), ${RIM.lobeExponent}.0) + ${RIM.opposingArc} * pow(max(-facing, 0.0), ${RIM.lobeExponent}.0));\n float rimFacing = dot(n, L);\n float rimKey = u_specular * (pow(max(rimFacing, 0.0), ${RIM.lobeExponent}.0) + ${RIM.opposingArc} * pow(max(-rimFacing, 0.0), ${RIM.lobeExponent}.0));\n // Wherever the key light doesn't fall, the face reflects its shaded surroundings — hence the\n // dark outline.\n float3 env = refl * (0.55 + 0.45 * min(key, 1.0)) + float3(1.2 * key);\n\n // Interference and diffraction live in the reflected ray at a grazing angle — a single hue\n // multiplier applied to the reflection, no extra samples.\n float3 spectral = float3(1.0);\n if (u_iridescence > 0.001) {\n spectral *= mix(float3(1.0), vgInterference(cosT), u_iridescence);\n }\n if (u_diffraction > 0.001) {\n float w = u_diffraction * smoothstep(${SPECTRAL.diffractionOnset}, 1.0, t);\n spectral *= mix(float3(1.0), vgDiffraction(e, bevel), w);\n }\n\n // The BACKDROP ESTIMATE arrives from the probe as one value per surface: computing it here\n // from samples isn't an option — a kink in density used to turn the estimate's discreteness\n // into ghost copies of text.\n float3 wide;\n float busy;\n if (u_probeLuma >= 0.0) {\n wide = u_probe;\n busy = u_probeBusy;\n } else {\n // The probe hasn't reported yet (first frames) — fall back to our own samples.\n float2 wx = float2(u_adaptRadius, 0.0);\n float2 wy = float2(0.0, u_adaptRadius);\n float3 w0 = vgUnpack(content.eval(vgInContent(s + wx)));\n float3 w1 = vgUnpack(content.eval(vgInContent(s - wx)));\n float3 w2 = vgUnpack(content.eval(vgInContent(s + wy)));\n float3 w3 = vgUnpack(content.eval(vgInContent(s - wy)));\n wide = (w0 + w1 + w2 + w3) * 0.25;\n float lw = vgLuma(wide);\n // The same statistic the probe uses (twice the mean deviation): both blur and the ink's\n // contrast margin depend on it, and the two paths' scales must not diverge.\n busy = clamp(0.5 * (abs(vgLuma(w0) - lw) + abs(vgLuma(w1) - lw)\n + abs(vgLuma(w2) - lw) + abs(vgLuma(w3) - lw)), 0.0, 1.0);\n }\n // Lightness AT THIS SPOT on the surface: the probe's plane, clamped to the measured range.\n float2 nrm = p / max(u_halfSize, float2(1.0));\n float local = u_probeLuma >= 0.0\n ? clamp(u_probeLuma + dot(u_probeSlope, nrm), u_probeRange.x, u_probeRange.y)\n : vgLuma(wide);\n float mean = u_probeLuma >= 0.0 ? u_probeLuma : vgLuma(wide);\n\n // SCATTERING. Regular mutes foreign structure under its own ink with blur, not a fill (M\n // 11:47): text under a capsule turns into blotches. Uniform across the whole lens; the radius\n // is measured in backdrop space — the lens compresses it at the silhouette.\n float structure = 1.0 - exp(-busy * VG_STRUCTURE_GAIN);\n // Under ink, Regular always scatters the backdrop; over a busy one, more strongly.\n float adaptBlur = max(\n (structure * VG_SCATTER_MAX + VG_SCATTER_BASE) * u_legibility * u_adaptRadius\n * min(max(footprint, 1.0), VG_FOOTPRINT_MAX),\n u_frost) * u_appear;\n if (adaptBlur > 0.5) {\n float reach = max(u_reach - length(p), 1.0);\n float4 g = vgGather(s, min(adaptBlur, reach), xy);\n float ga = g.a;\n float3 blurred = ga > 0.004 ? g.rgb / ga : float3(0.0);\n rgb = mix(rgb, blurred, smoothstep(0.5, 2.0, adaptBlur));\n }\n\n // AFTER scattering, not before: scattering is a property of TRANSMITTED light and replaces rgb\n // wholesale, so doing it the other way around erased the reflection over the whole element\n // (issue #106).\n rgb = mix(rgb, env * spectral, fres);\n\n // BODY. Tint and dynamic range under the glass compress just enough for ink over it to stay\n // legible (M 6:42). u_ink is ink POLARITY (1 light, 0 dark): the requirements are computed at\n // the two ends and blended by it, otherwise the glass dips toward the middle during a recolor.\n float strict = clamp(u_legibility * 2.0, 0.0, 1.0);\n float capLight = mix(VG_BODY_CAP_LOOSE, VG_BODY_CAP_TIGHT, strict);\n float floorDark = 1.0 - capLight;\n float pol = clamp(u_ink, 0.0, 1.0);\n // The requirement fades together with legibility: an element with no ink is promised\n // transparent glass by the model.\n float demand = clamp(u_legibility * 4.0, 0.0, 1.0);\n\n // Where there's no ink, the glass tints away from the backdrop. The direction is chosen by the\n // average lightness under the element, not the local spot's lightness: otherwise on a gradient\n // the threshold cuts across the body as a diagonal step.\n float darkSide = smoothstep(${BODY.darkSideFrom}, ${BODY.darkSideTo}, mean);\n float away = mix(VG_TINT_LIGHT, VG_TINT_DARK, darkSide);\n float tintLuma = mix(away, mix(VG_TINT_LIGHT, VG_TINT_DARK, pol), demand);\n\n // How much medium it takes to push lightness under the ink past the threshold — locally.\n // Computed from whichever edge of the backdrop's spread is closer to the ink: a light ink\n // drowns in a light spot right beneath it, and the spot's average lightness knows nothing\n // about that spot.\n float edge = busy * VG_BUSY_EDGE;\n float inkHi = min(local + edge, 1.0);\n float inkLo = max(local - edge, 0.0);\n float needForLight = inkHi > capLight\n ? clamp((inkHi - capLight) / max(inkHi - VG_TINT_DARK, 1e-4), 0.0, ${BODY.maxDemand})\n : 0.0;\n float needForDark = inkLo < floorDark\n ? clamp((floorDark - inkLo) / max(VG_TINT_LIGHT - inkLo, 1e-4), 0.0, ${BODY.maxDemand})\n : 0.0;\n float needForInk = mix(needForDark, needForLight, pol) * demand;\n\n float ground = structure * u_legibility * VG_GROUND_SPAN;\n float density = max(max(u_bodyDensity, ground), needForInk);\n\n // PRESENCE (§3). Over a uniform backdrop there is nothing to refract, and an element that is\n // only a rim honestly disappears — right for a piece of background, wrong for a control.\n //\n // This used to live on the rim line alone, as lit = max(rimKey, u_presence x 2), while the\n // DOM path has always implemented it as a floor on the BODY. Two renderers, one field, two\n // meanings. Measured on Apple's own control over a flat page (frames/verify/m-707), the body\n // carries 16 levels of separation there and the rim 11.6 — so the body is where it belongs,\n // and the rim's reading was the wrong one.\n // The separation asked for is capped by the range that is left: over a backdrop at 0.96 there\n // is no room to go 0.05 lighter. And what it is DIVIDED by is the distance to the tint's own\n // end, not to the tint the body currently sits at — dividing by the latter explodes wherever\n // the two are close, which is how the first version of this drove density to its ceiling at\n // both extremes and took the window down to 7%.\n bool lighter = local < 0.5;\n float target = lighter ? min(local + u_presence, 1.0) : max(local - u_presence, 0.0);\n float separation = abs(target - local);\n float reached = abs(tintLuma - local) * density;\n if (u_presence > 0.0 && reached < separation) {\n float toEnd = abs((lighter ? VG_TINT_LIGHT : VG_TINT_DARK) - local);\n density = max(density, min(separation / max(toEnd, 1e-4), ${BODY.maxDemand}));\n }\n\n // Glass has no color of its own — only the color of what's beneath it (HIG \"Color\").\n float3 tintHue = mix(float3(1.0), vgHue(wide * 0.5 + ambient * 0.5), u_colorPickup);\n // The element appears by the lens and body building up, not by fading in (M 2:55): at\n // u_appear = 0 it's indistinguishable from the backdrop beneath it.\n rgb = mix(rgb, tintHue * tintLuma, density * u_appear);\n rgb += tintHue * (u_legibility * VG_MATTE_LIFT * u_appear);\n\n // TINTING — colored glass, not a fill (M 16:31, 17:03): the backdrop's lightness drives the\n // tone — deeper over dark, lighter over light — and the content's texture still shows through\n // the color.\n if (u_accent.a > 0.0) {\n float3 tone = u_accent.rgb * mix(${ACCENT.deep}, ${ACCENT.light}, local);\n float3 through = tone * (0.85 + 0.3 * vgLuma(rgb));\n rgb = mix(rgb, clamp(through, float3(0.0), float3(1.0)), u_accent.a * u_appear);\n }\n\n // CONTRAST COMPRESSION. The medium removes some light and mixes in scattered light, so content\n // under the glass moves toward the middle rather than simply getting lighter (M 2:35). The\n // previous layer only added light and, over a light backdrop, pushed the body the opposite way\n // from the reference.\n rgb = mix(rgb, vgHue(ambient) * VG_MEDIUM_LUMA, VG_MEDIUM_PULL * u_appear);\n // Ambient light reaches the body the same way across the whole element.\n rgb += ambient * u_edgeLight * VG_AMBIENT_SPILL * u_appear;\n // Glass concentrates light; the played portion is the segment where there's more of it.\n float glow = VG_CONCENTRATE + 0.08 * vgProgress(p, u_halfSize, u_progress);\n rgb += (1.0 - rgb) * glow * lens;\n\n // Under the finger and during morphing, glass concentrates light into a spot (M 4:56, 5:11).\n // This is a CONCENTRATION of the surroundings, not the glass's own whiteness: over a dark\n // backdrop the element lightens but never turns white, and ink over it stays legible.\n if (u_touchPress > 0.001) {\n float2 fromTouch = p - u_touch;\n float spotR = max(min(u_halfSize.x, u_halfSize.y) * 1.2, 1.0);\n float spot = u_touchPress * (0.3 + 0.55 * exp(-dot(fromTouch, fromTouch) / (spotR * spotR)));\n rgb = mix(rgb, clamp(ambient * 1.6 + float3(0.1), float3(0.0), float3(1.0)), spot * lens);\n }\n\n // RIM LIGHT — a separate layer, a line about 1 pt wide along the silhouette (M 2:36, 11:04):\n // brighter where the face faces the key light, weaker opposite it; where no light falls, a\n // dark outline. This line is what holds the element's presence, not a fill on the body: over a\n // flat backdrop a control is visible along its whole silhouette because of it.\n float line = (1.0 - smoothstep(0.0, lineW, e)) * lens;\n float outline = (1.0 - smoothstep(0.0, lineW * 0.6, e)) * lens;\n float lit = clamp(max(rimKey * 1.4, u_presence * 2.0), 0.0, 1.0);\n // The dark rim is its own layer around the whole silhouette, and the highlight sits ON TOP of\n // it (iOS 27). While the outline used to fade via a (1 − lit) multiplier, the silhouette read\n // as a single arc: highlight OR shadow.\n rgb *= 1.0 - ${RIM.darkEdge} * outline;\n rgb = mix(rgb, mix(refl, float3(1.0), 0.75), line * lit);\n\n if (u_debug > 9.5 && u_debug < 10.5) { rgb = spectral * 0.5; }\n if (u_debug > 10.5 && u_debug < 11.5) { rgb = float3(density, needForInk, structure); }\n // WHAT THE PROBE SAID ABOUT THE BACKDROP — three values that drive all the tinting: the\n // average lightness under the element, the vertical lightness slope, and the lightness AT THIS\n // SPOT. The slope is shown offset and squeezed by half: it's signed and rarely exceeds a\n // magnitude of one half.\n if (u_debug > 11.5) { rgb = float3(max(u_probeLuma, 0.0), 0.5 + u_probeSlope.y * 0.5, local); }\n\n rgb = vgSoftClip(rgb);\n\n // Sample alpha has to survive to the result: un-premultiplying color by its original alpha and\n // then returning it with a different one (the shape mask) would make a transparent backdrop\n // opaque and blow it out.\n float alpha = srcA * (1.0 - smoothstep(-1.0, 1.0, sd));\n return half4(half3(clamp(rgb, float3(0.0), float3(1.0)) * alpha), half(alpha));\n}\n`;\n","import { ACCENT, MORPH } from './law';\nimport {\n bevelDp,\n bevelFraction,\n halfMinDp,\n rimDp,\n shadowReachDp,\n surfacePadDp,\n thicknessDp,\n type VireGlassGeometry,\n} from './geometry';\nimport { LENS_SHADER } from './lens-shader';\nimport { neckToBridge } from './sdf';\nimport { debugIndex, type VireGlassDebugMode, type VireGlassOptics } from './material';\n\n/** Smooth union with a second shape — bench morphing experiment only. */\nexport type VireGlassMorph = {\n offsetX: number;\n offsetY: number;\n width: number;\n height: number;\n cornerRadius: number;\n /** Seam smoothing radius in dp; 0 turns the second shape off. */\n smoothing: number;\n};\n\n\n/** Surface response to a finger: the field around the touch point deforms, not the shape's\n * bounding box (`vgTouchWarp` in `sdf.ts`). Lengths in dp; `radius` = 0 turns the response off\n * entirely. */\nexport type VireGlassTouch = {\n x: number;\n y: number;\n pullX: number;\n pullY: number;\n press: number;\n radius: number;\n waveAmp: number;\n wavePhase: number;\n};\n\nconst NO_TOUCH: VireGlassTouch = {\n x: 0, y: 0, pullX: 0, pullY: 0, press: 0, radius: 0, waveAmp: 0, wavePhase: 0,\n};\n\nconst NO_MORPH = { offsetX: 0, offsetY: 0, width: 0, height: 0, cornerRadius: 0, smoothing: 0 };\n\n/** No progress. Negative rather than zero: zero is the start of the track, a legitimate value. */\nconst NO_PROGRESS = -1;\n\n/** Tinted glass for the primary action (M 16:08). Color is RGB 0…1. */\nexport type VireGlassAccent = { color: readonly [number, number, number]; amount?: number };\n\n/** Default tint fraction: the color reads, but content beneath it is still visible. */\nexport const ACCENT_AMOUNT = ACCENT.amount;\nconst NO_ACCENT = [0, 0, 0, 0] as const;\n\n\n\n/** Magnification at the flat center. Kept separate from the uniform channel: it's also used by\n * the fallback below Android 13, where there's no RuntimeShader and only an affine magnifier is\n * left. */\nexport const lensMagnify = (o: VireGlassOptics) => 1 + (o.refractionScale - 1) * o.refraction;\n\n/**\n * Lens uniforms. Assembled as ONE channel: name, size and values travel together, so a mismatch\n * with the shader is caught immediately, with the name right there in the log. There used to be a\n * separate Kotlin `Prop` per value — Expo swallows an unknown prop silently, and the lens simply\n * never turned on (docs/material-lab.md E-01, which is how refraction ended up disabled for an\n * entire phase).\n *\n * Everything with a dimension is converted to PIXELS right here. The native view is left with\n * only the uniforms it alone knows: its own size and its own place on screen.\n */\n// The lens's uniform names and sizes are always the same — the set is fixed. They're handed over\n// as ONE instance for the whole process: otherwise every frame of a drag would send three dozen\n// fresh strings to the native side, React can't tell \"unchanged\" from \"a new array\", and motion\n// goes stepwise. The values are the only thing that actually changes.\nconst shapes = new Map<number, { names: string[]; sizes: number[] }>();\n\nfunction channel(entries: [string, number | readonly number[]][]) {\n const uniformValues: number[] = [];\n let shape = shapes.get(entries.length);\n let same = shape !== undefined;\n for (let i = 0; i < entries.length; i += 1) {\n const [name, value] = entries[i];\n const v = typeof value === 'number' ? [value] : value;\n if (same && (shape!.names[i] !== name || shape!.sizes[i] !== v.length)) same = false;\n for (const x of v) uniformValues.push(x);\n }\n if (!same) {\n shape = {\n names: entries.map((e) => e[0]),\n sizes: entries.map((e) => (typeof e[1] === 'number' ? 1 : e[1].length)),\n };\n shapes.set(entries.length, shape);\n }\n return { uniformNames: shape!.names, uniformSizes: shape!.sizes, uniformValues };\n}\n\n/** Props for the native view. Besides the uniform channel, only what the view uses itself lives\n * here: the shader source and the visible glass's size (the probe rectangle is taken from it). */\nexport function toLensProps(\n optics: VireGlassOptics,\n geometry: VireGlassGeometry,\n density: number,\n options: {\n debug?: VireGlassDebugMode;\n morph?: VireGlassMorph;\n /** Third shape of the fused body; a zero size turns it off. */\n morph2?: VireGlassMorph;\n groupProbe?: number[];\n touch?: VireGlassTouch;\n /** Progress fraction, 0…1: to the left of the boundary the element is active. `undefined` means no progress. */\n progress?: number;\n /** Key light direction in screen space; defaults to the light at rest. */\n light?: readonly [number, number];\n /** 0…1: the lens builds up as the element appears — instead of a plain fade. */\n appear?: number;\n /** Tint for the primary action: the glass color and the fraction it lays over the content. */\n accent?: VireGlassAccent;\n } = {},\n) {\n const morph = options.morph ?? NO_MORPH;\n const morph2 = options.morph2 ?? NO_MORPH;\n const touch = options.touch ?? NO_TOUCH;\n // Backdrop estimate for the whole surface group. Travels through the same channel as the\n // material and applies AFTER the lens's own estimate — that is, it simply overrides it. It\n // can't travel as a separate prop: the lens view is wrapped in an animated component.\n const g = options.groupProbe;\n const group: [string, number | readonly number[]][] =\n g && g.length >= 9\n ? [\n ['u_probeLuma', g[0]],\n ['u_probeBusy', g[1]],\n ['u_probeRange', [g[2], g[3]]],\n ['u_probeSlope', [g[4], g[5]]],\n ['u_probe', [g[6], g[7], g[8]]],\n ]\n : [];\n const d = density;\n const halfW = (geometry.width * d) / 2;\n const halfH = (geometry.height * d) / 2;\n const halfMin = Math.min(halfW, halfH);\n\n return {\n shaderSource: LENS_SHADER,\n glassWidth: geometry.width,\n glassHeight: geometry.height,\n ...channel([\n ['u_halfSize', [halfW, halfH]],\n ['u_corner', Math.min(geometry.cornerRadius * d, halfMin)],\n ['u_bevel', Math.max(bevelDp(geometry, optics) * d, 1)],\n ['u_thick', thicknessDp(geometry, optics) * d],\n ['u_rim', rimDp(geometry, optics) * d],\n ['u_ior', optics.ior],\n ['u_iorSpread', optics.iorSpread],\n ['u_light', options.light ?? REST_LIGHT],\n ['u_appear', options.appear ?? 1],\n ['u_accent', options.accent ? [...options.accent.color, options.accent.amount ?? ACCENT_AMOUNT] : NO_ACCENT],\n // Haze from surface roughness. Lives in the same disc-gather pass as adaptive scattering,\n // and fades out toward the bevel: that's a different job there — bending the ray and\n // splitting it.\n ['u_frost', optics.blur * d],\n ['u_ink', optics.ink],\n ['u_legibility', optics.legibility],\n ['u_dim', optics.dimming],\n ['u_presence', optics.presence],\n ['u_adaptRadius', optics.adaptRadius * d],\n ['u_bodyDensity', optics.bodyDensity],\n ['u_edgeLight', optics.edgeLight],\n ['u_fresnel', optics.fresnel],\n ['u_specular', optics.specular],\n // The rim gathers light from the element's vicinity — this is a radius around the shape,\n // not its bevel.\n ['u_reflectReach', optics.gatherRadiusDp * d],\n ['u_film', optics.film],\n ['u_iridescence', optics.iridescence],\n ['u_diffraction', optics.diffraction],\n ['u_colorPickup', optics.colorPickup],\n ['u_morphOffset', [morph.offsetX * d, morph.offsetY * d]],\n ['u_morphHalf', [(morph.width * d) / 2, (morph.height * d) / 2]],\n ['u_morphCorner', morph.cornerRadius * d],\n ['u_morphK', morph.smoothing * d],\n ['u_morph2Offset', [morph2.offsetX * d, morph2.offsetY * d]],\n ['u_morph2Half', [(morph2.width * d) / 2, (morph2.height * d) / 2]],\n ['u_morph2Corner', morph2.cornerRadius * d],\n ['u_touch', [touch.x * d, touch.y * d]],\n ['u_pull', [touch.pullX * d, touch.pullY * d]],\n ['u_touchPress', touch.press],\n ['u_touchRadius', touch.radius * d],\n ['u_wave', [touch.waveAmp * d, touch.wavePhase]],\n ['u_progress', options.progress ?? NO_PROGRESS],\n ['u_debug', debugIndex(options.debug ?? 'normal')],\n ...group,\n ]),\n };\n}\n\n/** Static part of the surface uniforms. Dynamics (gesture, press, light) get mixed in inside the\n * component's worklet — the adapter must stay an ordinary function. */\nexport function toSurfaceUniforms(\n optics: VireGlassOptics,\n geometry: VireGlassGeometry,\n options: {\n debug?: VireGlassDebugMode;\n morph?: VireGlassMorph;\n /** Third shape of the fused body; a zero size turns it off. */\n morph2?: VireGlassMorph;\n dragLimit?: number;\n shadow?: number;\n /** Average ambient color around the element: light from it bleeds into the shadow (reference 219 @8:22). */\n ambient?: readonly [number, number, number];\n /** The lens draws the glass body — the surface is left with the highlight, shadow and icon. */\n bodyInLens?: boolean;\n touch?: VireGlassTouch;\n /** Progress fraction, 0…1: to the left of the boundary the element is active. `undefined` means no progress. */\n progress?: number;\n /** 0…1: the element is appearing — shadow and ink build up together with the lens. */\n appear?: number;\n /** 0 — the element sinks in under the finger, 1 — it rises into glass (reference §5). */\n lift?: number;\n } = {},\n) {\n const morph = options.morph ?? NO_MORPH;\n const morph2 = options.morph2 ?? NO_MORPH;\n const touch = options.touch ?? NO_TOUCH;\n const pad = surfacePadDp(geometry, options.dragLimit ?? 0, morph);\n return {\n u_center: [geometry.width / 2 + pad, geometry.height / 2 + pad],\n u_halfSize: [geometry.width / 2, geometry.height / 2],\n u_corner: Math.min(geometry.cornerRadius, halfMinDp(geometry)),\n u_bevel: bevelDp(geometry, optics),\n u_thickness: bevelFraction(geometry, optics),\n u_morphOffset: [morph.offsetX, morph.offsetY],\n u_morphHalf: [morph.width / 2, morph.height / 2],\n u_morphCorner: morph.cornerRadius,\n u_morphK: morph.smoothing,\n u_morph2Offset: [morph2.offsetX, morph2.offsetY],\n u_morph2Half: [morph2.width / 2, morph2.height / 2],\n u_morph2Corner: morph2.cornerRadius,\n u_edgeDensity: optics.edgeDensity,\n u_dispersion: optics.dispersion,\n u_refraction: optics.refraction,\n // Tint density is suppressed when the lens is drawing the body: painting it twice would\n // double the fill, and adaptation is impossible on the surface anyway — it can't see the\n // backdrop. The color itself stays: it drives absorption at the rim.\n u_tint: [\n optics.tint.r,\n optics.tint.g,\n optics.tint.b,\n options.bodyInLens ? 0 : optics.tintStrength,\n ],\n u_shadow: options.shadow ?? 1,\n // Neutral by default: without an ambient sample, the shadow stays exactly as it was.\n u_ambient: options.ambient ?? [0, 0, 0],\n u_shadowReach: shadowReachDp(geometry),\n u_touch: [touch.x, touch.y],\n u_pull: [touch.pullX, touch.pullY],\n u_touchPress: touch.press,\n u_touchRadius: touch.radius,\n u_wave: [touch.waveAmp, touch.wavePhase],\n u_presence: optics.presence,\n u_progress: options.progress ?? NO_PROGRESS,\n u_appear: options.appear ?? 1,\n // Zero by default: buttons sink in, the way every element behaved before this rule existed.\n u_lift: options.lift ?? 0,\n\n u_debug: debugIndex(options.debug ?? 'normal'),\n };\n}\n\n/**\n * Surface fields that are LENGTHS: the adapter's contract is specified in dp, and on the web each\n * one of them has to be multiplied by screen density. The list lives here rather than in the\n * renderer, where it used to be a dozen and a half manual multiplications in a row: a missed\n * field there was only caught by eye, and the miss isn't visible everywhere — at density 1,\n * multiplying is indistinguishable from not doing it.\n */\nexport type SurfaceUniforms = ReturnType<typeof toSurfaceUniforms>;\n\nexport const SURFACE_LENGTH_UNIFORMS = [\n 'u_halfSize',\n 'u_corner',\n 'u_bevel',\n 'u_morphOffset',\n 'u_morphHalf',\n 'u_morphCorner',\n 'u_morphK',\n 'u_morph2Offset',\n 'u_morph2Half',\n 'u_morph2Corner',\n 'u_shadowReach',\n 'u_touch',\n 'u_pull',\n 'u_touchRadius',\n // `satisfies`, not just `as const`: otherwise a typo in the name compiles silently and makes it\n // to runtime — the field with the garbage name gets NaN, and the real one is left un-multiplied.\n] as const satisfies readonly (keyof SurfaceUniforms)[];\n\n/**\n * Surface uniforms in device pixels. Android draws in dp and calls the adapter as-is; the web\n * needs this conversion. `u_center` isn't part of it: the renderer knows the element's center on\n * its own.\n */\nexport function toDeviceSurfaceUniforms(raw: SurfaceUniforms, density: number): SurfaceUniforms {\n const scaled: Record<string, unknown> = { ...raw };\n for (const key of SURFACE_LENGTH_UNIFORMS) {\n const value: unknown = scaled[key];\n scaled[key] = Array.isArray(value)\n ? (value as number[]).map((v) => v * density)\n : (value as number) * density;\n }\n // Of the wave, only the amplitude has a length; the phase is in turns and knows nothing about density.\n scaled.u_wave = [raw.u_wave[0] * density, raw.u_wave[1]];\n return scaled as SurfaceUniforms;\n}\n\n/** Key light direction in screen coordinates, for when the orientation response is off. */\nexport const REST_LIGHT: readonly [number, number] = [-0.577, -0.817];\n\n/** Uniforms the component mixes in inside the worklet (press, active, light direction) and via\n * the icon layer. Listed here so a test can check the shader contract's completeness without\n * importing the component itself (it pulls in Skia and doesn't come up in a node environment). */\nexport const DYNAMIC_UNIFORMS = ['u_press', 'u_active'] as const;\n\nexport const ICON_UNIFORMS = ['u_iconOn', 'u_iconScale', 'u_inkIdle', 'u_inkActive'] as const;\n\n/** App-colored overlay layer on the glass. The `u_overlay` sampler shares its contract with the\n * ink mask and is sampled at the SAME coordinate — otherwise deformation would carry them apart. */\nexport const OVERLAY_UNIFORMS = ['u_overlayOn'] as const;\n\n/**\n * Fusing two surfaces into one continuous medium.\n *\n * The second shape is described RELATIVE to the first one's center, because both live in the\n * same shader: the union has no \"two pieces of glass,\" just one body with two bulges — the mask,\n * the refraction and the rim are all computed from a single shared scene.\n *\n * `t` — how fused the shapes are: 0 turns the second shape off before any computation, 1 gives a\n * single shared medium. The seam's smoothing radius is a fraction of the smaller half-size: on\n * large elements the bridge has to be wider, otherwise the seam is left with a sharp corner,\n * which doesn't happen in a liquid.\n */\n\n\n/**\n * How wide the neck between two lobes has to be: enough to soften the seam on a large element, and\n * enough to actually SPAN whatever is between them. The second term is the one that was missing.\n */\nfunction neckFor(\n half: number,\n aw: number,\n ah: number,\n bw: number,\n bh: number,\n offsetX: number,\n offsetY: number,\n): number {\n // Surface-to-surface, measured between the bounding boxes. The rounded corners put the true\n // surfaces slightly further apart, so this errs toward a wider neck, which is the safe side.\n const gx = Math.abs(offsetX) - (aw + bw) / 2;\n const gy = Math.abs(offsetY) - (ah + bh) / 2;\n const gap = Math.hypot(Math.max(gx, 0), Math.max(gy, 0));\n // Capped at the narrowest of the two bodies. A neck wider than what it joins is not a neck, and\n // past that width the honest answer is that these are two things rather than one — a menu that\n // has finished leaving its button, two controls too far apart to be a segmented control. Being\n // separate is a legitimate state; being joined by a blob larger than either shape is not.\n const widest = Math.min(aw, ah, bw, bh);\n return Math.min(Math.max(half * MORPH.neck, neckToBridge(gap) * MORPH.fuse), widest);\n}\n\nexport function morphBetween(\n a: VireGlassGeometry,\n b: VireGlassGeometry,\n offsetX: number,\n offsetY: number,\n t: number,\n): VireGlassMorph | undefined {\n if (t <= 0) return undefined;\n const half = Math.min(halfMinDp(a), halfMinDp(b));\n return {\n offsetX,\n offsetY,\n width: b.width,\n height: b.height,\n cornerRadius: b.cornerRadius,\n smoothing: neckFor(half, a.width, a.height, b.width, b.height, offsetX, offsetY) * Math.min(t, 1),\n };\n}\n\n/**\n * MITOSIS: the second shape grows OUT OF the first and travels to its place, instead of appearing\n * beside it at full size. A menu coming out of its button, a control dividing into segments.\n *\n * `morphBetween` is the other half — two shapes that are both already where they belong, fusing\n * into one body — and run backwards it is meiosis, the neck thinning until it breaks. What neither\n * of them may do is pop: at any `t` above zero this returns one continuous body, because that is\n * the whole of what the reference says a material transition is.\n *\n * The choreography stays the host's: what the shapes MEAN is the app's business. How a silhouette\n * emerges from another silhouette is the material's, the same way the spring under a finger is.\n */\nexport function morphOutOf(\n source: VireGlassGeometry,\n target: VireGlassGeometry,\n offsetX: number,\n offsetY: number,\n t: number,\n): VireGlassMorph | undefined {\n if (t <= 0) return undefined;\n const k = Math.min(t, 1);\n // At t = 0 the lobe IS the parent, in the parent's place: the transition starts from one body and\n // never has a first frame in which a second one exists. The parent's own surface is what the neck\n // attaches to, so nothing has to be budded off to give it something to hold.\n const width = source.width + (target.width - source.width) * k;\n const height = source.height + (target.height - source.height) * k;\n const cornerRadius = source.cornerRadius + (target.cornerRadius - source.cornerRadius) * k;\n const half = Math.min(halfMinDp(source), Math.min(width, height) / 2);\n return {\n offsetX: offsetX * k,\n offsetY: offsetY * k,\n width,\n height,\n cornerRadius,\n // The lobe travels as it grows, so the span changes every frame and the neck is measured\n // against where the lobe actually is, not against where it will end up.\n smoothing: neckFor(half, source.width, source.height, width, height, offsetX * k, offsetY * k),\n };\n}\n"]}
|