Sakura shader preview: Cherry blossom petals drifting through the air in depth, tumbling and catching the light.
ittybitty

Sakura

Cherry blossom petals drifting through the air in depth, tumbling and catching the light.

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

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

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

  const canvas = document.getElementById('sakura');
  const effect = sakura(canvas, {
    showSky: true,
    showFar: true,
    showNear: true,
    speed: 0.5,
    amount: 0.6,
    size: 1,
    wind: 0.5,
    depth: 0.6,
    interactive: true,
    responsiveness: 0.5,
    petal: '#ffd9e4',
    blush: '#f39ab4',
    top: '#bcd8f0',
    bottom: '#fbe7ee',
    // Performance
    dpr: 2,
    adaptive: true,
  });

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

Details

Notched sakura petals fall in four layers of depth, each one tumbling as it goes: narrowing as it turns edge-on, glowing at its thin tip, blushing at its base, and blurring the further it sits from the focal plane. A breeze carries them; the pointer sends gusts through them.

Payload
6.3 KB brotli for sakura.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.
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.