Updated
Caustics
Customize
Colors
Strength0.60
Waves0.35
Depth1.40
Scale1.00
Dispersion0.50
Chop0.55
Direction23°
Softness0.05
Bloom1.10
Sparkle1.25
Sparkle size1.00
Ray angle70°
Vignette0.25
Shade0.80
Speed1.0
Grain0.015
Seed0
Follow0.75
Touch0.50
Ripple strength0.35
Ripple size1.00
Ripple speed1.00
Installation
npx shadcn@latest add https://uibrik.com/r/caustics.jsonAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/caustics/caustics.tsx"use client"; import { NOISE, createProgram, type FrameInfo, type Prepass, ShaderSurface, type ShaderBackgroundProps } from "../_shader-background/ShaderSurface"; /** * The light pass for Caustics, done the way real caustics form (after Evan Wallace's WebGL Water). * * A grid of light rays falls on a moving water surface. Each ray is bent by the slope of the * surface where it enters (Snell's law, small-angle) and lands on the floor a little to the side. * The grid is drawn as a mesh at those landing points, and each triangle's brightness is how much it * shrank on the way: area before / area after. Where the surface focuses rays, triangles shrink and * pile up, and the familiar bright web appears, with its real shapes: soft cells, sharp cusps, lines * that split and merge as the waves move. * * Red, green and blue are drawn separately, each bent a touch differently, which gives the faint * colour fringing real caustics have. The result goes into a two-thirds-size texture, a little * soft, the way light from a sun disk is, with mipmaps the main pass reads its bloom from. */ const GRID = 240; // cells per side (241² vertices still fits 16-bit indices) const VERT = /* glsl */ `#version 300 es precision highp float; in vec2 a_pos; // 0..1 across the light grid
Adds the files to
components/uibrik/caustics. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/caustics.Too large to paste whole, so Copy prompt gives a short prompt that installs it with the CLI. Download the full prompt to attach it instead.
Usage
import { Caustics } from "@/components/uibrik/caustics/caustics";<Caustics colors={["#0b3a53", "#0f6f8f", "#3fb6c9", "#e6fbff"]} strength={0.6} waves={0.35} depth={1.4} scale={1} dispersion={0.5} chop={0.55} direction={23} softness={0.05} bloom={1.1} sparkle={1.25} sparkleSize={1} rayAngle={70} vignette={0.25} shade={0.8} speed={1} grain={0.015} seed={0} animate interactive follow={0.75} touch={0.5} ripples rippleStrength={0.35} rippleSize={1} rippleSpeed={1}> …</Caustics>Where to use Caustics
Travel and hotel sites
Sunlight on a pool floor sets a summer, holiday mood behind a booking or destination page.
Wellness app heroes
Slow moving water light gives a spa or meditation product a calm, living backdrop.
Pairs with Soft Clouds
Summer campaigns
Click-to-ripple adds a small moment of play to seasonal landing pages.
Props
Caustics- colors
- Type string[]
- ["#0b3a53","#0f6f8f","#3fb6c9","#e6fbff"]
- Pool floor from deep to shallow, then the light's tint last; 2 to 6 colours.
- strength
- Type number
- 0.6
- How strong the light is against the plain floor.
- waves
- Type number
- 0.35
- Wave height.
- depth
- Type number
- 1.4
- Floor depth: deeper water focuses the light into thinner, brighter lines.
- scale
- Type number
- 1
- Size of the waves; larger is calmer.
- dispersion
- Type number
- 0.5
- Colour fringing at the edges of the light.
- chop
- Type number
- 0.55
- Irregular chop on top of the wave trains; 0 leaves only smooth swells.
- direction
- Type number
- 23
- Direction the main waves travel.
- softness
- Type number
- 0.05
- Blur on the light, like a larger sun.
- bloom
- Type number
- 1.1
- Glow spilling around the brightest light.
- sparkle
- Type number
- 1.25
- Star-shaped sun glints where the light peaks.
- sparkleSize
- Type number
- 1
- Length of the glint rays.
- rayAngle
- Type number
- 70
- Direction of the long glint rays.
- vignette
- Type number
- 0.25
- Darkening toward the corners.
- shade
- Type number
- 0.8
- How much the floor colour varies.
- speed
- Type number
- 1
- Animation speed; 1 is the designed pace.
- grain
- Type number
- 0.015
- Film grain strength.
- seed
- Type number
- 0
- Shifts the composition, so two backgrounds with the same settings still differ.
- animate
- Type boolean
- true
- Move on its own. Off draws one still frame.
- interactive
- Type boolean
- true
- React to the pointer.
- follow
- Type number
- 0.75
- How lazily the fingertip dip follows the pointer, 0 (locked) to 1 (drifts after it).
- touch
- Type number
- 0.5
- How deep the pointer dips into the water.
- ripples
- Type boolean
- true
- A click drops a ripple on the water.
- rippleStrength
- Type number
- 0.35
- Height of a click ripple.
- rippleSize
- Type number
- 1
- Wavelength of a click ripple; larger is broader.
- rippleSpeed
- Type number
- 1
- How fast a ripple spreads.
- children
- Type ReactNode
- –
- Content shown on top of the background.
- className
- Type string
- –
- Classes for the box; it fills whatever size you give it.