refract-rain-glass

Created 35 minutes ago

attributes
descriptionBuild liquid glass buttons and panels over a moving scene with wet edges, chromatic refraction, press response and legible HTML labels. Use when the glass must distort real background detail.
import_scopesignals-cleared-supporting-files
licenseMIT
license_urlhttps://github.com/MengTo/Skills/blob/2f8cb46167bec49ee3c4a6ca37972fc065b6b47e/LICENSE
namerefract-rain-glass
publisherMengTo
repository_urlhttps://github.com/MengTo/Skills
source_urlhttps://github.com/MengTo/Skills/blob/2f8cb46167bec49ee3c4a6ca37972fc065b6b47e/agent-skills/web-design/refract-rain-glass/SKILL.md
upstream_copyrightCopyright (c) 2026 Meng To
upstream_revision2f8cb46167bec49ee3c4a6ca37972fc065b6b47e

Refract Rain Glass

A live scene bends through a beveled edge under a moving film of water.

Use a clean copy of the live scene as the optical source. Keep labels, keyboard focus and hit areas in the DOM above the optical pass.

Assemble the material

  • Render the scene to a texture. Read it from a separate full-screen pass. Never sample a framebuffer while writing to it. Include any atmospheric streaks that should bend behind the lens.
  • Include lens.glsl. Its uniforms use CSS pixels, bottom-left origin, center XY and half-size ZW. Set glassViewport to the CSS surface size. Fill glassRects with the four capsules. Zero unused slots. A positive pickerRect width enables the optional eight-tile panel. Use pickerReveal = 1 for a settled panel.
  • Update glassContact with local 0–1 UV, one-based control index and press weight. Invert pointer Y. Reset on leave, cancel or lost capture. Re-measure on font load, resize and during transforms. Have the lens respond to a press while the label stays sharp.
  • Sample the returned UV for the green channel. Offset red and blue slightly in opposite directions along the distortion. Suppress separation on the flat face. The helper bends a virtual lip with IOR 1.46 and computes an opposed pair of narrow highlight strips. Avoid adding a heavy continuous CSS border.
float face, rim;
vec2 reflection, light;
vec2 q = glassRay(uv, vec4(0.), 0., face, rim, reflection, light);
vec2 d = (q - uv) * .045;
vec3 rgb = vec3(texture2D(sceneTex, clamp(q+d,0.,1.)).r,
                texture2D(sceneTex,q).g, texture2D(sceneTex,clamp(q-d,0.,1.)).b);
rgb = mix(rgb, texture2D(sceneTex,reflection).rgb, rim);

Apply scene tone mapping once. Darken the return band with light.y and lift the key with light.x. Add water.glsl with uniform float clock; and uniform vec4 seasonMix;. Call glassShower(uv * glassViewport, rgb) in display space. Use original screen coordinates here so a moving highlight cannot pull a drop off the rim. Ease seasonMix.x from zero to one for rain.

Check

Move a striped image behind the control. The stripe should bend near the lip, stay recognizable through the center and leave the label sharp. Compare dry and wet frames at 1× and 2×. Tab through controls, then disable WebGL and retain keyboard access with a translucent CSS fill.


Copyright (c) 2026 Meng To

The license files are attached. MIT

The attached ZIP contains the pinned supporting files cleared for import. Applicable license notices are attached or included when cleared.

Like how this is organised?

Build your own Memory tree on knowen.md: notes, decisions and tasks in one connected markdown graph, shared with your team and your AI agents.