Nebula shader preview: A slow drift through a stellar nursery: glowing gas, dark dust and young stars with telescope spikes.
ittybitty

Nebula

A slow drift through a stellar nursery: glowing gas, dark dust and young stars with telescope spikes.

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

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

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

  const canvas = document.getElementById('nebula');
  const effect = nebula(canvas, {
    spikes: true,
    palette: 'hubble',
    colorA: '#ff3d6e',
    colorB: '#3ad6ff',
    form: 'pillars',
    density: 0.45,
    glow: 1,
    dust: 0.4,
    turbulence: 0.7,
    stars: 0.6,
    speed: 0.4,
    camera: 'drift',
    interactive: true,
    responsiveness: 0.4,
    // Performance
    dpr: 1,
    adaptive: true,
  });

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

Details

Clouds of glowing gas are marched through front to back, so they both shine and hide what lies behind them, while lanes of dust stand out dark and redden at their edges. Bright young stars sit inside the gas, light it from within and shine through it with the diffraction spikes of a space telescope, over a dense field of pin-sharp stars. Pillars, cliffs or open clouds, in Hubble, Webb or your own colours. The pointer steers the view.

Payload
14.4 KB brotli for nebula.js, ittybitty-shader.js, runtime.js and pointer.js, measured at build time.
Resolution
Device pixel ratio capped at 1, so the stars stay crisp; the gas is marched at a quarter of that, half its rows each frame in turn, and smoothed as it is scaled up.
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.