Spectrum shader preview: Light split by a prism and smeared through rough glass onto film.
ittybitty

Spectrum

Light split by a prism and smeared through rough glass onto film.

Code

Use as
Code view

Copy embed: paste into Webflow, Framer, Squarespace or any HTML · Copy for agent: paste into Cursor or Claude · Copy code: the files for your own build.

For your own build, add spectrum.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="spectrum" style="width: 100%; height: 480px;"></ittybitty-shader>

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

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

  const canvas = document.getElementById('spectrum');
  const effect = spectrum(canvas, {
    speed: 0.3,
    angle: -50,
    beams: 1,
    width: 0.18,
    dispersion: 1.6,
    palette: 'film',
    hue: 0,
    glass: true,
    mottle: 0.15,
    texture: 1.5,
    smear: 0.5,
    crinkle: 0,
    intensity: 1.4,
    backdrop: '#1a3c44',
    grain: 0.06,
    interactive: true,
    responsiveness: 0.5,
    // Performance
    dpr: 1,
    adaptive: true,
  });

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

Details

Soft beams of light arc through the frame, each broken into its wavelengths so it fans out into a band of colour, violet on one side and red on the other. Rough glass folds the bands into patches and drags them out like a long exposure, mottling the colours where the dispersion changes. Palettes mimic how film or a sensor records a spectrum, finished with a violet glow and film grain.

Payload
10.3 KB brotli for spectrum.js, ittybitty-shader.js, runtime.js and pointer.js, measured at build time.
Resolution
Device pixel ratio capped at 1; the light is soft and the grain is drawn per CSS pixel.
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.