ShaderMate
GPU magic in a few lines of JavaScript. Multipass buffers, feedback, textures, live uniforms and shader UI with zero WebGL boilerplate.
Real 3D.
No engine.
Signed distance fields, lighting and reflections, all inside one fragment shader.
createShader({ shader: 'raymarch.glsl' });
Open the example →
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 →
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 →
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 →
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 →
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' });
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 →
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
Backgrounds, headlines, buttons, cards. Point it at a canvas and go.
createShader({ canvas: '#headline', shader: marble });
Open the example →
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: 30Use 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 defaultShare a canvas
Many shaders, one WebGL context. Swap with play/pause.
a.pause(); b.play(); // same canvasStart 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);
}`,
});<canvas id="hero"></canvas>
<script src="https://cdn.jsdelivr.net/npm/shadermate@2/dist/shadermate.min.js"></script>
<script>
ShaderMate.createShader({ canvas: '#hero', shader: 'hero.glsl' });
</script>// npm i shadermate
import { ShaderCanvas } from 'shadermate/react';
export function Hero({ hover }) {
return (
<ShaderCanvas
shader={frag}
uniforms={{ u_hover: hover ? 1 : 0 }}
style={{ width: '100%', height: 320 }}
/>
);
}Next: quick start · writing shaders · migrating from 1.x