Engraving shader preview: Any image, or the layers beneath, engraved like a banknote.
ittybitty

Engraving

Any image, or the layers beneath, engraved like a banknote.

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 engraving.js, ittybitty-shader.js, runtime.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="engraving" style="width: 100%; aspect-ratio: 16 / 10;"></ittybitty-shader>

<!-- Or with JavaScript, for full control: -->
<canvas id="engraving" aria-hidden="true" style="width: 100%; aspect-ratio: 16 / 10; display: block"></canvas>

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

  const canvas = document.getElementById('engraving');
  const effect = engraving(canvas, {
    showPaper: true,
    showRosette: true,
    showBorder: true,
    image: '/examples/still-life.webp',
    lines: 'waves',
    spacing: 3,
    angle: 20,
    relief: 0.6,
    contrast: 1.3,
    petals: 12,
    wear: 0.3,
    ink: '#1e3a2f',
    tint: '#9dbba6',
    paper: '#efeadb',
    // Performance
    dpr: 2,
    adaptive: true,
  });

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

Details

Intaglio lines that swell with the darkness beneath them and bend with the brightness of the picture, with a second set across the deepest shadows. Behind it, in a paler ink, a guilloché rosette of interlaced curves and a woven guilloché border. Static: one draw per change.

Payload
6.9 KB brotli for engraving.js and ittybitty-shader.js and runtime.js and texture.js, measured at build time. See the method.
Resolution
Device pixel ratio capped at 2.
Frame rate
None. One frame per change.
When unseen
Stops rendering when the canvas leaves the viewport or the tab is hidden, and resumes where it left off.
Reduced motion
Nothing to change: it never moves.
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.