Water Surface shader preview: Open water from above, mirroring the sky or your image, rippled by wind and rain.
ittybitty

Water Surface

Open water from above, mirroring the sky or your image, rippled by wind and rain.

Code

The usage always matches the preview, layers and performance settings included. No build step or package.

Use as
Code view

Copy embed gives one block to paste into any page or site builder, no setup. For your own code: add surface.js, ittybitty-shader.js, runtime.js, pointer.js, texture.js next to this page. Highlighted values follow the controls.

<!-- Quickest: one element. Size it with CSS; it fills its box. -->
<script type="module" src="./ittybitty-shader.js"></script>
<ittybitty-shader effect="surface" style="width: 100%; height: 480px;"></ittybitty-shader>

<!-- Or with JavaScript, for full control: -->
<canvas id="surface" aria-hidden="true" style="width: 100%; height: 480px; display: block"></canvas>

<script type="module">
  import { surface } from './surface.js';

  const canvas = document.getElementById('surface');
  const effect = surface(canvas, {
    showWater: true,
    showReflections: true,
    showGlints: true,
    speed: 0.5,
    scale: 1,
    waves: 0.6,
    chop: 0.5,
    wind: 30,
    rain: 0,
    reflection: 0.7,
    sun: 0.6,
    source: 'sky',
    image: '',
    interactive: true,
    responsiveness: 0.5,
    sky: '#5f9fd8',
    clouds: '#f4f6f8',
    water: '#0b3346',
    // Performance
    dpr: 2,
    adaptive: true,
  });

  // Later: effect.set(…), effect.pause(), effect.resume(), effect.destroy()
</script>

Details

Wind waves and a finer chop, with optional rain rings, all with exact slopes. The surface mirrors a sky with drifting clouds, or your own image, and weighs that reflection against the water’s own colour as real water does: more mirror where ripples tilt, more depth where the water lies flat. Transparent, it becomes a film of reflections over anything.

Payload
7.7 KB brotli for surface.js and ittybitty-shader.js and runtime.js and pointer.js and texture.js, measured at build time. See the method.
Resolution
Device pixel ratio capped at 2, so the ripples stay crisp. Adaptive resolution steps down on slow devices.
Frame rate
Display rate.
When unseen
Stops rendering when the canvas leaves the viewport or the tab is hidden, and resumes where it left off.
Reduced motion
Shows a single still frame. Controls still update it.
Layers
Up to five effects fuse into one shader and one draw call. Filters such as dithering and halftone process the layers beneath them.
Browsers
Any browser with WebGL2: Chrome and Edge 56+, Firefox 51+, Safari 15+.
Licence
MIT. Copy it, change it, ship it.