Shader

Run a custom WGSL or GLSL fragment or compute shader.

What it does

Runs your own WGSL or GLSL code on the GPU, either as a per-pixel fragment shader or as a full compute shader. Wire an image into Content In and the shader processes it; leave Content In unconnected and the shader generates an image from scratch.

A @param comment in the code becomes a live control on the node with no separate wiring, for example // @param float brightness 0.0 2.0 1.0 "Brightness control". Built-in uniforms for resolution, time and frame number are available to every shader.

When to use it

ParameterTypeDefault
content_inOneOf([FieldOf(Raster)])
languageString"WGSL"
shader_typeString"Fragment"
wgslString"DEFAULT_FRAGMENT_SHADER"
use_canvas_sizeBooleantrue
widthNumber512
heightNumber512
positionVec3(0, 0, 0)
rotationVec3(0, 0, 0)
scaleVec3(1, 1, 1)
anchorVec3(0, 0, 0)
opacityNumber1

Gotchas

Shader code written for Shadertoy or in ISF format is detected and converted automatically. Where detection fails, the code runs as plain GLSL or WGSL instead, which may not match what the source expected. The log records the result.

Width and Height apply only in generator mode, with no image wired into Content In and Use Canvas Size off. With an image connected, or with Use Canvas Size on, the output resolution follows the input or the canvas.

Compute shaders get full GPU access, including storage textures and arbitrary writes. Fragment shaders are restricted to per-pixel sampling and output. Use Compute only where the effect needs that access. Most image effects run as Fragment, and more predictably.

Worked example

  1. Add a Shader node. Leave Content In unconnected to work as a generator.

  2. Open the shader code editor and write your WGSL, adding an @param line for anything that should be a live control, for example a colour or a brightness value.

  3. Turn off Use Canvas Size and set Width/Height for a specific output resolution instead of following the canvas.

  4. Wire an image into Content In to process existing footage instead of generating from nothing.

See also

Hydra · Visual Plugin · Attribute Wrangle · Rasters (images)