Tall Grass shader preview: A meadow of tall grass with the wind rolling through it, realistic, cartoon or pixel.
ittybitty

Tall Grass

A meadow of tall grass with the wind rolling through it, realistic, cartoon or pixel.

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

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

<script type="module">
  import { tallGrass } from './tall-grass.js';

  const canvas = document.getElementById('tall-grass');
  const effect = tallGrass(canvas, {
    showSky: true,
    showSun: true,
    showGrass: true,
    showGround: true,
    showSeeds: true,
    style: 'realistic',
    speed: 0.6,
    zoom: 1,
    wind: 0.6,
    density: 0.6,
    height: 0.6,
    plumes: 0.3,
    sun: 0.25,
    interactive: true,
    responsiveness: 0.5,
    grass: '#5f8a2e',
    plume: '#f2e6c8',
    sky: '#6f93c4',
    horizon: '#f6d7a8',
    // Performance
    dpr: 2,
    adaptive: true,
  });

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

Details

Row upon row of tall grass recedes into haze while gusts roll across the field in waves. Realistic, with dark roots and tips that glow when backlit by a low sun; cartoon, in flat two-tone blades with inked edges; or pixel, in chunky blocks with a dithered sky. The pointer parts the grass as it moves through, and a swipe sends a gust.

Payload
8.4 KB brotli for tall-grass.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.