Skip to content

std/visuals

Import: use "std/visuals";

GPU visual operators — generators, filters, and the raw-shader Visual. Wire nodes with >> (primary input; route to screen to display) and bind parameters or texture inputs with node.param("name") << signal. screen is the global output sink, like master.

A blur visual (Blur()). Bind its parameters with b.param("name") << ….

fn Blur() -> Blur

A blur visual: a TouchDesigner-style Blur TOP that softens its primary input (set via src >> Blur()) with a 5×5 box kernel whose spacing scales with radius, so it blurs at large radii too.

Parameters:

  • radius — blur radius in pixels

Returns: Blur — a filter node, routable with >> and bindable with .param

fn param(name: String) -> VisualParam

Binds a uniform by name, e.g. b.param("radius") << sig.

A composite visual (Composite()). Bind its parameters with c.param("name") << ….

fn Composite() -> Composite

A composite visual: a TouchDesigner-style Composite TOP that blends its primary input A (set via src >> Composite()) with a second input B (set via c.param("b") << node, where node may be a forward node or prev inside feedback(...)). Bind operand to pick the blend (rounded to nearest): 0 over, 1 add, 2 subtract, 3 multiply, 4 difference, 5 subtractive, 6 max/lighten, 7 min/darken, 8 screen. Results are clamped to [0,1].

Parameters:

  • operand — blend-mode selector (see list above)
  • b — second input B (texture input; wire a node with <<)

Returns: Composite — a filter node, routable with >> and bindable with .param

fn param(name: String) -> VisualParam

Binds a uniform or input slot by name, e.g. c.param("operand") << 1.0 or c.param("b") << node.

A displace visual (Displace()). Bind its parameters/slots with d.param("name") << ….

fn Displace() -> Displace

A displace visual: offsets each pixel lookup of its primary input (set via src >> Displace()) by a displacement field fed into the by slot (d.param("by") << field or d.param("by") << prev inside feedback(...)).

Parameters:

  • amount — displacement strength
  • by — displacement field (texture input; wire a node with <<)

Returns: Displace — a filter node, routable with >> and bindable with .param

fn param(name: String) -> VisualParam

Binds a uniform or the by input slot by name, e.g. d.param("amount") << sig or d.param("by") << field.

An edge visual (Edge()). Bind its parameters with e.param("name") << ….

fn Edge() -> Edge

An edge visual: a spatial filter that Sobel-detects the boundaries of its primary input (set via src >> Edge()), turning a soft noise/voronoi field into bright cell-contour lines.

Parameters:

  • strength — edge gain

Returns: Edge — a filter node, routable with >> and bindable with .param

fn param(name: String) -> VisualParam

Binds a uniform by name, e.g. e.param("strength") << sig.

A lookup visual (Lookup()). Wire its gradient input with l.param("gradient") << ramp.

fn Lookup() -> Lookup

A lookup visual: a TouchDesigner-style Lookup TOP that colourises its primary input (set via src >> Lookup(), used as the index) by sampling a gradient fed into the gradient slot (l.param("gradient") << ramp) at the index’s luminance.

Parameters:

  • gradient — colour gradient input (texture input; wire a Ramp with <<)

Returns: Lookup — a filter node, routable with >> and bindable with .param

fn param(name: String) -> VisualParam

Binds the gradient input slot by name: l.param("gradient") << ramp.

A luma-level visual (LumaLevel()). Bind its parameters with l.param("name") << ….

fn LumaLevel() -> LumaLevel

A luma-level visual: a TouchDesigner-style Luma Level TOP over its primary input (set via src >> LumaLevel()). Brightness / black-level / gamma / invert controls, e.g. to lift a crushed image into a colour Lookup’s range.

Parameters:

  • brightness — output gain
  • black — black-level offset
  • gamma — gamma exponent
  • invert — 0..1 invert mix

Returns: LumaLevel — a filter node, routable with >> and bindable with .param

fn param(name: String) -> VisualParam

Binds a uniform by name, e.g. l.param("brightness") << sig.

A noise generator visual (Noise()): an animated TouchDesigner-style fractal value-noise field. Bind its parameters with n.param("name") << ….

fn Noise() -> Noise

A noise generator visual: an animated TouchDesigner-style fractal value-noise field, the green-TOP-style source of an operator chain. Bind its TD noise TOP parameters with .param("name") << ….

Parameters:

  • period — feature size; larger is bigger cells
  • harmonics — fbm octave count
  • gain — per-octave amplitude falloff
  • exponent — contrast shaping, pow
  • offset — brightness floor

Returns: Noise — a generator node, routable with >> and bindable with .param

fn param(name: String) -> VisualParam

Binds a uniform by name, e.g. n.param("period") << sig.

A ramp generator visual (Ramp()). Bind its parameters with r.param("name") << ….

fn Ramp() -> Ramp

A ramp generator visual: a TouchDesigner-style Ramp TOP drawing a 4-key colour gradient (no input). The keys color0..color3 sit at 0, pos1, pos2, 1; type picks orientation (0 horizontal, 1 vertical, 2 radial). The defaults make a black→blue→light-blue→white palette for Lookup.

Parameters:

  • type — orientation selector (0 horizontal, 1 vertical, 2 radial)
  • color0 — gradient key at position 0, a vec3
  • color1 — gradient key at pos1, a vec3
  • color2 — gradient key at pos2, a vec3
  • color3 — gradient key at position 1, a vec3
  • pos1 — second key position
  • pos2 — third key position

Returns: Ramp — a generator node, routable with >> and bindable with .param

fn param(name: String) -> VisualParam

Binds a uniform by name, e.g. r.param("type") << 2.0.

An RGB-key visual (RgbKey()). Bind its parameters with k.param("name") << ….

fn RgbKey() -> RgbKey

An RGB-key visual: a TouchDesigner-style RGB Key TOP that blacks out pixels of its primary input (set via src >> RgbKey()) within threshold of the key colour, passing the rest through. With the defaults (black key, threshold 0) it is a pass-through.

Parameters:

  • key — colour to key out, a vec3
  • threshold — key range/softness

Returns: RgbKey — a filter node, routable with >> and bindable with .param

fn param(name: String) -> VisualParam

Binds a uniform by name, e.g. k.param("threshold") << sig.

The display output sink. screen is a global (like master): route a visual with v >> screen, then adjust presentation via its methods.

fn quality(n: Number) -> Screen

Sets the supersampling (SSAA) quality — the internal render resolution as a multiple of the presented window. Higher is smoother but costs ~n² GPU work; clamped to the renderer’s supported range. Takes effect live.

Parameters:

  • n (Number) — render-scale multiple (≥ 1)

Returns: Screen — the sink, for chaining

fn show_window() -> Screen

Opens the native live-rendering window for the routed visual, rendered on the GPU in-process from the routed graph and transport (audio meter feeds read as zero for now). A no-op if the window is already open.

Returns: Screen — the sink, for chaining

fn snap(path: String) -> Screen

Renders the routed visual off-screen on the GPU and writes it to a PNG at the given path (resolved relative to the working directory). Works headless, so it also runs in an offline resonon file.non render. Rendered at the export resolution (independent of the live window) with quality’s SSAA.

Parameters:

  • path (String) — output PNG path

Returns: Screen — the sink, for chaining

A slope visual (Slope()). Bind its parameters with s.param("name") << ….

fn Slope() -> Slope

A slope visual: a TouchDesigner-style Slope TOP that turns the luminance gradient of its primary input (set via src >> Slope()) into a signed RG displacement field, re-centred around offset for a downstream Displace.

Parameters:

  • strength — gradient gain
  • offset — re-centre point

Returns: Slope — a filter node, routable with >> and bindable with .param

fn param(name: String) -> VisualParam

Binds a uniform by name, e.g. s.param("strength") << sig.

A transform visual (Transform()). Bind its parameters with t.param("name") << ….

fn Transform() -> Transform

A transform visual: a TouchDesigner-style Transform TOP that translates, rotates and scales its primary input (set via src >> Transform()) about a pivot. Positive scale zooms in, positive rotate spins counter-clockwise; rotation is aspect-corrected so a wide canvas spins without shearing. extend picks how pixels outside the source are filled (rounded to nearest): 0 hold/clamp, 1 repeat, 2 mirror, 3 black. With the defaults it is a pass-through.

Parameters:

  • translate — uv-fraction offset (+x right, +y up), a vec2
  • rotate — rotation in degrees (positive is counter-clockwise)
  • scale — per-axis zoom, a vec2
  • pivot — centre of rotate/scale, a vec2
  • extend — outside-source fill mode (see list above)

Returns: Transform — a filter node, routable with >> and bindable with .param

fn param(name: String) -> VisualParam

Binds a uniform by name, e.g. t.param("rotate") << sig.

A GPU fragment-shader visual. Bind uniforms with v.param("name") << signal and route to the display with v >> screen.

Built-in uniforms are always supplied without binding (declare and use them):

  • iTime — transport time in seconds (beat-synced; freezes when stopped)
  • iResolution — canvas size in pixels (vec2)
  • iBeat — continuous beat position
  • iCycle — continuous cycle position

These names are reserved and cannot be bound.

Custom shaders compiled with Visual(source) expose their own uniforms; any name is accepted. Live audio meter feeds are bindable: v.param("kick") << drums.rms, v.param("level") << master.peak (each track and the master expose .rms / .peak).

fn Visual(source: String) -> Visual

Compiles a fragment-shader source string into a Visual. Share GLSL between shaders by composing source strings in Resonon, e.g. Visual(load_file("shaders/lib.glsl") + frag).

Example:

v = Visual(frag);

Parameters:

  • source (String) — GLSL-ES fragment shader source (non-empty)

Returns: Visual — a compiled visual, bindable with << and routable with >>

fn param(name: String) -> VisualParam

Binds a uniform by name: v.param("name") << signal.

Parameters:

  • name (String) — the GLSL uniform name

Returns: VisualParam — a parameter reference, bound with <<

A reference to a visual operator’s parameter, produced by node.param("name") and consumed by << (v.param("period") << sig). Not used on its own.

fn feedback(build: Function) -> Visual

Builds a feedback group: the closure is called with prev — the group’s previous-frame output as a sampleable visual — and returns the group output. Wire prev into a slot (e.g. d.param("by") << prev) to close the loop; the renderer realizes it as a ping-pong buffer. Route the result with >> screen.

Example:

feedback(fn(prev) { let d = Displace(); d.param("by") << prev; return Noise() >> d; })

Parameters:

  • build (Function) — fn(prev) { ... }, returning the group’s output Visual

Returns: Visual — the group output, routable with >> and reusable for fan-out

fn load_shader(path: String) -> Visual

Loads a fragment shader from an external .glsl file and compiles it. The path is resolved relative to the .non file being run, so existing shader tooling (highlighting, linting) can edit the .glsl directly. Re-executing the routing line after editing the file hot-swaps the shader.

Example:

v = load_shader("shaders/plasma.glsl");

Parameters:

  • path (String) — shader file path, relative to the current .non file

Returns: Visual — a compiled visual, bindable with << and routable with >>