Components / Backgrounds / Caustic Surface
Caustic Surface
The net of light on a pool floor, as a backdrop. The lines are not a texture: each floor pixel finds the surface point whose refracted ray lands on it, and its brightness is the area that patch of surface had over the area its light lands on, E = 1 / |det(I + D·(1 − 1/n)·H)|. Where the surface focuses, that determinant collapses and the light spikes. Deeper water focuses a sharper net, and the pointer drops ripples that bend it: as strong as it is fast when it moves, a full one when it presses, and keyboard focus on anything placed on the water stirs it too.
Usage
import CausticSurface from '@/components/caustic-surface'
<CausticSurface depth={260} amplitude={11}>
{content}
</CausticSurface>Installation
npx shadcn@latest add https://morphiq.prathampatel.design/r/caustic-surface.jsonModel
E = 1 / |det(I + D·(1 − 1/n)·H)|D water depth · n 1.333 · H the Hessian of the surface
Props
| Property | Type | Default | Description |
|---|---|---|---|
depth | number | 260 | Water between surface and floor, px. Deeper focuses the light into a sharper, busier net. |
amplitude | number | 11 | Height of the longest wave, px. |
wavelength | number | 200 | Length of the longest wave, px. The other four are fixed fractions of it. A change rescales the net about the centre of the surface. |
speed | number | 1 | Time scale of the waves. 0 stills them; ripples still run. |
ripple | number | 1 | Strength of the ripple a press or tap drops, or a key that activates something on the surface. A moving pointer sheds weaker ones, scaled by its speed up to three quarters of this; focus arriving by keyboard stirs half of it under the focused element. 0 turns them off. |
intensity | number | 1 | Brightness of the focused light. |
color | string | '#d6f3ff' | Colour of the light. Any CSS colour. |
background | string | '#03202a' | Colour of the pool floor, and the fallback where WebGL2 is unavailable. |
resolution | number | 1.5 | Device-pixel-ratio cap for the canvas. Lower is cheaper. |
children | ReactNode | — | Content laid over the water. It stays real DOM above the canvas. |