Shader graph
Shader fills built from nodes wired together — every built-in preset — and the knobs every unwired input becomes.
A shader graph is a shader fill made of nodes instead of code: noise, gradients, plasma and rings, warps like zoom, kaleidoscope and tunnel, color ramps and blends, a feedback node for trails, and an Audio node that listens to the timeline's sound. PopCraft compiles the graph into an ordinary shader fill, so everything a shader fill has, a graph has too: it draws on the GPU, it plays in Animate, Present and exports, and its knobs can be keyed.
Every built-in shader preset is a shader graph: the backgrounds (Mesh gradient, Waves and the rest), the effects (particles, lines, bursts and light rays) and the audio visualizers (Zoom feedback, Kaleidoscope, Plasma pulse, Synth tunnel, Starfield warp, Liquid ink). Pattern nodes give a value that a Mix or Blend colors; effect nodes draw in color themselves, the effects with transparency so they layer over a picture.
Make a shader layer
Description
A launch post in Animate with the Design panel open. R picks the rectangle tool and a rectangle is dragged out across the post. Its fill opens from the Design panel; Shader is picked, then Kaleidoscope under Audio visualizers, and the rectangle fills with a turning kaleidoscope. Space plays it: a shader graph that reads time moves on its own.
- Press R and drag out a rectangle. Any layer with a fill works too, the frame's background included.
- Open its fill in the Design panel.
- Choose Shader, then any preset: each tile plays a short loop of it. Edit nodes opens the preset's graph. To build a graph from nothing instead, click Build with nodes (the + beside Edit nodes; see Edit the nodes).
- Press Space to play it. A graph that reads time moves on its own, and its audio inputs follow the timeline's sound (see Audio-reactive motion).
Tune its knobs
Every input of a node that no wire feeds is a knob: a shader param named <node>_<input>, listed in the Design
panel under the fill. Changing a knob re-renders straight away without recompiling, so dragging one, keying one or
driving one from the music is cheap.
Description
The Synthwave tunnel visualizer in Animate with its Neon tunnel layer selected. The Design panel lists the graph’s knobs: every unwired input of its nodes. A knob’s value is typed and the tunnel changes at once, without recompiling; Space plays it with the music.
- Select the layer with the graph fill. Its knobs are listed under the fill in the Design panel.
- Type a new value, or drag the field.
- Click a knob's ◆ to key it, the way you'd key any property, or give it a behaviour (an audio behaviour makes it follow the sound).
Edit the nodes
The node editor opens under the canvas, the way the timeline does. Every node shows a live preview of the graph up to that node, so you can see what each step adds. To open it, select the layer with the graph fill and click Edit nodes under the fill in the Design panel (or in the fill's Shader tab).
The video builds a graph from nothing and goes through every step below; each step is a chapter you can jump to.
Description
A launch post whose frame has the Plasma shader fill, its fill open. Build with nodes (the + beside Edit nodes) opens the node editor under the canvas with only the Output node. A double-click on empty space opens the node search and Plasma is added; a wire from its output into the Output's color makes the frame draw it. The Output is dragged to the right, and a wire dropped from Plasma onto empty space adds a Color ramp already wired; wiring the ramp into the Output replaces the old wire and the frame turns purple. Selecting Plasma shows its knobs on the right, and its scale is typed. Shift+A adds Noise, which is dragged under Plasma; a marquee selects both, Cmd+D duplicates them with their knob values and Delete removes the copies. A wire is dragged off the Output's input to disconnect it, another is disconnected from its right-click menu, and Cmd+Z brings both back. Scrolling pans, Cmd+scroll zooms, and F fits the graph.
- Click Build with nodes (the + beside Edit nodes) in the fill's Shader tab. The graph replaces the shader, and the editor opens with only the Output node.
- Double-click empty space and pick a node: type part of its name and press Enter.
- Drag from a node's output (the dot on its right) to another node's input to wire them. Wire into the Output node's color, and the layer draws it.
- Drag a node by its body to move it.
- Drop a wire on empty space to add a node there, already wired from the node you dragged it out of.
- Wire it into the Output. A wire into an input that already has one replaces it.
- Select a node to see its options and knobs on the right. Type a knob's value or drag the field.
- Press Shift+A, or click +, to search for a node and add it in the middle of the view.
- Drag across empty space to select several nodes. Shift-click adds a node to the selection or takes it out.
- Cmd/Ctrl+D duplicates the selection, knob values included. Delete removes it.
- Drag an input's wire away and let go on empty space to disconnect it.
- Right-click a wire and choose Disconnect.
- Cmd/Ctrl+Z undoes each change, one step at a time.
- Scroll to pan, and pinch or hold Cmd/Ctrl and scroll to zoom. Middle-drag also pans.
- Press F to fit the whole graph in view.
Right-clicking a node offers Duplicate and Delete; right-clicking empty space offers Add node here and Fit graph. Click a wire to pick it, and Delete disconnects it. Cmd/Ctrl+A selects every node, the arrow keys nudge the selection (Shift for bigger steps), and Escape clears the selection, then closes the editor. The state machine graph is the same editor, so all of this works there too.
Wiring an input turns its knob off: the knob's value and any key or audio behaviour on it go away, because the wire now drives that input. Disconnect the wire and the input gets its knob back at the node's default. A node that isn't wired through to the Output draws nothing yet, but its knobs keep their values for when it is.
Save in the Shader tab keeps the graph with its knob values under My shaders, and Publish puts it in a shader pack with the graph included, so a saved or installed node shader opens in the node editor again. See Save and share your shaders. Editing its WGSL by hand turns it into plain code: the graph goes, because it would overwrite the edit.
How a graph works
- Nodes are fields. Each node is a function of the pixel's position, and a node reads an input by asking the node wired into it for its value at that position. Most pass the position straight on; the warp nodes (zoom & rotate, kaleidoscope, tunnel, liquid warp, mirror) ask at a moved position, which is how they bend everything upstream.
- Feedback without the frame before. The feedback node reads its input many times, each echo zoomed and turned a step further and read a little earlier in time. That gives MilkDrop's trails while every frame stays a pure function of its time and knobs: scrubbing, looping and exporting all agree.
- Ports convert. Values are numbers, 2D and 3D vectors, and colors. Wiring one kind into another converts it: a number spreads to a grey, a color reads as its brightness.
- The Audio node is the graph's music input. It compiles to a knob marked
@audio, which gets an audio behaviour when the fill is applied.
The nodes
| Group | Nodes |
|---|---|
| Inputs | Coordinate, Time, Value, Color, Audio, Beat, Previous frame, Image |
| Maths | Math, Remap, Smoothstep, Component |
| Color | Mix, Blend, HSV color, Color ramp, Posterize, Brightness, Luma, Duotone, Gamma & filter |
| Patterns | Noise, Gradient, Circle, Plasma, Starfield warp, Rings, Grid, Waves, Twinkling stars, Pulsing grid, Spectrum, Shape, Motion vectors |
| Effects | RGB split, Blur, Glow, Edges, Halftone, Scanlines, Border, Code, Mesh gradient, Rainbow plasma, Particles (petals, rain, snow, sparkles, confetti, embers or dust), Focus lines, Speed lines, Impact burst, Light rays |
| Warps | Zoom & rotate, Kaleidoscope, Tunnel, Polar tunnel, Liquid warp, Mirror, Echo, Feedback |
| Out | Output, Feedback buffer |
Image is the picture the graph is put on: a video clip's whole frame when the graph is a shader effect in Edit mode. Feed it into RGB split, Blur, Glow, Edges, Halftone, Scanlines, Duotone or any warp to process footage. On a layer's fill there is no picture beneath, so it reads as transparent.
MilkDrop presets
Everything a MilkDrop preset is made of has a node, so a preset can be rebuilt in a graph (or ask the agent to convert
one: paste the .milk file into the chat).
| In the preset | In the graph |
|---|---|
Per-frame equations: beat detection, index = (index + is_beat) % 4, values that glide on each hit, rand() | Beat: index (steps 0 … steps−1, one per every beats), count, glide (eases to the next step on each hit), random (a new value each step), flash. It listens to the music's beat count, a new audio signal. Math and Remap do the rest of the arithmetic. |
The frame before (sampler_main) and fDecay | Previous frame (with its decay), and a Feedback buffer node for what is kept: MilkDrop keeps its warped buffer and shows it through the comp shader, which is never fed back |
Per-pixel motion: zoom, rot, dx/dy, sx/sy, cx/cy | A Code node reading the previous frame at the moved position, or for quick trails Feedback: zoom, rotate, warp (dx/dy), stretch (sx/sy), center |
decay and the warp shader's ret = crisp * .99 - .01 | Feedback's decay and fade |
| The warp shader's own wobble | A Code node wired into Feedback's warp: its .xy is how far each pixel moves |
| The comp shader | Polar tunnel for the classic tube, or a Code node: input(q) is GetPixel, blur(q) is GetBlur |
| Custom shapes (sides, rad, ang, colors, border, textured) | Shape, put over the rest with Blend (add for an additive shape) |
| Waveforms | Spectrum: ring, bars or line |
Video echo (fVideoEchoZoom, fVideoEchoAlpha, orientation) | Echo |
| Outer and inner borders | Border |
fGammaAdj, darken, brighten, solarize, invert | Gamma & filter |
| Motion vectors | Motion vectors |
A graph with a Previous frame node keeps state: each frame draws over the last, as MilkDrop does, and its decay is per 30th of a second (MilkDrop's 30 fps), so it fades the same at any frame rate. A short jump forward (under two seconds) catches up in steps; scrubbing back or jumping further replays the seconds before it — until an earlier frame adds less than one color level, up to six seconds — so a frame you land on looks like it does when played. A graph has at most one Feedback buffer node. An export plays from the start, frame by frame. What a preset counts frame by frame comes from the music: the beat count is how many beats the track has had up to that moment.
The Code node runs WGSL you write: statements ending in a return of a color, with uv, time, res, aspect,
four knobs a to d, input(q), blur(q), and prev(q) and prevBlur(q) (the previous frame). The node's inspector
highlights the WGSL; the expand button opens it in a larger window. Your edit applies when you leave the field or press
Mod+Enter. Code that does not compile is refused with the compiler's errors.
New nodes go on top of the layer's other fills, so a frame's own background never hides them.
The command palette adds any of these to the selected layer's node shader (Add shader node: Beat, …). Plugins
call popcraft.editShaderGraph({ id, fill, op }), the CLI popcraft run <file> shader.editGraph --params '{"id": "…", "fill": "f1", "op": {"op": "addNode", "kind": "beat", "x": -240, "y": 0}}',
and the agent edit_shader_graph: one command behind all of them.
A graph is stored on the fill (Paint.shaderGraph): nodes and edges in maps keyed by id. The
file format has the full shape. The graph is one value of the layer's fills, so if two people edit the
same graph at the same moment, the last edit wins.
Shader assets
A shader can be kept with the file and reused like an image. In the Assets panel, Shaders lists them with a live thumbnail:
- Save (+) keeps the selected layer's shader fill (its node graph or WGSL, with its knob values).
- Upload reads a
.wgslfile (definingfn shade(uv: vec2f, res: vec2f, time: f32) -> vec4f) or a graph.json({ "nodes": …, "edges": … }, or a file you downloaded from here). - Click a shader to add it as a fill on top of the selected layer. A graph stays editable in the node editor.
- In Edit, a clip's Shaders list has Add from shader assets…, for graphs that read the clip through an image node.
- Each one can be downloaded or removed. Layers it was applied to keep their shader.
The palette has Save shader to assets and Apply newest shader asset. Plugins call popcraft.saveShaderAsset,
importShaderAsset, applyShaderAsset, removeShaderAsset and getShaderAssets; the CLI runs shader.saveAsset,
shader.importAsset, shader.applyAsset, shader.removeAsset and shader.listAssets; the agent has
save_shader_asset, import_shader_asset, apply_shader_asset, remove_shader_asset and get_shader_assets. Shader
assets are stored with the file (shaderAssets), so everyone editing it sees them.