# Rain on Controls

![Streaks meet the curved rim, then collect, run down the face and drop away.](assets/preview.jpg)

Make each streak supply the water that appears on the control. A separate random splash emitter breaks the illusion when the control moves.

## Attach the rain

1. Measure visible controls relative to the render surface after layout, font loading and resize. Track transformed bounds during hover or drag. Use CSS pixels throughout. For a bottom-up shader the rectangle is `[rect.left - view.left + rect.width/2, view.bottom - rect.bottom + rect.height/2, rect.width/2, rect.height/2]`.
2. Use [impacts.glsl](assets/impacts.glsl) inside a fragment shader. Supply `uniform vec4 glassRects[4], seasonMix;` and `uniform float clock;`. Zero unused rectangles. Call `glassShower(uv * viewportCSS, color)` on display-referred RGB before drawing labels. Rain intensity is seasonMix.x in 0–1. The four slots assume horizontal capsules. For a rounded card add halfHeight minus cornerRadius to rimHeight and use halfWidth minus cornerRadius for the straight run.
3. For each lane pick the next impact position once per cycle. Trace the incoming streak back from that point. Exclude the underside and stop the streak on contact. If the scene already has rain, reserve these last few pixels for the contact pass to avoid double streaks.
4. Let a short pressure wave spread along the rim. Throw a few small beads on ballistic arcs, integrate their velocity over approximately 11 ms, then let the same pool thin as the rivulet forms. Carry its lateral offset to the underside. Pin the top of the hanging drop until its neck thins.
5. Vary cycles between about 1.8 and 2.7 seconds. Keep the resting film under a pixel. Reject distant fragments before looping. Skip the pass when dry and freeze time or show a static film under reduced motion.

## Check

Slow playback around impact, release and the next cycle. Follow a single bead on a rounded end. Look for an air gap, a second splash before impact, bright water crossing text, or a row of simultaneous drips. Resize while hovering and switch to clear midway through a fall. The UI must remain clickable.

---

Copyright (c) 2026 Meng To

The license files are attached. [MIT](https://knowen.md/f/3c02f208-fea4-4055-a09c-593a4f764a38)

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