
Papercut
A layered cut-paper scene with real shadows and parallax.
This browser cannot run WebGL2, so this is a still image. The code below works wherever WebGL2 is available.
Code
The usage always matches the preview, layers and performance settings included. No build step or package.
Copy embed gives one block to paste into any page or site builder, no setup. For your own code: add papercut.js, ittybitty-shader.js, runtime.js, 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="papercut" style="width: 100%; aspect-ratio: 16 / 10;"></ittybitty-shader>
<!-- Or with JavaScript, for full control: -->
<canvas id="papercut" aria-hidden="true" style="width: 100%; aspect-ratio: 16 / 10; display: block"></canvas>
<script type="module">
import { papercut } from './papercut.js';
const canvas = document.getElementById('papercut');
const effect = papercut(canvas, {
showSky: true,
showSun: true,
showShadows: true,
showGrain: true,
scene: 'hills',
layers: 6,
depth: 0.6,
speed: 0.3,
seed: 3,
interactive: true,
responsiveness: 0.5,
sky: '#f6d7b0',
far: '#e9a07a',
near: '#3b2a4a',
// Performance
dpr: 2,
adaptive: true,
});
// Later: effect.set(…), effect.pause(), effect.resume(), effect.destroy()
</script>
Details
Sheets of coloured card cut into hills, peaks, waves or a pine forest, stacked in a shadow box. Each has the grain of card and a cut edge that catches the light, and throws a soft copy of its silhouette onto the sheet behind. Colours run from pale at the back to deep at the front. The pointer shifts the sheets by their depth, and the scene drifts slowly.
- Payload
- 6.9 KB brotli for papercut.js and ittybitty-shader.js and runtime.js and pointer.js, measured at build time. See the method.
- Resolution
- Device pixel ratio capped at 2.
- Frame rate
- Display rate while drifting.
- 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. The pointer still shifts the sheets.
- 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.