Shadershed

Fragment shader
Built-in uniforms (read-only)
Reference

Custom uniforms

Declare a uniform and a control for it appears under the canvas. The comment sets the range, = sets the starting value, and color swaps a vec3's three sliders for a colour picker.
uniform float speed;    // 0.0 .. 4.0 = 1.5
uniform int   steps;    // 1 .. 64 = 24
uniform bool  shadows;
uniform vec2  centre;   // -1.0 .. 1.0
uniform vec3  tint;     // color

Buffer

The Buffer tab holds a second mainImage that draws to an offscreen texture instead of the screen. Both passes compile together, and either can read the result by pointing an iChannel at Buffer. Read it from Buffer's own shader and you get last frame — which is what makes trails, feedback and simulations possible.

The texture is 32-bit float RGBA, and all four channels come back exactly as written — unclamped, and including alpha. The Image pass is the one exception: it draws to the screen, so its alpha is forced to 1 and fragColor.a there is ignored. A fresh Buffer texture starts at vec4(0.0), so frame 0 reads zeroes rather than junk.
// Buffer: velocity in .xy, age in .z, mass carried in .a
fragColor = vec4(velocity, age, mass);

// Image: read all four back, .a included
vec4 state = texture(iChannel0, uv);

Keyboard

Click the canvas first, or you'll just be typing into the editor. The texture is 256×3: a column per key, and a row each for held, pressed-this-frame and toggled. Dragging on the canvas works the arrow keys too, so a keyboard shader runs on a trackpad or a phone — that only engages while a channel is set to Keyboard, so it stays out of the way of shaders using iMouse.
float held    = texture(iChannel0, vec2(KEY/256.0, 0.5/3.0)).x;
float pressed = texture(iChannel0, vec2(KEY/256.0, 1.5/3.0)).x;
float toggled = texture(iChannel0, vec2(KEY/256.0, 2.5/3.0)).x;
// KEY is the old keyCode: 32 space, 37-40 arrows, 65-90 A-Z, 48-57 0-9

Voronoi

Three fields packed into channels.
float cell   = texture(iChannel0, uv).r;   // distance to the nearest point
float border = texture(iChannel0, uv).g;   // margin to the second nearest
float id     = texture(iChannel0, uv).b;   // flat random, one per cell
Bilinear filtering suits the distances but incorrectly blends cell ids for .b. Use texelFetch for exact ones.

Share links

Shader code is comressed and written after the #, so nothing is stored on the server.