Water
Free
Moves an image under rippling water with caustic light. It also works as an animated water texture. Adapted from Water by Paper Shaders (shaders.paper.design) under the Apache 2.0 license.
Code
Usage
<ShaderWater
backgroundColor="#909090"
highlightColor="#ffffff"
imageSrc="https://images.unsplash.com/photo-1505142468610-359e7d316be0?w=1600&h=1200&fit=crop"
causticStrength={0.1}
edgeDistortion={0.8}
causticHighlights={0.07}
causticLayering={0.5}
patternSize={1}
waveDistortion={0.3}
waterSpeed={1}
graphicScale={0.8}
graphicRotation={0}
graphicOffsetX={0}
graphicOffsetY={0}
/>Props
| prop | type | default | description |
|---|---|---|---|
imageSrc | string | required | Image URL. The URL must be same-origin or served with CORS headers. |
imageAlt | string | required | Alternative text for the image. Pass an empty string for a decorative image. |
imageWidth | number | 1600 | Image width in pixels. Sets the aspect ratio with imageHeight. Defaults to 1600. |
imageHeight | number | 1200 | Image height in pixels. Sets the aspect ratio with imageWidth. Defaults to 1200. |
backgroundColor | string | #909090 | Color behind the image. Accepts any CSS color. |
highlightColor | string | #ffffff | Caustic highlight color. Needs highlights above 0. Accepts any CSS color. |
causticHighlights | number | 0.07 | Color added along the caustic shape. Range 0 to 1. |
causticLayering | number | 0.5 | Strength of the second caustic layer. Range 0 to 1. |
edgeDistortion | number | 0.8 | Caustic distortion at the image edges. Range 0 to 1. |
waveDistortion | number | 0.3 | Extra noise distortion, separate from the caustics. Range 0 to 1. |
causticStrength | number | 0.1 | Strength of the caustic distortion. Range 0 to 1. |
patternSize | number | 1 | Size of the water pattern. Range 0.01 to 7. |
waterSpeed | number | 1 | Animation speed. 0 stops the animation. Range 0 to 2. |
graphicScale | number | 0.8 | Overall zoom level of the graphic. |
graphicRotation | number | 0 | Rotation of the graphic in degrees. |
graphicOffsetX | number | 0 | Horizontal offset of the graphic center. |
graphicOffsetY | number | 0 | Vertical offset of the graphic center. |
graphicFit | "none" | "contain" | "cover" | contain | How the graphic fits the box. |
opacity | number | 1 | Sets the opacity of the whole block, including the fallback image. |
maxDpr | number | 1.5 | Caps device pixel ratio for sharper output without runaway GPU cost. |
maxFps | 30 | 45 | 60 | 60 | Caps the animation frame rate for performance-sensitive pages. |
