Skip to content

feat(water-ripple): add interactive WebGL water ripple background - #1006

Open
saumyarex wants to merge 1 commit into
magicuidesign:mainfrom
saumyarex:feat/waterRipple-background
Open

feat(water-ripple): add interactive WebGL water ripple background#1006
saumyarex wants to merge 1 commit into
magicuidesign:mainfrom
saumyarex:feat/waterRipple-background

Conversation

@saumyarex

Copy link
Copy Markdown

Description

Adds a Water Ripple background component under Backgrounds. It runs a wave
simulation on the GPU and shades the resulting height field as a lit liquid
surface, so ripples spread outward from wherever the pointer moves. Idle by
default; an autoPlay prop emits ambient ripples without any input.

Changes

  • registry/magicui/water-ripple.tsx — new component
  • registry/example/water-ripple-demo.tsx — demo
  • content/docs/components/water-ripple.mdx — docs (usage, 3 examples, props, credits)
  • registry/registry-ui.ts, registry/registry-examples.ts — registry entries
  • config/docs.ts — sidebar entry under Backgrounds
  • Regenerated registry artifacts with pnpm build:registry

Motivation

I originally built this for my own portfolio site, where I wanted a background that
reacted to the cursor. The Backgrounds section here has grids, patterns, Light Rays and
Noise Texture, but nothing fluid, so thought maybe I should contribute.

Worth flagging: this is distinct from the existing ripple component, which is a static
stack of concentric CSS circles. This one is a WebGL fluid simulation — the names are
close but the effects are unrelated.

Breaking Changes

None.

Checklist

  • pnpm check passes locally
  • pnpm build passes locally
  • pnpm build:registry was run and the generated files are committed (if you changed registry/ or config/site.ts — CI verifies this on every PR)
  • PR title follows Conventional Commits (e.g., feat(marquee): add reverse prop)

Adds a Water Ripple background component under Backgrounds. It runs a
GPU wave simulation and shades the resulting height field as a liquid
surface, so ripples spread from wherever the pointer moves.

The simulation is a discrete wave equation evaluated in a fragment
shader over three ping-pong float render targets, which keeps the
simulation from ever sampling the texture it is writing to. A second
pass turns the height field's gradient into a surface normal and
combines Blinn-Phong specular, fresnel and caustic terms, writing
premultiplied alpha so the effect composites over any background.

Implementation notes:

- Falls back to OES_texture_half_float when OES_texture_float is
  missing, and to NEAREST filtering when the matching *_linear
  extension is unavailable. Framebuffer completeness is checked, and
  the component renders nothing rather than failing silently when the
  device supports neither float format.
- Sizes the canvas by devicePixelRatio (capped at 2) and rebuilds the
  simulation grid from a ResizeObserver on the container.
- Pauses via IntersectionObserver while off-screen, and does not
  animate at all under prefers-reduced-motion.
- Handles webglcontextlost/webglcontextrestored, rebuilding the
  pipeline when the GPU hands the context back.
- Keeps props in a ref so tweaking them never tears down the GL
  context and discards the waves already on the surface.
- Resolves lightColor/shadowColor as CSS colours, including custom
  properties, and re-resolves them when the document theme changes.

Files:

- registry/magicui/water-ripple.tsx
- registry/example/water-ripple-demo.tsx
- content/docs/components/water-ripple.mdx
- registry/registry-ui.ts, registry/registry-examples.ts
- config/docs.ts

Registry artifacts regenerated with pnpm build:registry.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

@saumyarex is attempting to deploy a commit to the product-studio Team on Vercel.

A member of the Team first needs to authorize it.

@Yeom-JinHo
Yeom-JinHo self-requested a review August 27, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant