Write Your Own Visualizer Look: A Shader in Ten Minutes
Write a Visualizer shader without leaving Audio Workbench: the device's own editor has colouring, suggestions, live problems and a preview, and redraws as you type while the music keeps playing. This walks through the editor, the file format, directives, inputs, and multi-pass @buffer/@pass pipelines.
The Visualizer device turns the sound and the notes on your bench into a picture. Besides the built-in shaders, it runs shaders you write yourself, and you can write them right on the device: open its settings, edit the code, and the picture redraws while the music keeps playing. It does for pictures what the Sound Script device does for sound.
- A shader is one text file in Godot’s shader language. The Visualizer’s settings window is a code editor for it, with colouring, suggestions as you type, a list of problems and a live preview. You never have to leave the app.
- Comment directives (
// @knob,// @pill,// @toggle,// @texture,// @mesh) build the controls and slots on the device front. // @bufferand// @passlet one file define a multi-pass pipeline (feedback trails, 2D segment strips, or 3D mesh passes) before drawing the final image.- The shader reads the spectrum, the waveform, band levels and the notes you play.
- A broken edit never blanks the picture: the device keeps the last version that worked and shows the error with its line number.
- Prefer VS Code or Rider? The same file opens there too, and the two stay in sync.
This post builds a shader from nothing. You need Audio Workbench and a patch with some sound in it.
Step 1: open the shader editor
- Add a Visualizer to the bench and wire any audio into its Audio In. The Visualizer is an end point: it makes no sound and passes nothing on.
- Look at the Shader pill on the device. It names the shader on show. Tap it and pick any shader from the list, then the rows under the list are for writing your own:
- New Shader… copies the shader on show into a new file of its own (“Name Copy”) and switches to it, so the quickest way to learn is to change what is on screen.
- Edit Shader… opens that file in your external editor (see below).
- Open Shader Folder shows the folder in your file manager.

- Click the gear in the device’s title bar. This opens the Visualizer’s settings window, and the code editor is the main part of it.
A tour of the window
The shader you wrote is on the left, and everything about it is on the right.

- Toolbar. Apply compiles the shader now, Revert goes back to the last applied text, and Apply on change (on by default for your own shaders) recompiles after a short pause in typing.
Ctrl+Enterapplies too. Save, the name box and Load at the right are the device’s patch controls, for saving a whole Visualizer setup as a preset. - Source badge. The line above the code says where the shader lives. YOUR SHADER is a
.gdshaderfile in your Visualizer folder, and the editor writes to that file as you type. The small arrow icon opens the same file in your external editor. - The code. Line numbers, colouring for keywords, functions, the app’s
u_inputs and the//directive lines that build the device front. Suggestions open as you type: after// @you get the directives, after a directive its settings (min=,max=,default=), and elsewhere the Visualizer’s inputs, your own declared controls and the shader language’s words.Ctrl+Spaceopens the list on demand. - Problems. A compile error appears here with its line number. More on that below.
- Inputs. The controls and slots your header lines create, read live from the text: each knob, pill, toggle, model and image, and the uniform name to use in code (
u_param1,u_hero_data, …). Add a// @knobline and it shows up here as you type it. - Settings. The device’s general settings, Channels (Mono or Stereo), FFT Smoothing, Stage View and Stage Window, and Export Clip….
- Preview. The picture, live, right under the problems list, so you never have to close the window to see what you did. Flip it to Reference for a short list of the inputs and directives.
- Status bar. The problem count, your cursor position, and a reminder of the apply shortcut.
Start from a built-in shader
The shaders that come with the app can be read but never changed. Select one, open the gear, and the badge says BUILT IN, READ ONLY. Click Edit a copy to fork it into a file of your own and carry on editing there. The originals stay as they were, and reading them is a good way to learn: Fire Spectrum, for one, is a multi-pass shader that is worth a read once you reach the @buffer section below.

Prefer your own editor?
Everything above also works from VS Code, Rider or anything else. Edit Shader… on the pill opens the file (in VS Code when it is installed, otherwise your system’s default app, at the error line when there is one), and Open Shader Folder lets you open the folder as a workspace. The two stay in sync: save in your editor and the picture changes, type in the app and the file changes. If the file changes on disk while you have unapplied edits in the app, a bar offers Reload from file or Keep mine.
Any .gdshader you drop in the Visualizer shaders folder (Settings, Paths, “Visualizer shaders”) shows up in the Shader list within half a second.
Step 2: paste a working shader
Click into the editor, select everything (Ctrl+A), and paste this over it. With Apply on change on, the picture follows a moment later.
shader_type canvas_item;
// @knob1 "Punch" min=0.5 max=3 default=1.5 step=0.1 unit="x"
// @knob2 "Hue" min=0 max=360 default=200 step=1 unit="°"
// @knob3 "Bars" min=16 max=96 default=48 step=1 unit="bars"
uniform sampler2D u_spectrum : filter_linear, repeat_disable;
uniform float u_bass;
uniform float u_note_trigger;
uniform float u_param1;
uniform float u_param2;
uniform float u_param3;
vec3 hue(float h) {
return clamp(abs(mod(h * 6.0 + vec3(0.0, 4.0, 2.0), 6.0) - 3.0) - 1.0, 0.0, 1.0);
}
void fragment() {
// Which bar this pixel belongs to, and where inside it.
float bars = floor(mix(16.0, 96.0, u_param3));
float bar = floor(UV.x * bars);
float across = fract(UV.x * bars);
// Most of the music sits in the low bins, so spend more of the width on them.
float x = (bar + 0.5) / bars;
float level = texture(u_spectrum, vec2(pow(x, 2.0) * 0.6, 0.125)).r;
float height = clamp(sqrt(level) * mix(0.5, 3.0, u_param1), 0.0, 1.0);
// Cut the bar into lit cells with a gap around each one.
float rows = 28.0;
float y = 1.0 - UV.y;
float down = fract(y * rows);
float cell = step(0.12, across) * step(across, 0.88) * step(0.12, down) * step(down, 0.88);
float lit = step((floor(y * rows) + 0.5) / rows, height);
vec3 tint = hue(u_param2 + y * 0.35);
vec3 col = tint * lit * (0.8 + 0.6 * u_bass);
col += tint * 0.06 * (1.0 - lit);
col += vec3(1.0) * u_note_trigger * 0.15 * lit;
COLOR = vec4(col * cell, 1.0);
}
You should see a wall of lit cells that climbs with the music, shifts colour towards the top, brightens with the bass and flashes on each note. The three knobs on the device are now called Punch, Hue and Bars, with the ranges from the comments.

What each part does:
shader_type canvas_item;must be the first statement. Spatial and particle shaders are refused with a message.- You draw by setting
COLORinfragment().UVruns from 0 to 1 across the picture, withUV.yat 0 at the top. u_spectrumis a 256 by 4 texture. Row 0 is the left (or mono) spectrum, so row 0’s centre is at y = 0.125.texture(u_spectrum, vec2(..., 0.125)).rreads the level at one frequency. Squaring the position (pow(x, 2.0)) makes the first bars cover the low bins in detail, andsqrt(level)lifts quiet bins so a soft mix still fills the picture.fract(UV.x * bars)is the position inside the current bar, from 0 to 1. Keeping only the middle of it, and the middle of each row, is what cuts the bars into separate cells.u_bassandu_note_triggerare plain floats. The trigger jumps to 1 on each note and fades in about a fifth of a second.u_param1,u_param2andu_param3are the knobs, each 0 to 1 as the shader sees them.mix(16.0, 96.0, u_param3)turns the third one back into a bar count.
Declare only the inputs you use.
Step 3: declare controls and slots with @ directives
In the shader editor, typing @ (or // @) opens the directive list with ready-to-edit templates.
Named controls (@knob, @pill, @toggle)
Modern looks declare named controls (up to 8 knobs and 4 pill/toggle controls) that appear directly on the device faceplate:
// @viz "Neon Grid" api=1 author="You"
// @knob warp "Warp" min=0.2 max=4 default=1 step=0.1 unit="x" curve=log
// @pill mode "Mode" options="Bars,Radial,Dots" default=0
// @toggle glow "Glow" default=true
Each directive creates a uniform named u_<id>:
@knob <id> "<Label>"feedsuniform float u_<id>;with the scaled knob value (including any control wire modulation). Parameters:min,max,default,step,unit,curve=linear|log.@pill <id> "<Label>"feedsuniform int u_<id>;with the selected zero-based option index. Parameters:options="A,B,C",default.@toggle <id> "<Label>"feedsuniform int u_<id>;(0or1). Parameter:default=true|false.
Image and 3D model slots (@texture, @mesh)
// @texture skin "Skin" default="Marble.png"
// @mesh hero "Model" default="Default Sphere"
@texture <id> "<Label>"adds a faceplate image picker (or addfixedto hide the picker) and bindsuniform sampler2D u_<id>;.@mesh <id> "<Label>"adds a 3D model picker (fixedalso supported), used bydraw=meshpasses or sampled as a vertex texture viauniform sampler2D u_<id>_data;.
Legacy 3-knob form (@knob1..3)
Older shaders also support @knob1, @knob2, and @knob3:
// @knob1 "Warp Speed" min=0.2 max=4 default=1 step=0.1 unit="x"
// @knob2 "Hue" min=0 max=360 default=200 step=1 unit="°"
// @knob3 "Line Width" min=1 max=10 default=3 step=0.5 unit="px"
Note the difference: legacy @knob1..3 always send normalized 0 to 1 values in u_param1, u_param2, and u_param3 (so you scale them with mix(min, max, u_param1)), whereas named @knob directives send the scaled [min..max] value directly in u_<id>.
Wire an LFO or any control signal into a knob and the look animates with it, because the uniform includes whatever is wired in.
Step 4: read more of the patch
These are the built-in inputs a shader can declare. Every one is optional.
| Uniform | Type | What it holds |
|---|---|---|
u_waveform | sampler2D, 512 x 2 | The waveform, -1 to 1. Row 0 is left (or mono) at y = 0.25, row 1 is right at y = 0.75. |
u_spectrum | sampler2D, 256 x 4 | The spectrum, 0 to 1. Rows 0 and 1 are left and right, rows 2 and 3 the falling peak caps. Row centres at y = 0.125, 0.375, 0.625, 0.875. |
u_spectrum_mid | sampler2D, 256 x 1 | Mid spectrum, (L + R) / 2 FFT magnitude. |
u_sub_bass, u_bass, u_low_mid, u_high_mid, u_treble, u_air | float | Level of each band, 0 to 1. |
u_energy, u_peak | float | Overall level and peak, 0 to 1. |
u_note_pitch, u_note_velocity | float | Latest note and velocity, 0 to 1. |
u_note_gate | float | 1 while any note is held. |
u_note_trigger | float | Jumps to 1 on each note, then fades. |
u_active_notes | int | How many notes are held. |
u_note_strikes | sampler2D, 16 x 1 | Per-frame note strikes (R = pitch, G = velocity, B = spread, A = active). |
u_time, u_delta | float | Seconds since the device started, and frame step in seconds. |
u_frame | int | Frame counter. |
u_resolution | vec2 | Size of the current target (buffer or display) in pixels. |
u_sample_rate, u_is_stereo | float, int | Audio sample rate, and 1 in Stereo or 0 in Mono. |
u_param1, u_param2, u_param3 | float | Legacy @knob1..3 values, normalized 0 to 1. |
u_mesh_slot | int | Zero-based index of which listed @mesh model a draw=mesh pass is currently drawing. |
The audio textures need a hint so they are filtered and not repeated:
uniform sampler2D u_waveform : filter_linear, repeat_disable;
Step 5: a second shader to swap in
For a different shape of problem, here is an oscilloscope line drawn from the waveform. Select all in the editor, paste it over the first shader, and the picture changes without stopping the music.
shader_type canvas_item;
// @knob1 "Gain" min=0.5 max=4 default=1.5 step=0.1 unit="x"
// @knob2 "Thickness" min=1 max=12 default=4 step=0.5 unit="px"
// @knob3 "Hue" min=0 max=360 default=170 step=1 unit="°"
uniform sampler2D u_waveform : filter_linear, repeat_disable;
uniform vec2 u_resolution;
uniform float u_energy;
uniform float u_param1;
uniform float u_param2;
uniform float u_param3;
vec3 hue(float h) {
return clamp(abs(mod(h * 6.0 + vec3(0.0, 4.0, 2.0), 6.0) - 3.0) - 1.0, 0.0, 1.0);
}
void fragment() {
float gain = mix(0.5, 4.0, u_param1);
float px = mix(1.0, 12.0, u_param2) / u_resolution.y;
float w = texture(u_waveform, vec2(UV.x, 0.25)).r * gain * 0.4;
float d = abs(UV.y - (0.5 - w));
float line = 1.0 - smoothstep(px * 0.5, px * 0.5 + 1.5 / u_resolution.y, d);
float glow = exp(-d * 40.0) * (0.15 + u_energy);
vec3 tint = hue(u_param3);
COLOR = vec4(tint * (line + glow), 1.0);
}

Things to try from here: draw the right channel from row 0.75 in a second colour, multiply the line by 1.0 + u_note_trigger to make it flare on notes, or feed u_param3 from an LFO so the hue drifts.
Multi-pass shaders (@buffer and @pass)
A single pass cannot easily keep last frame’s trails, compute an envelope follower on the GPU, draw thousands of independent bars/particles, or render a 3D mesh and composite 2D post-processing over it. // @buffer and // @pass let you build a multi-pass pipeline (up to 4 buffers and 6 passes) inside the same .gdshader file.
How a multi-pass file is structured
Everything before the first // @pass is the shared prelude (shader_type canvas_item;, @viz / @knob / @buffer directives, uniforms, and helper functions). The Visualizer prepends that prelude to every pass and compiles each pass into its own shader:
-
Declare offscreen render targets in the prelude with
// @buffer:// @buffer trail size=screen format=rgba16f filter=linear persistent=truesize=:screen,half,quarter, or fixedWxH(up to1024x1024, or2048on a screen-sized 3D mesh buffer).format=:rgba16f(default HDR),rg16f,r16f, orrgba8.filter=:linear(default) ornearest.persistent=true|false: whentrue, the Visualizer allocates a ping-pong pair of render targets so a pass can sample its own previous frame viauniform sampler2D u_prev_<name>;.
-
Split the shader body with
// @pass <target>lines:- Each intermediate pass targets a declared
@buffername (// @pass trail), andu_resolutioninside it matches that buffer’s pixel dimensions. - Any later pass can sample earlier buffers via
uniform sampler2D u_<name>;. - The file must end with a single
// @pass imagestage, which draws the final picture onto the device display (and fullscreen / stage / preview mirrors). - If a pass has a compile error, the editor reports the original file’s line number with the target name, e.g.
Line 24 (trail): ....
- Each intermediate pass targets a declared
@pass draw and blend modes
| Option | Values | What it does |
|---|---|---|
draw=quad | Default | Draws a fullscreen quad into the buffer or screen. |
draw=segments | count=1..4096 (default 511) | Draws count 2D quad instances via MultiMeshInstance2D so vertex() can place bars, lines, or particles. |
draw=mesh | mesh=<id1,id2,...> | Must target a @buffer (at most 1 mesh pass per look). Converts that pass to shader_type spatial;, renders listed @mesh slots into a transparent 3D buffer (camera on +Z at 3.6, 34 deg FOV, 4x MSAA, no lights), and sets u_mesh_slot (0, 1, …) per slot. Keep spatial render_mode (such as render_mode unshaded, cull_disabled;) inside the mesh pass body, and avoid canvas-only built-ins in shared prelude helpers. |
blend= | replace (default), add | blend=add injects render_mode blend_add; into the pass. |
Multi-pass example: persistent trails
shader_type canvas_item;
// @viz "Bass Trails" api=1
// @knob decay "Trail" min=0.7 max=0.98 default=0.92 step=0.01
// @buffer trail size=screen format=rgba16f filter=linear persistent=true
uniform float u_bass;
uniform float u_time;
uniform float u_decay;
// @pass trail
uniform sampler2D u_prev_trail : filter_linear, repeat_disable;
void fragment() {
vec2 center = vec2(0.5 + 0.25 * cos(u_time * 1.7), 0.5 + 0.25 * sin(u_time * 2.3));
float orb = smoothstep(0.08 + 0.08 * u_bass, 0.0, length(UV - center));
vec3 prev = texture(u_prev_trail, UV).rgb * u_decay;
vec3 glow = vec3(0.15, 0.9, 0.75) * orb;
COLOR = vec4(max(prev, glow), 1.0);
}
// @pass image
uniform sampler2D u_trail : filter_linear, repeat_disable;
void fragment() {
COLOR = texture(u_trail, UV);
}
When an edit has an error
Nothing breaks. The device keeps drawing the last version that worked, and shows the error with its line number in two places. In the editor, Problems turns red and names the line, and the status bar counts it:

On the device front, the message sits over the picture, so you see it even with the window closed. The picture underneath is whichever shader worked last (here the one that was on show before the typo), not a black screen:

Shader error (showing Fire Spectrum). Line 33 (image): No matching function found for: 'stepp_oops'.
Fix the line and the next apply clears it. Your text is never thrown away. (In a multi-pass shader the name in brackets is the pass the error is in.)
Two limits to know. A shader cannot read files or reach the network. And it can be slow: a very heavy shader lowers the frame rate of the whole app, so start simple and add cost one step at a time.
Your shader travels with the patch
When you save a workbench, the Visualizer stores the text of your shader inside the patch, with the knob settings of each shader you touched. The patch opens correctly on a machine that does not have your file. Opening a patch runs the text saved in it. On the machine that received the patch, the editor’s badge reads IN THE PATCH and edits change the patch itself. Click Save as file… and the shader becomes a .gdshader in that machine’s Visualizer folder, which makes it theirs to change.
Where to learn the shader language
The Visualizer uses Godot’s shading language, so Godot’s own documentation is the reference for everything inside fragment():
- Shading language: types, built-in functions such as
mix,smoothstep,stepandtexture, and precision rules. - CanvasItem shaders: the built-ins available in a
canvas_itemshader, includingUV,COLORandTIME. - Your first 2D shader: a gentle start if this is your first shader.
The Visualizer adds its own inputs (the u_ uniforms above) and the @ comment directives on top of that language. Everything else is Godot.
Get it
Audio Workbench is on Steam and itch.io. If you write a shader you like, save the patch and share it: the shader goes with it.