triode

Custom TSL transforms

Initialize with await Triode.create(options). Triode selects WebGPU or WebGL 2 before it creates outputs and starts playback. Inspect triode.rendering.backend and triode.rendering.adapter after initialization. To manage the clock yourself, set autoLoop: false and call triode.tick(deltaMs). Use forceWebGL: true when testing the WebGL 2 backend.

Supply a TSL node callback to setFunction. In the Playground, the TSL namespace is in the cue scope. In a browser bundle, import the nodes from three/tsl. The final argument supplies TSL uniform nodes for time and resolution.

setFunction({
  name: 'redGain',
  type: 'color',
  inputs: [{ name: 'gain', type: 'float', default: 1 }],
  node: (color, gain) => TSL.vec4(color.r.mul(gain), color.gba),
});
osc(8, 0.1, 0.5).redGain(() => 0.6).out(o0);

A source callback receives UV coordinates first and returns a color. A coordinate callback receives UV coordinates and returns a pair. A color callback receives the current color. Combine callbacks receive both colors; coordinate-combine callbacks receive UV coordinates and the second signal's color. Declare only additional parameters in inputs for combine and combineCoord. Triode inserts the second color before those parameters. A leading vec4 named color or signal marks an explicitly declared operand. Texture inputs pass a sampling callback for the supplied reference. Use the same callback for both rendering backends.

Use the CPU-side color, vector, matrix and coordinate helpers on triode.synth for sketch values such as solid3(vec3(1, 0, 0)). The Playground also exposes them directly in the cue scope. Import shader nodes from three/tsl when authoring a node callback.

In the Playground, tex() and texture() create offscreen textures for use by that cue. Use out() to change a live output.

A failed Playground cue keeps the previous scene, output histories, display selection and source bindings. Use Open GLSL archive in the Playground to run a sketch with raw GLSL transforms, ShaderMaterial, or composer effects.

Source docs/workflows/tsl-transforms.md