01 / 13
v2.0.1 is here · free & MIT open source

ShaderMate

GPU magic in a few lines of JavaScript. Multipass buffers, feedback, textures, live uniforms and shader UI with zero WebGL boilerplate.

Get started See the examples $ npm i shadermate
23 KB gzippedzero dependenciesWebGL 1 + 2ShaderToy-compatible
02 · Raymarching

Real 3D.
No engine.

Signed distance fields, lighting and reflections, all inside one fragment shader.

createShader({ shader: 'raymarch.glsl' });
Open the example →
03 · Built-in uniforms

Feels
alive.

iTime, iMouse, iResolution, iFrame and friends are declared and fed in for you. Just use them.

pointer: { smooth: 0.15 }   // iMouse, eased
Open the example →
04 · Ping-pong buffers

Feedback
loops.

One flag gives a pass its own previous frame. Paint with light, leave trails, make smoke.

{ name: 'trail', pingpong: true, float: true, channels: ['trail'] }
Open the example →
05 · Textures

Bring your
own pixels.

Images, video, webcam, audio FFT or any canvas plug straight into iChannel0–3. This one is a 2D canvas.

channels: [myCanvas, 'photo.jpg', { camera: true }]
Open the example →
06 · Multipass

Stack passes
like layers.

Render a scene, pipe it into post-FX. Synthwave into a 4×4 Bayer dither, with an x-ray lens.

passes: [
  { name: 'scene',  shader: synthwave },
  { name: 'dither', shader: dither, channels: ['scene'] },
]
Open the example →
07 · Custom uniforms

Wire it to
your UI.

Set a value in JS, see it on the GPU next frame. Types are inferred. Tween any of them with easing.

sm.set('u_hue', 0.5);
sm.tween('u_twist', 3, { duration: 600, ease: 'outCubic' });
08 · Live GUI

Tweak it
live.

One call builds a panel from your uniforms. Here: an animated mesh-gradient generator for your next hero.

await createGui(sm);   // shadermate/gui
Open the example →
09 · Shader UI

Buttons,
but shaders.

Real, accessible buttons with a canvas behind the label. Hover, press and click are tweened uniforms.

pointer: { target: button, smooth: 0.2 }
All 16 buttons →
10 · GPU simulation

Simulate
anything.

Four chained float passes give 240 reaction-diffusion steps a second.

{ name: 'B', float: true, size: 'half', channels: ['A'] }   // ×4, chained
Open the example →

SHADEANYTHING

11 · Any canvas

Backgrounds, headlines, buttons, cards. Point it at a canvas and go.

createShader({ canvas: '#headline', shader: marble });
Open the example →
12 · Everything in the box

The line that
does it.

Fill a box or the page

Follows a canvas's CSS size, or makes a full-window canvas.

createShader({ shader, size: 'window' });

React to the cursor

Across the page, or only over one element.

pointer: { target: button, smooth: 0.2 }

Animate any value

Tween uniforms with easing, per component.

sm.tween('u_glow', 3, { ease: 'outCubic' });

Save a still or a clip

PNG screenshots and WebM recordings.

await sm.record({ duration: 5000 });

Stay quiet off-screen

Pauses when the tab is hidden or scrolled away.

pauseWhenHidden: true,  maxFps: 30

Use it from React

Props update uniforms without a rebuild.

<ShaderCanvas shader={frag} uniforms={{ u_hover }} />

Paste from ShaderToy

mainImage, iChannels and iMouse just work.

createShader({ shader: shadertoyCode });

Catch errors inline

Compile errors in an overlay, with line numbers.

errorOverlay: true   // the default

Share a canvas

Many shaders, one WebGL context. Swap with play/pause.

a.pause(); b.play();   // same canvas

Browse the recipesFull API reference →

13 · Install

Start in
a minute.

Size
23 KB gzipped core
Dependencies
None
WebGL
1 and 2, picked for you
Builds
Script tag, ESM, CJS, TypeScript
Add-ons
shadermate/gui · shadermate/react
License
MIT
// npm i shadermate
import { createShader } from 'shadermate';

createShader({
  canvas: '#hero',
  shader: `void mainImage(out vec4 o, in vec2 fc) {
    vec2 uv = fc / iResolution.xy;
    o = vec4(uv, 0.5 + 0.5 * sin(iTime), 1.0);
  }`,
});

Next: quick start · writing shaders · migrating from 1.x