Skip to content

Writing your own effects

Kevin Raymond edited this page Sep 21, 2026 · 2 revisions

Two kinds of effect, both plain text files that hot-reload while the app runs:

  • Layer effects (.pfx + WGSL): shaders, multi-pass pipelines, GPU particle systems. Start with Creating your own effects and the technical guide.
  • trama effects (assets/trama/effects/*.wgsl): one fragment shader with a JSON manifest in its first comment. Save a typo and nothing blanks. The last good version keeps running and the node shows the compiler's message.

Scaffold a trama effect rather than starting from a blank file:

cargo xtask new-effect my_effect            # takes one picture
cargo xtask new-effect my_mix --inputs 2    # takes two
cargo xtask new-effect my_source --source   # takes none, generates one

What it writes already compiles and already does something visible, so you can see it working before you change a line. The app notices a newly created file, so the node is in the palette without a restart.

One rule worth knowing before you write a speed parameter: never multiply it by u.time. Every change in speed is then multiplied by how long the app has been running, and a modulated speed strobes. List it under "rates" in the manifest and use the running total the engine hands you. hue_drift.wgsl is the example.

Color inside a chain is premultiplied: RGB is already scaled by coverage. Scaling a whole vec4f keeps that true, but a curve like gamma does not, so divide coverage back out first and multiply it in again. levels.wgsl shows the shape.

This page is a starting point, with more to come.

Clone this wiki locally