ComfyUI lab 7: Write inspectable shader looks
Use coordinate and channel math for deterministic color transforms before reaching for another diffusion pass.
Listen to this article
On-device voiceUses the voice built into your browser; no article text leaves this page.
Audio narration is not supported by this browser.
Diffusion is expensive and nondeterministic. Many finishing operations—channel mixing, vignettes, gradients, masks, scanlines, palette shifts—are ordinary pixel math and should remain ordinary pixel math.
Read the image contract
A ComfyUI IMAGE is normally a batch shaped B × H × W × C, with floating values from zero to one. The shader node exposes red, green, blue, normalized x/y coordinates, and time t. Its expression returns either one grayscale plane or an RGB tuple. Output is clipped into the valid range.
The supplied expression mixes a little blue into red, preserves green, and lifts blue for a cool editorial grade. Every coefficient is inspectable. Set all channels to (r,g,b) for an identity test; change one coefficient at a time; compare histograms and skin tones.
Animate parameters, not code
For motion, keep the expression stable and vary t or another scheduled input. A sine function can drive a pulse, x/y can define spatial wipes, and an audio-derived value can modulate strength. Do not concatenate arbitrary code strings per frame when one parameter expresses the change.
Shader math cannot restore clipped highlights or infer missing objects. Use it where the desired output is a known transformation of existing pixels, and use a generative model only where new content is genuinely required.
Run the lab
- Open this graph in Comfy Studio
- Download the exact API-format workflow
- CLI:
app comfy download shader-style-lab
Record the graph JSON, input assets, seed where relevant, model or service version, custom-node commit, and final artifact together. That bundle—not a screenshot—is the reproducible creative unit.
Open-source map
- Open shader node — MIT numpy expression node used by the graph
- RyanOnTheInside — Advanced reactive effects and particle systems
Creative Systems Labs: 7 of 12. Previous: Build style as a system Next: Prototype frame transforms safely