
Ship something
people remember.
A button that wakes up when you reach for it.
Pebbles
Huge, smooth glass pebbles, dark as obsidian, with coloured light glowing through them.
This browser cannot run WebGL2, so this is a still image. The code below works wherever WebGL2 is available.
Code
For your own build, add pebbles.js, ittybitty-shader.js, runtime.js and pointer.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="pebbles" style="width: 100%; aspect-ratio: 2 / 1;"></ittybitty-shader>
<!-- Or with JavaScript, for full control: -->
<canvas id="pebbles" aria-hidden="true" style="width: 100%; aspect-ratio: 2 / 1; display: block"></canvas>
<script type="module">
import { pebbles } from './pebbles.js';
const canvas = document.getElementById('pebbles');
const effect = pebbles(canvas, {
speed: 0.5,
count: 3,
size: 1,
roundness: 0.35,
clarity: 0.6,
frost: 0.75,
refraction: 0.7,
rim: 0.3,
grain: 0.12,
backdrop: [[0, '#01655b'], [0.5, '#5a5646'], [1, '#c42414']],
glass: '#504a44',
glowColor: '#a00c06',
depth: false,
interactive: true,
responsiveness: 0.5,
// Performance
dpr: 1.5,
adaptive: true,
});
// Later: effect.set(…), effect.pause(), effect.resume(), effect.destroy()
</script>
Details
Big rounded pebbles of dark glass, piled up and cropped by the frame. Light glows through their bodies in deep colour, whatever is behind a pebble shows through it bent and softened by frosting, and thin bright lines trace the rims where light grazes them. They drift, turn and breathe slowly; the pointer nudges them aside and the light follows it.
- Payload
- 10.1 KB brotli for pebbles.js, ittybitty-shader.js, runtime.js and pointer.js, measured at build time.
- Resolution
- Device pixel ratio capped at 1.5. One pass: each pixel looks through its frontmost pebble at the pebbles behind, evaluated directly rather than read back from a buffer.
- 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 and the pointer 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.