Introduction

What ShaderMate is, what it is for, and where to start.

2 min read

ShaderMate puts a GLSL fragment shader on any canvas. You write the shader; it handles the WebGL context, compiling, sizing, the render loop, input, textures and multipass buffers. It has no dependencies and ships as a single file for <script> tags, an ES module for bundlers, and optional React and tweak-panel add-ons.

HTML
<canvas id="hero"></canvas>
<script src="https://cdn.jsdelivr.net/npm/shadermate@2/dist/shadermate.min.js"></script>
<script>
  ShaderMate.createShader({
    canvas: '#hero',
    shader: `
      void main() {
        vec2 uv = gl_FragCoord.xy / u_resolution;
        fragColor = vec4(0.5 + 0.5 * cos(u_time + uv.xyx + vec3(0, 2, 4)), 1.0);
      }`
  });
</script>

You write ordinary WebGL GLSL. There is no precision line, no out vec4, and no uniform declarations to copy from page to page: the built-ins you use are declared for you.

What it is for#

What you get#

Where next#