# COMP STUDIO — Module reference

Every module in the app, every parameter it has, and the rules that decide
how they connect. Written for anyone reading or building a graph from the
outside, including an AI agent producing or editing a document.

The reference sections (effects and modulators) follow the live
definitions in `src/engine/registry.ts`, `src/engine/generators.ts` and
`src/engine/modulators.ts`, and each description follows the module's doc
comment. Nothing generates this file: both are written by hand and kept in
step. If this file and the code disagree, the code wins. The same text is
shown to people at compstud.io/documentation.

Wording: the UI calls the boxes on the canvas **modules**. The code calls
them **nodes**, as React Flow does. Both words mean the same thing here.

---

## 1. The graph in one page

A document is a directed graph of nodes and edges. Pictures flow left to
right, from an input through effect modules into an output. Modulators
produce numbers (signals) that drive parameters.

| Node `type` | What it is | Menu |
| :-- | :-- | :-- |
| `image` | A still picture (dropped, pasted or picked). The file is not in the document: it is kept in this browser (IndexedDB `comp.media`) and comes back on reload. Elsewhere the node comes back empty, naming the file it wants. | Input |
| `imageSet` | **Image Set**: up to 32 pictures put out on one wire as a **batch**: everything downstream runs once per picture (see *Batches* below). Each file is kept in this browser like an Image's and comes back on reload. On the card: drop or pick several files at once, drag a thumbnail to move it in the batch, × to take one out. | Input |
| `video` | A video file, kept in this browser like an image's and back on reload. Has playback controls and a `speed` port. Its sound track, if it has one, goes out on a `sound` port. | Input |
| `audio` | A sound file placed on the timeline. Draws no picture; its `sound` output goes into a Renderer or a Viewer. The file is kept in this browser like an image's and comes back on reload; the document holds only its id. With `synth` set it is a **Noise Synth** or **Tone Synth** instead: the sound is made from its settings (section 6), which are saved, so it comes back on reload. | Input |
| `soundMix` | **Sound Mix**: several sounds (up to 16, on `sound:0`…`sound:15`) rendered into one sound on its `sound` output, each with its own Gain, Pan, Mute and Solo. Draws no picture. | Module (Audio) |
| `generator` | A procedural picture (Solid Color, Gradient, Noise, Plasma, Wave Field, Cellular, Pattern, Shape, Spectrum) with its own width and height, or, on **Match canvas** (first in its Resolution menu and where a new one starts), the size of the picture it is composited into: a Layers module's canvas when it is a layer, on any Fit, through the effects on its branch. A viewer or preview wired to it (or through effects after it) shows it at the canvas of the first module it is a layer of; read by two Blends of different shapes in one chain, it is made for the one nearer the viewer and fitted to the other. Composited nowhere, it keeps its width and height. **Text** (`textLayer`) is a generator too: words typed on its card, set in a font and placed on the picture; so is **Model** (`model3d`): a 3D model from a glTF file, drawn from a camera. | Input |
| `text` | **Prompt** (called Text before; the type stays `text`): words, for whatever takes text -- an AI module's prompt, Text Mask's words, a Text module's words. Saved with the document. | Input |
| `describe` | **Describe**: a picture into words by a model in the browser (Florence-2), on a click; its words come out on a text port, as a Prompt's do (section 7). Saved with the document. | AI |
| `aiImage` | **AI Image**: a picture asked of a model on OpenRouter or Google AI Studio, from a prompt, a picture, or both (section 7). The picture it got back is kept on the device that made it, not in the document. | AI |
| `effect` | One of the 80 effect modules below, or Depth, Depth Relight, Re-angle, Cut Out, Magic Mask, Text Mask, Fill or Colorize (section 7), which are effects that run a model in the browser. | Module / AI |
| `modulator` | A signal source (LFO, Noise, Pulse, Value, Step Sequencer, Bézier) or operator (Math, Map Range, Image Statistic, Tracker, Sample & Hold, Smooth, Envelope, Audio Level, Onset, Beat). | Input (sources) / Module (operators) |
| `renderOutput` | **Viewer**: a live preview card. | Output |
| `backgroundOutput` | **Background**: draws the result full screen behind the canvas. | Output |
| `scope` | **Scopes**: waveform, RGB parade, vectorscope or histogram of the picture wired in. | Output |
| `projector` | **Projector**: the picture alone in a pop-up window, for a second screen, a projector or screen capture. A toolbar in the window zooms (buttons, wheel, + / -), moves the picture (drag, arrows), frames it with Fit or Fill (Fit is 100% centred; Fill zooms until the picture covers the window, and the rest stays reachable by moving) and goes full screen; it shows only while the pointer is near the bottom of the window. Zoom and position are not saved. | Output |
| `render` | **Renderer** (type `render`): bakes the incoming picture to PNG, JPG, WebP, GIF, MP4, WebM or a PNG sequence (every frame as a numbered PNG, in one zip). MP4 and WebM also carry the sound wired into its `sound` port. The baked file shows on the card (a preview, its size and length) and is kept in this browser until the next render or **Delete**; **Save** downloads it, named by its Name field and the time. | Output |
| `recorder` | **Recorder**: records what plays in real time to MP4 or WebM, with the sound wired into its `sound` port, and downloads the take. Its purple `render` output carries the last take, as a Renderer's does its file, into a Viewer or Background to watch it back (takes are not saved, so after a reload there is nothing on it until the next one). | Output |
| `moduleGroup` | A **group**: several modules shown as one card. Display only. | — |
| `comment` | A **comment**: a frame traced on the canvas (C, then drag) with words along its top, explaining the modules inside it. Not a module: no ports, never drawn through; always behind the modules. Dragging it by its words moves the cards wholly inside it (Ctrl+drag moves the frame alone); double-click the words to edit. Its lock keeps it out of selections (box, Select all) and in place. | C |

### Previews on the cards

Every effect and generator card (and the Tracker) has a preview mode in
its title -- **Off**, **On** or **Auto**, a click stepping through them in
that order; an eye, or a pencil on a module edited on its picture -- for the module's picture, as a viewer wired out of it would
show it. Auto shows it while the module is the one selected (selecting
several opens none) and hides it otherwise; On always. The picture comes in
one of three kinds, set by the module and never by a choice:

- **Plain** (most modules): the picture edge to edge in a recessed well
  under the title, flush with the card's edges, the card's full width up to
  9:16. A taller picture is pillarboxed.
- **Interactive** (modules edited on their picture): the well is a clipped
  viewport with the picture on a darker pasteboard, so handles that reach
  past the picture have room. The view fits the picture and its handles
  when it opens and when a drag is let go (never during a drag; it eases
  over 150 ms). A handle still out of sight gets a chevron on the edge.
- **Large** (Layers, Text, Model, Shape and 3D Shape): the card widens to two columns, and the
  picture sits in a 420px window down its whole right side, top to bottom,
  with the title over the controls only. Only Off or On; it starts On.

Module cards are 256px wide so the picture reads. A module edited on its
picture starts on Auto, every other on Off (Large ones on On). The mode is
kept in this browser, not in the document. A point param -- a picture
position, 0..1 from the bottom left -- gets a dot there to drag: Center on Chromatic Aberration, Crystal
Ball, Glass, Kaleidoscope, Polar Coordinates, Radial Blur, Ripple,
Spectral Prism, Swirl, Tunnel and Vignette; Light on God Rays; Impact on Shatter;
Position on Shape (a Large preview, so the card's own outline thumbnail is hidden while it is open); the four corners of Corner Pin; Emitter Origin on
Particle Flow (counted from the top left, as its simulation reads it). A keyed point takes a key
at the playhead; a wired one can't be dragged; one the module's other
settings make irrelevant (dimmed on the card) has no dot. The Layers module's preview (Large) has handles
on its picked layer instead (see Layers); Magic Mask's shows the picture
coming in, with its points; Text's (Large), the picture its words go onto,
with their box. **Transform**'s has a box where its input lands: drag inside to
move it (Offset), a corner to scale it (Scale), the dot above to turn it
(Rotation; Shift: 15° steps). **Resize / Crop**'s shows the picture coming
in, the part cut away dimmed: with Crop Margins, drag an edge or a corner to
crop and inside to slide the window; cropping to an aspect (or a Fill
resize), drag inside to slide it (Anchor). A preview scrolled out of view
stops drawing, and at most 12 draw at once: past that, the last opened say
they are paused until one closes or scrolls away, with a button that sets
every preview to Off.

### Batches

An Image Set puts several pictures out on one wire. No port takes two wires:
the batch travels on the wire, and modules don't change. Everything
downstream of the set runs once per picture, in batch order, and each picture
keeps its own state (trails, feedback, a model's answer, an Image Statistic's
reading). A module running an in-browser model asks it once per picture:
an answer is kept while its picture isn't drawn (switched away from, passed
over by a Pick), and remembered by the exact picture it answered, so showing,
picking or baking that picture again doesn't run the model again. Whatever doesn't depend on the batch, like a generator layered
over every picture, is drawn once and shared. Seeds are the module's, so
every picture gets the same grain. Where two sets meet (a Layers module's base and
layer), pictures are matched by position, and the shorter set starts again
from its first picture. A batch's pictures are named after the largest set
reaching the output.

A wire carrying a batch is drawn as two strands, with ×N, the number of
pictures, on its middle. **Collect** (Module → Composite) makes a batch of
whatever is wired into it, and **Pick** takes one picture back out. A picture
wire dropped on a picture input that already has one replaces it; with
**Shift** held as it is let go, the two merge into a batch instead: the new
picture joins the Collect already feeding that input (or the Collect it lands
on) on its next free port, or a new Collect is wired in the old wire's place.
The wire is drawn broad and dashed while Shift is held.

A **Viewer** or **Projector** fed a batch gets a bar under its picture:
back and on through the pictures (going round), which one shows (3 / 12),
and a grid button that shows every picture side by side, as square as
the count allows, each in a cell of the first picture's shape. In a grid each
picture works at about a cell's size. On the card, a click on a cell shows
that picture alone. Pictures' names are not shown. The Projector's
window has the same buttons in its toolbar, with `[` / `]` (or Page Up /
Page Down) and `G`. A **Renderer** fed a batch chooses what it bakes:
**One** picture (stepped through like a Viewer's), **Each** picture as a
file of its own in one zip (`01_name.png`, `02_name.png`, … numbered in
batch order and named after the picture; a PNG sequence as a folder of
frames per picture), or a **Sheet**: every picture side by side on one, the
shape of the first, 16 px apart, as square as the count allows, each picture
at the render's scale unless the sheet would pass 8192 px a side, when they
all shrink together. A **Scope**, **Recorder** or **Background** shows one
picture, stepped through on its card the same way (no grid).

**AI Image** fed a batch on Image generates one picture for each, from that
picture and the same prompt, one request after another (each billed; the
button says how many). They come out as a batch of their own, in order, shown
as thumbnails on the card; one that fails says why on its thumbnail and the
rest go on. Each is kept on this device like an Image Set's files.
Generating from a single picture again goes back to one result.
**Describe** fed a batch has the stepper: it describes the picture chosen.

### Ports and edge handles

| Port | Handle id | Shape / wire colour | Carries |
| :-- | :-- | :-- | :-- |
| Main picture input | none (`targetHandle` omitted / null) | blue | the picture being processed (`u_src`) |
| Extra picture input | the input's key, e.g. `layer`, `layer2`, `matte`, `map` | blue | another picture (the Layers module's layers, Mask, Remap, …) |
| Parameter | `param:<key>`, e.g. `param:radius`; a vec2 has one per axis, `param:<key>.x` and `param:<key>.y` | amber (signal) or dashed blue (field) | a number, or a picture as a per-pixel value |
| Modulator output | `mod` (`sourceHandle`); a Tracker has two instead, `mod:x` and `mod:y` | amber | the modulator's signal |
| Rendered file | `render` | purple | a baked file, Render or Recorder → Viewer/Background |
| Sound | `sound` (both ends) | dotted green | an Audio node's sound, a video's sound track, or a Sound Mix's, into a Renderer, Viewer, Projector, Recorder, Audio Level, Onset, Beat, Spectrum or a Sound Mix's `sound:<n>` |
| Text | `text` (`sourceHandle`, on a Prompt or a Describe) into `text:<use>`, e.g. `text:prompt` | dashed pink | words, into an AI Image's Prompt, Text Mask's Words or a Text module's Words |
| AI reference | `reference` (`targetHandle`, on an AI Image) | blue | a live picture for the model to work from |

Which target ports exist on each node kind:

- **effect**: main input, its extra inputs, and `param:<key>` for every param that is not `portless` (`param:<key>.x` / `.y` for a vec2) -- those a module shows at its settings: Layers shows the layers it has room for (`shownWhen`).
- **generator**: no picture input; `param:<key>` for every param (per axis for a vec2). Spectrum also takes `sound`; Text takes `text:prompt` (its Words), whose words stand in for its own. A Model has three more picture outputs besides its main one (`sourceHandle` null): `depth`, `normal` and `matte`.
- **video**: only `param:speed`. A new video brings a hidden-in-plain-sight Math helper (`helperFor: <videoId>`) wired into its speed.
- **modulator**: `param:<key>` for each int/float param (none for Value). Image Statistic and Tracker also take a picture on its main input (the Tracker has no `param:` ports); Audio Level and Onset take `sound`.
- **audio**: `param:gain` (its Gain, keyable; a modulator wired in drives it), and the `sound` output.
- **soundMix**: `sound:<n>` for each shown input (one empty port after the last one in use) and `param:layer<n>.gain` for each of them, and the `sound` output.
- **renderOutput**: main input (a live picture) or `render` (a baked file), plus `sound`.
- **backgroundOutput**: main input or `render`; no `sound`.
- **render**: main input and `sound`.
- **scope**: main input only (a live picture). **projector**, **recorder**: main input (a live picture) and `sound`. Neither a Scope nor a Projector has an output; a Recorder's one output is `render`, its last take.
- A `sound` port takes only a wire from a sound source -- an Audio node, a video's own `sound` output, or a Sound Mix -- and a sound source's wire goes only into a `sound` port (Render, Viewer, Projector, Recorder, Audio Level, Onset, Beat, Spectrum, Sound Mix).
- **imageSet**: none. Its only port is its picture output, carrying the batch.
- **text** (Prompt): none. Its only port is the `text` output.
- **aiImage**: `text:prompt` (text) and `reference` (a live picture), both optional; no main input. Its output is a picture, like an Image's. Nothing upstream of it is drawn through it: the reference is captured once, when Generate is pressed.
- **describe**: `reference` (a live picture); no main input. Its output is the `text` port, like a Prompt's. The picture is captured once, when Describe is pressed.
- A `text:` port takes only a wire from a Prompt or a Describe, and their wires go only into a `text:` port (AI Image's Prompt, Text Mask's Words, a Text module's Words: `text:prompt`).
- **moduleGroup**: none. Wires always name the member module inside the group, never the group. Prompt and AI Image modules cannot be grouped yet.

Cycles are refused, with one exception: a wire into a Feedback's `loop`
port (labelled Target, as in TouchDesigner; `feedbackLoop`, Module → Temporal) may come from anywhere downstream of
it, closing a loop through the graph as TouchDesigner's Feedback TOP does. What
the port reads is that module's picture as it was **last frame**, so each frame
is still drawn front to back: the loop's modules run once a frame on their own
last result. The Feedback's main input is the seed, put out on the first
frame and after a seek, until something has come back. The loop wire is dashed
and routed under the cards it joins, with chevrons pointing back and a "last
frame" label; the Target port is a hollow ring with the targeted module's name
beside it. While the Feedback or its
loop wire is hovered, every module and wire in the loop is ringed in blue
(selected ones keep their selection look). Modules that need only their own past (Tunnel, Trails,
Datamosh, …) keep it internally instead; see *feedback* in the module facts below.

**Precision.** Modules draw in half float (16 bits a channel) where the GPU
can, and each module's output is clamped to 0..1 as eight bits clamp, so a
picture looks the same either way but for banding. Settings → High precision
turns it off (eight bits), for a GPU that struggles. Media, the screen and
files stay eight bits; fields (a Fill, a per-pixel Math) are not clamped.

### Parameter kinds

| Kind | Stored as | Card control | Shader uniform |
| :-- | :-- | :-- | :-- |
| `float` | number | slider, or a typed number field when the range is "free number" | `float u_<key>` |
| `int` | number (integer) | slider | `int u_<key>` |
| `enum` | number, the **index** of the option | menu (optional `groups` add headings; display only) | `int u_<key>` |
| `bool` | boolean | toggle | `bool u_<key>` |
| `color` | `[r, g, b]`, each 0..1, straight (not premultiplied) | colour swatch | `vec3 u_<key>` |
| `vec2` | `[x, y]` | two sliders, X and Y, each with its own port | `vec2 u_<key>` |

Column meanings in the tables below:

- **Range / options**: slider bounds. A wired value may go past them; the
  minimum still applies to fields (it keeps effects out of values that break them).
- **Port**: `◇` diamond, takes a single number **or** a picture (a field);
  `○` round, single number only; `none`, not wirable. A vec2's port mark
  applies to each of its two axis ports; an axis with nothing wired keeps its
  typed value. A wire saved into a vec2's old single port loads as a wire
  into both axes.
- **Notes**: *phased* params (`speed`, `rate`, `roll`) are integrated over
  time so changing them never makes the picture jump; they only take single
  values. *active when* means the card dims the param unless the condition
  holds; it still keeps its value and its port.

Every effect marked mixable gets an injected **`mix`** param (0..1, default 1)
that crossfades the result against the module's input.

### Signals, fields and type conversion

Wiring follows Blender's sockets. A wired param takes the incoming value
outright; its slider locks and shows the live value.

| Into | From a picture (field) | From a number (signal) |
| :-- | :-- | :-- |
| float | luminance, raw (0..1 for a normal picture) | as is |
| int / enum | luminance, truncated | truncated |
| bool | luminance > 0 | > 0 |
| color | RGB | grey |
| vec2 (each axis) | luminance, per axis | as is, per axis |

- Signals arrive raw, in the units of wherever they land. An LFO swings −1..1;
  use **Map Range** to turn that into, say, 200..400 lines.
- **Math** and **Map Range** go per pixel as soon as a picture reaches one of
  their ports; their output becomes a field (blue diamond). Map Range's Auto
  range treats a picture as 0..1.
- A field reaching a round port (through a Math, say) stays wired but is
  drawn **red** and ignored until the wiring is fixed.
- A number wired into a picture input becomes a flat grey.
- **Image Statistic** goes the other way: picture → number (mean, min, max,
  range, std dev), measured within the same frame in an export, a frame or
  so later in a viewer.
- **Audio Level** and **Onset** turn sound into a number: a band's loudness
  (or, on Audio Level, its brightness, noisiness or rate of change), or a
  gate on every hit.

### Time and animation

- Time is in seconds, on the document's **comp**: it plays from the comp's start
  to its end, then goes round again (Loop on) or stops there (Loop off). The
  timeline along the bottom shows it, scrubs it, and steps it a frame at a
  time. A seek, or the comp going round, is a jump: feedback and time-cache
  modules start again from the frame they land on, as on a reset. With a
  **work area** set, playing loops over it instead (from wherever the
  playhead is, on to the work area's end, then round it); the playhead can
  still be put anywhere. **Markers** name moments: keys snap to them, and
  `,` / `.` stop at them.
- **Keyframes.** Any shown param of an effect, generator or group member,
  and any numeric param of a modulator, can be keyed: the diamond after its
  label (or `I` over the row) sets a key at the playhead, at the value the
  param has there. Once keyed, changing the param sets a key where the
  playhead is. Between keys a param eases (smooth, never past a key's
  value, flat at a peak), goes straight, or holds (toggles and menus always
  hold); before the first key and after the last it holds. A point is keyed
  per axis and a colour per component. A wire into the port wins over its
  keys. Keyed params on a Math or Map Range that has become per-pixel (a
  picture reaches it) are not followed yet. The **dope sheet** (T, above
  the timeline) shows every key, by module and param, to move, copy, ease
  (Smooth, Ease in & out, Ease in, Ease out, Linear, Hold) or delete. Its
  **Curves** view shows each keyed channel's value over time: keys move in
  time and value, and a Smooth key's handles can be dragged (Aligned, or
  Free with Alt) or put back to Auto. Each channel can hold its end values
  (Hold), carry on along its end slope, cycle its keys, or ping-pong
  through them, before its first key and after its last.
- A module marked *animated* forces a continuous frame loop. A graph with
  nothing animated only redraws when something changes. Many modules are
  animated only at some settings (typically when `speed` or `rate` is not 0).
- Each node has a stable random seed derived from its id, so two Grain
  modules make different grain. Random modulators also have a `seed` knob for
  a different draw.
- *feedback* modules keep their own last output; *timeCache* modules keep a
  ring of past input frames (Time Machine, Echo, …). Both are per node, and
  per time: a module reached both behind a time module and not keeps two.
- *Time modules* (Time Offset, Freeze Frame, Time Remap, Time Range) change the time of their
  branch: everything upstream of their main input runs at the time they
  make of the comp's, while they and everything downstream keep the comp's.
  Their own params are read at the comp's time. They nest, from the output
  inwards. What is heard is not moved; a video behind one shows its frame
  for the branch's time, and a video read at two times (with and without a
  Time Offset) plays from two elements, one per time. A branch held by a
  Freeze Frame, or a Time Remap with nothing moving on Time, stands still and
  does not keep the viewer drawing. A branch whose own time goes back (a Time
  Range going round, a Remap running backwards) starts its feedback again.
- Sound follows the same clock. A Viewer plays the audio nodes wired into
  its own `sound` port, or into the `sound` port of the Render on its main
  path, and any audio node an Audio Level or Onset in its chain reads. Sound starts and stops with the transport, starts again from where a seek lands, and follows a Render's loop
  preview. While sound plays, the clock follows the audio output, so picture
  and sound stay in step. A chain with sound counts as animated.
- A video follows the clock: at comp time t it shows the frame at t × Speed
  (the integral of a moving Speed), wrapping with Loop or holding its last
  frame -- the same frame in a viewer as in an export. A playing video a
  little off is eased back with its playback rate, and seeked when more
  than 0.5 s off. Its sound track sits on the timeline from 0 and loops with
  the picture, and plays only at Speed 1: at any other speed, or a moving
  one, the video gives no sound, and its card says so when the sound is wired.
- An MP4 or WebM render carries only the sound wired into the Render's own
  `sound` port, not sound an analyser merely reads. It is mixed down for the
  rendered stretch with each audio node's Gain, Offset and Loop; muted nodes
  are left out. It is encoded as AAC, else Opus, whichever the browser can
  encode and the container takes. Where it can encode neither, or must fall
  back to MediaRecorder, the file comes out silent and the Render says so.
  The Render's **Sound** button (under Length of) runs its range (or the comp, when it
  follows the comp) from 0 to where the last wired clip ends.

### Frame size

Each step runs at its own frame size, in source pixels. Inputs set it (an
image's own size, a generator's width × height). **Resize / Crop**, and
**Layers** on a Custom canvas, change it for everything after them. Extra
picture inputs are fitted to the main input's frame (cover, cropped, not
stretched), and so is everything on their branch -- except the Layers module's layers on
any Fit but Canvas, which arrive at their own size for Layers to place. Previews may
run at reduced size; pixel-sized params are scaled so previews and exports
match.

---

## 2. Documents, groups and presets

Documents save to `localStorage` and import/export as JSON:

```json
{
  "version": 12,
  "comp": { "start": 0, "end": 10, "fps": 30, "loop": true },
  "nodes": [
    { "id": "n1", "type": "image", "position": { "x": 0, "y": 0 }, "name": "photo.jpg", "width": 1920, "height": 1080 },
    { "id": "n2", "type": "effect", "position": { "x": 300, "y": 0 }, "effectId": "blur", "params": { "radius": 6, "mix": 1 } },
    { "id": "n3", "type": "modulator", "position": { "x": 300, "y": 200 }, "modulatorId": "lfo",
      "params": { "shape": 0, "rate": 0.5, "phase": 0, "seed": 0, "amplitude": 10, "offset": 12 } },
    { "id": "n4", "type": "renderOutput", "position": { "x": 600, "y": 0 }, "width": 360 }
  ],
  "edges": [
    { "id": "e1", "source": "n1", "target": "n2" },
    { "id": "e2", "source": "n3", "target": "n2", "sourceHandle": "mod", "targetHandle": "param:radius" },
    { "id": "e3", "source": "n2", "target": "n4" }
  ]
}
```

- `comp` is the composition: `start` and `end` in seconds (0 ≤ start, end at
  least 0.1 s after it, at most 3600), `fps` 1..120 (what the timeline counts
  frames in; playback stays smooth), `loop` (true: back to the start at the
  end; false: stop there), `auto` (true until the first video or sound is
  loaded, which then sets `end` to where it ends; set false by editing the
  start or end). Viewers play at `fps`: a new picture each frame of the comp,
  whatever the screen or a video's own rate. Missing (versions before 9) it
  is made from 0 to the furthest Render range, video or sound, at least
  10 s. Presets have none. `markers`: `{ t, label }` in time order, inside
  the comp (labels up to 40 characters). `work`: `{ start, end }` inside
  the comp and at least a frame long, or null.
- `params` are keyed by the param `key` from the tables below. Missing keys
  take their default; unknown keys and out-of-range sizes are dropped or reset
  on load.
- Node-specific fields:
  - `image`, `video`, `audio` (not a synth): `mediaId?`, the id the imported file is kept under in this browser's IndexedDB `comp.media`. On load the file is read back from there and loaded again, as if dropped; a device without it shows the node empty. Kept media no open document uses is forgotten a month after it was kept.
  - `imageSet`: `items`, in batch order, at most 32: each `{ id, name, width, height, mediaId? }`, its file kept like an Image's (`id`: letters, digits, `-` and `_`, unique in the set). Items past 32, or with a missing or repeated id, are dropped on load.
  - `video`: `name, width, height, duration, speed?, loop?, muted?, playbackRate?` (speed 0.0625..16). Whether it has a sound track is found again when the file is loaded, not saved.
  - `audio`: `name, duration, channels, sampleRate` (saved empty for a synth, whose sound is made again on load), `synth?` (`{ kind: 'noise' | 'tone', seed, params }`, see section 6; an unknown kind loads as a plain Audio node), plus its placement: `gain` 0..2 (default 1), `offset` s (0), the clock time the file starts at (negative trims its start), `loop` (true; a looped file repeats over the whole timeline), `muted` (false), and the clip edits, all optional: `in`, `out` (seconds into the file; only that stretch is heard; missing: the file's start and end), `fadeIn`, `fadeOut` (seconds, 0 or missing: none), `fadeCurve` (0 Linear, 1 Equal power; missing: equal power). Versions before 6 have no audio nodes.
  - `soundMix`: `layers` (one per input, in port order: `gain` 0..2 (default 1), `pan` -1..1 (0), `mute` and `solo` (false)), `inputs` (how many ports the card shows, at least 1), `limiter` (true), `duckBy?` (the input index that ducks the others, 0..15; missing: no ducking), `duckDepth` 0..30 dB (12), `duckThreshold` -80..0 dBFS (-35), `duckAttack` 0.001..2 s (0.05), `duckRelease` 0.01..5 s (0.4), written only while `duckBy` is set, `anim?` (keys on `layer<n>.gain`), `extrap?`. The rendered sound is never saved: it is rendered again on load from its inputs.
  - `generator`: `generatorId, width, height` (≤ 8192), `matchCanvas?` (true: drawn at the size of what it is composited into, `width × height` on its own; missing before version 11, so older generators keep their sizes), `params`, `anim?`. A Text (`textLayer`) also has `typeset`: `{ text, font: { family, weight, italic, width?, file? }, align, tracking, lineHeight }` -- the words (up to 2000 characters), the font (a Google Fonts family, one installed on the computer, or one brought in as a file, kept like an imported picture under `file`), alignment 0 left / 1 centre / 2 right, letter spacing (-0.2..1 em) and line height (0.5..3 em). `width` is a percent of normal, one of CSS's steps (50, 62.5, 75, 87.5, 112.5, 125, 150, 200), for a family with a width axis; missing is normal. Missing or damaged fields take the defaults. What was last drawn for it is not saved: the words are drawn again on load. A Model (`model3d`) also has `model?`: `{ name, mediaId? }`, its file's name and the id this browser keeps the file under (like an Image's); the mesh is read again from the file on load.
  - `modulator`: `modulatorId, params, helperFor?`, `anim?`. A Tracker also has `track?`, its analysed path: `{ start, fps, width, height, x, y, confidence, signature }` -- comp seconds of frame 0 and frames a second, the analysed picture's size in pixels, then one value per comp frame (x, y in uv, 0..1 from the bottom left; confidence 0..1, how sure each match was, which the preview draws as lost under Min Confidence; null where the analysis found no point) and what the path was made from. Missing or damaged: no path.
  - `effect`: `effectId, params`, `anim?`. A Code module also has `code`: `{ source }` (its GLSL fragment body, up to 20 000 characters); its `effectId` is `code:` and a hash of the source, made again from the source on load (new in version 12).
  - `effect` and `generator` also take `preview?`: `'off' | 'on' | 'auto'`, the preview mode the card starts on until this browser chooses one (a template can open a Text or Layers card closed). Missing: the module's own start; anything else is dropped.
  - `anim` (version 9): keyframes by channel -- a param's key, a point's
    `key.x` / `key.y`, a colour's `key.r` / `key.g` / `key.b` -- each a list of
    `{ t, v, interp }`: seconds on the comp, the value (a toggle 0 or 1, a menu
    its index), and how the stretch to the next key goes (`bezier` eases
    smoothly through the keys, `easeIn`, `easeOut`, `easeInOut` slow out of
    the key, into the next, or both, `linear`, `constant` holds; toggles and
    menus are always `constant`). A Smooth key may carry handles of its own:
    `hl` and `hr`, `[seconds, value]` from the key (left back in time, right
    on), with `handles` `aligned` or `free`; without them its handles are
    worked out (Auto).
  - `extrap` (version 9): by channel, `linear`, `cycle` or `pingpong` --
    what a keyed channel does before its first key and after its last.
    Missing: it holds.
    Channels the node has no param for are dropped on load.
  - `render`: `format` (`png|jpg|gif|mp4|webm|pngseq`; only mp4 and webm carry sound; `pngseq` comes back as a zip of `frame_00001.png`…), `quality` 0.01..1 (default 0.9; JPG quality, GIF colours, or video bitrate as bits per pixel per frame, 0.05 at 0 rising exponentially to 1.5 at 1, so ~66 Mbps at 1080p30 for 0.9, capped at 400 Mbps), `scale` 0.05..4 (1), `time` start s (0), `duration` 0.1..600 s (3; GIF ≤ 30, PNG sequence ≤ 60), `fps` 1..60 (30; GIF ≤ 30), `loopPreview?`, `batch?` (what it bakes of a batch: `{ mode: 'item' | 'each' | 'sheet', item, columns? }`; `item` from 0, for One; missing: the first picture), `range?` (`comp`: `time` and `duration` follow the comp's start and length, held within the format's limits; `work`: the work area's, or the comp's while there is none; missing: its own, as before version 9. A new Renderer follows the comp), `loudness?` (-14, -16 or -23 LUFS; missing or null: Off, as in older documents; a new Renderer starts at -14; the readout after an export is not saved), `filename?` (what Save names the file, before its timestamp; missing or empty: `comp`), `baked?` (the last file baked: `id` in this browser's media cache, `extension`, `requested`, `width`, `height`, `size` bytes, `at` ms, `duration?`, `fps?`, `warning?`, `items?`, how many files a zip baked picture by picture holds; the file itself is never in the document, and a document naming one this device lacks shows it as not here).
  - `export`: gone. An old document's Exporter is not loaded; its `filenamePrefix` becomes the `filename` of the Render it downloaded from.
  - `backgroundOutput`: `enabled?` (true), `fit?` (`fill|fit|cover|contain`), `opacity?` (1), `batch?` as a Scope's.
  - `renderOutput`: `width`, preview width in graph units (default 360); `batch?`, how it shows a batch: `{ mode: 'item' | 'grid', item, columns? }` (`item` from 0, the picture shown alone; `columns` 0 or missing: picked from the count). Missing: the first picture alone.
  - `scope`: `mode` (0 Waveform, 1 Parade, 2 Vectorscope, 3 Histogram; default 0), `batch?` (`{ mode: 'item', item }`: the picture of a batch it measures; a grid is read as its picture).
  - `projector`: `fit` (`contain|cover`, default `contain`), `batch?` as a Viewer's. Whether its window is open is not saved.
  - `recorder`: `format` (`mp4|webm`, default mp4), `quality` 0.05..1 (0.9, the bitrate, per pixel as a Render's), `fps` 1..60 (30), `scale` 0.1..1 (1; the long side is held to 1920), `batch?` as a Scope's. Takes are not saved. Versions before 7 have no scope, projector or recorder nodes.
  - `text`: `text` (up to 20 000 characters). Versions before 8 have no text or aiImage nodes.
  - `describe`: `task` (0 Caption, 1 Detailed, 2 More detailed; default 1), `text` (what it last wrote, or what was typed over it; up to 20 000 characters), `item?` (behind a batch, the picture it describes, from 0; missing: the first).
  - `aiImage`: `provider` (`openrouter|google`; missing means `openrouter`), `model` (that provider's model id; default `google/gemini-2.5-flash-image` on OpenRouter, or `gemini-3.1-flash-lite-image` on Google when only a Google key is set), `aspectRatio` (`1:1|16:9|9:16|4:3|3:4|3:2|2:3`, default `1:1`), `resolution` (`1K|2K|4K`, default `1K`), `resultId` (the kept picture's id in this device's IndexedDB `comp.media`, or null), `name, width, height`, `results?` (made from a batch: `{ resultId, width, height }` per picture, in order, at most 32; put out as a batch). The picture itself is not in the document: on another device the node comes back saying so, and Generate makes a new one.
  - `moduleGroup`: `name, members` (node ids), `inputs`/`outputs` (ports `{ node, handle, label, kind }`, kind `picture|param|field|mod|sound`), `exposed?` (`{ node, key, input?, label? }`).
  - `comment`: `width`, `height` (the frame in graph units, at least 140 × 64), `text` (up to 20 000 characters), `locked?` (true: left out of selections, not moved or resized). Versions before 10 have no comments.
- **Groups** are display only: members stay in the graph, hidden, with their
  own wires. The renderer never sees the group, so ungrouping loses nothing.
  `exposed` puts chosen member params (or a member's extra picture input) on
  the group card, optionally renamed. Hidden params (curve points, sequencer
  steps) cannot be exposed.
- **Presets** are a saved subgraph plus its exposed params; placing one adds it
  as a group. User presets live in `localStorage` under `comp.presets`.
  Built-in presets (`src/state/builtinPresets.ts`):
  - **Toon**: Blur → Posterize → Edge Detect.
  - **Slit-Scan**: Time Machine with a Gradient on its Time input.
  - **VHS**: Chroma Bleed → Line Jitter → Head Switch → Dropouts → Composite Video → Grain.
  - **CRT Screen**: Composite Video → Shadow Mask → Scanlines → Bloom → Lens → Vignette.
  - **Beat Punch**: Transform → Chromatic Aberration → Exposure, each driven
    through a Map Range from one Envelope fired by a Pulse.
  - **Film Print**: Halation → White Balance → Transform → Frame Hold (24) →
    Grain → Vignette, with a Noise × Math signal on Transform's offset for
    gate weave.
  - **Time Melt**: Time Machine with a Noise generator on its Time input.
  - **Neon FM**: Blur → Frequency Modulation → Halation → Gradient Map; the
    gradient after the glow colours its falloff, cyan cores into magenta.
  - **Thermal Camera**: Blur → Levels → Gradient Map (iron palette) → Pixelate →
    Sharpen → Grain.
  - **Night Vision**: Exposure → Gradient Map (green phosphor) → Bloom → Grain →
    Scanlines → Vignette (the round eyepiece).
  - **Risograph**: Levels → Dither (clustered dot, 3 levels, mono) → Gradient Map
    (two inks and the paper) → Chromatic Aberration (misregistration) → Grain
    (still, the paper).
  - **Game Boy**: Levels → Palette (Game Boy Classic, Bayer 4x4, Pixel Size 6) →
    Scanlines (faint, the LCD grid).
  - **MacPaint**: Levels → Dither (Atkinson, 1 bit) → Gradient Map (ink on a warm
    screen).
  - **Commodore 64**: Levels → Palette (Commodore 64, Bayer 4x4, Pixel Size 4) →
    Scanlines → Bloom.
  - **CGA**: Levels → Palette (CGA Cyan & Magenta, Bayer 8x8, Pixel Size 3) →
    Scanlines → Bloom.
  - **Amber Terminal**: Levels → Glyphs (ASCII, amber ink on black) → Scanlines →
    Bloom.
  - **Unknown Pleasures**: Levels → Rutt-Etra (white ridgelines, Occlusion 1,
    Smoothing).
  - **Oscilloscope**: Rutt-Etra (green, Dot Break 1, Beam Cutoff) → Bloom.
  - **Newsprint**: Levels → Print (CMYK, Euclidean dots, coarse ruling, high dot
    gain, slight misregistration, grey-cream stock).
  - **CCTV**: Lens → Saturation → Levels → Sensor Noise → Frame Hold (12) →
    Compression → Vignette.
  - **Bitrate Crash**: Compression → Datamosh, with a Pulse firing an Envelope
    whose Map Range drops Compression's quality.
  - **Watercolour**: Painterly → Levels → Saturation → Edge Detect (comp over input, at
    half mix) → Grain (still, the paper).
  - **Engraved Note**: Levels → Hatching → Vignette.
  - **Corrupted Signal**: Gradient Map (red) → Block Glitch → Line Jitter →
    Chromatic Aberration → Frame Hold (12), with a Pulse firing an Envelope
    whose two Map Ranges burst Block Glitch's intensity and Line Jitter's amount.
  - **Aerochrome**: Channel Mixer (red and green swapped) → Selective Color (reds
    towards magenta) → Levels → Bloom → Grain.
  - **Cinestill 800T**: White Balance (cool) → Levels → Halation (wide, red) →
    Bloom → Grain → Vignette.
  - **Portrait f/1.4**: Exposure → Bokeh, with Depth → Math (− focus) → Math
    (absolute) → Math (× aperture) as a field on Bokeh's radius.
  - **Hologram**: Black & White → Levels → Gradient Map (cyan) → Edge Detect (comp
    over input) → Scanlines → Line Jitter → Chromatic Aberration → Bloom →
    Exposure, with a Noise modulator through a Map Range flickering the Exposure.
  - **Anaglyph 3D**: Levels into Depth and two Remaps (Luma Value, the
    depth on their Map, opposite directions, one Value on both amounts) → Channel
    Mixers (red only; green and blue only) → Layers (Add).
  - **Stained Glass**: Crystal Mosaic → Saturation → Glass (Antique) → God Rays →
    Bloom.
  - **Cyanotype**: Black & White → Levels → Gradient Map (Prussian blue to white)
    → Paper (Watercolour).
  - **Underwater**: Depth (Fog) → Wobble → Caustics → White Balance → God Rays →
    Grain; Depth first so its model only runs again when the picture coming in
    changes.
  - **Teletext**: Levels → Glyphs (Blocks) → Posterize (2 levels: eight colours) →
    Scanlines → Interlace → Bloom.
  - **Warhol Grid**: Levels → Blur → four Gradient Maps (Step, a palette each) →
    Layers (Grid, 2 columns) → Chromatic Aberration.
  - **Mandala**: Kaleidoscope (Rotation from a slow LFO) → Tunnel → Bloom →
    Saturation, with a Pulse firing an Envelope whose Map Range swells the Bloom.
  - **Dream Rewind**: Time Offset → Echo → Halation → Chromatic Aberration → Blur
    (half mix) → Saturation, with a triangle LFO through a Map Range swinging the
    offset, so the picture keeps running back.

---

## 3. Module index

In the Module menu the categories, and the modules within each, are listed
alphabetically. The AI menu, between Module and Output, holds the AI
modules (section 7); Text and Prompt are in the Input menu, under Text, and Model under 3D.

| Category | Modules (id) |
| :-- | :-- |
| Color & Tone | Black & White (`blackwhite`), Channel Mixer (`channelMixer`), Channel Split (`channelSplit`), Color Balance (`colorBalance`), Curves (`curves`), Exposure (`exposure`), Invert (`invert`), Levels (`levels`), LUT (`lut`), Palette (`palette`), Saturation (`saturation`), Selective Color (`selectiveColor`), Shadows & Highlights (`shadowsHighlights`), Threshold (`threshold`), Vibrance (`vibrance`), White Balance (`whiteBalance`) |
| Stylize | Bands (`bands`), Crystal Mosaic (`crystalMosaic`), Disintegrate (`disintegrate`), Dither (`dither`), Edge Detect (`edgeDetect`), Emboss (`emboss`), Glyphs (`glyphs`), Goo (`goo`), Gradient Map (`gradientMap`), Halftone (`halftone`), Hatching (`hatching`), Holographic Foil (`holoFoil`), Iridescent Metal (`iridescentMetal`), Painterly (`painterly`), Paper (`paper`), Photocopy (`photocopy`), Pixelate (`pixelate`), Posterize (`posterize`), Print (`print`), Relight (`relight`), Risograph (`risograph`), Scatter (`scatter`), Slope (`slope`) |
| Optics & Blur | Anamorphic Streak (`streak`), Aura (`aura`), Bloom (`bloom`), Blur (`blur`), Bokeh (`bokeh`), Caustics (`caustics`), Chromatic Aberration (`chromaticAberration`), Crystal Ball (`crystalBall`), Denoise (`denoise`), Diffraction Spikes (`diffractionSpikes`), Directional Blur (`directionalBlur`), Dirty Lens (`dirtyLens`), Glass (`glass`), God Rays (`godRays`), Halation (`halation`), Lens (`lens`), Lens Flare (`lensFlare`), Lenticular (`lenticular`), Optic Compensation (`opticCompensation`), Prism Filter (`prismFilter`), Radial Blur (`radialBlur`), Rain on Glass (`rain`), Reflection (`waterReflection`), Sharpen (`sharpen`), Shattered Glass (`shatter`), Soap Film (`soapFilm`), Spectral Prism (`spectralPrism`), Tilt-Shift (`tiltShift`), Vignette (`vignette`) |
| Transform & Warp | Corner Pin (`cornerPin`), Depth Mesh (`depthMesh`), Displace (`displace`), Kaleidoscope (`kaleidoscope`), Polar Coordinates (`polarCoordinates`), Remap (`mapDisplace`), Resize / Crop (`resize`), Ripple (`ripple`), Swirl (`swirl`), Tile (`tile`), Transform (`transform`), Wobble (`wobble`) |
| CRT & Display | Composite Video (`compositeVideo`), Frequency Modulation (`fmScanlines`), Interlace (`interlace`), Particle Flow (`particleFlow`), Phase Modulation (`velocityMod`), Roll (`roll`), Rutt-Etra (`ruttEtra`), Scanlines (`scanlines`), Shadow Mask (`shadowMask`), Sub-pixels (`subpixels`) |
| Tape & Glitch | Block Glitch (`blockGlitch`), Chroma Bleed (`chromaBleed`), Compression (`compression`), Dropouts (`dropouts`), Glitch Machine (`glitchMachine`), Head Switch (`headSwitch`), Hum Bar (`humBar`), Line Jitter (`lineJitter`), Pixel Sort (`pixelSort`), Signal Rot (`signalRot`) |
| Noise & Grain | Film Damage (`filmDamage`), Grain (`grain`), Sensor Noise (`sensorNoise`) |
| Temporal | Datamosh (`datamosh`), Echo (`echo`), Feedback (`feedbackLoop`), Flames (`flames`), Frame Hold (`frameHold`), Freeze Frame (`freezeFrame`), Ink Flow (`inkFlow`), Motion Blur (`motionBlur`), Motion Detect (`motionDetect`), Optical Flow (`opticalFlow`), Stable Fluids (`stableFluids`), Time Machine (`timeMachine`), Time Offset (`timeOffset`), Time Range (`timeRange`), Time Remap (`timeRemap`), Trails (`trails`), Tunnel (`feedback`) |
| Composite | Blend (`blend`), Chroma Key (`chromaKey`), Collect (`collect`), Light Wrap (`lightWrap`), Mask (`mask`), Matte Tools (`matteTools`), Pick (`pick`) |
| Custom | Code (menu entry `code`: an effect made from the code on its card) |
| Generators (Input menu) | Cellular (`cellular`), Noise (`noise`), Pattern (`pattern`), Plasma (`plasma`), Gradient (`ramp`), Shape (`shape`), Solid Color (`solid`), Spectrum (`spectrum`), Wave Field (`waveField`) |
| Text (Input menu) | Text (generator `textLayer`), Prompt (node type `text`) |
| 3D (Input menu) | Model (generator `model3d`), 3D Shape (generator `shape3d`) |
| Audio (Module menu) | Sound Mix (node type `soundMix`); the sound readers Audio Level, Onset and Beat are in section 5 |
| AI (AI menu) | Generate: AI Image (node type `aiImage`), Colorize (`colorize`), Fill (`fill`) · Analyse: Beat (modulator `beat`), Cut Out (`cutOut`), Depth (`depth`), Depth Relight (`depthRelight`), Describe (node type `describe`), Magic Mask (`magicMask`), Re-angle (`reangle`), Text Mask (`textMask`) |

---

## 4. Effect modules

Each entry: id, source file, whether it animates, a **Summary:** line (one
sentence for people, shown when the module's menu entry is hovered), then
the module's own description and its parameters. Every module in a menu
has a Summary line somewhere in this file (sections 4 to 8), and a test
holds it to that.

The description (the blockquote) is written for people first: what the
module looks like and what its settings do. A paragraph reading exactly
`How it works:` splits it: what follows is how the module is built
(algorithms, uniforms, files, passes), which the documentation page folds
away. In the tables, an `active when` note is either an expression over
`params.<key>` or the condition in plain words.

### Color & Tone

#### Black & White

id `blackwhite` · [blackwhite.ts](src/engine/modules/blackwhite.ts) · static

Summary: Turns the picture grey, weighting each colour by how bright it looks to the eye.

> Desaturation weighted by how bright each colour looks to the eye, which
> tracks perceived brightness far better than a flat average of the
> channels -- a pure red and a pure green come out as clearly different
> greys rather than the same muddy one.
>
> Amount mixes rather than switches, so the effect can be dialed in.
>
> How it works:
>
> The weights are the Rec. 709 luma weights.
>
> It also proves that live parameter updates reach the shader.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `amount` | Amount | float | 0 … 1 (step 0.01) | 1 | ◇ |  |

#### Channel Mixer

id `channelMixer` · [channelMixer.ts](src/engine/modules/channelMixer.ts) · static

Summary: Rebuilds each colour channel from the other three: swap channels, fake infrared, or mix a custom black and white.

> Each output channel as a weighted sum of the three inputs: swap red and
> blue, build an infrared look from green, or -- with Monochrome -- a black
> and white mixed from chosen channels, the way a filter in front of
> black-and-white film would.
>
> Identity by default. Gains run negative as well, which is how a channel
> is subtracted out.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `monochrome` | Monochrome | bool | on / off | false | ◇ |  |
| `rFromR` | Red ← R | float | -2 … 2 (step 0.01) | 1 | ◇ |  |
| `rFromG` | Red ← G | float | -2 … 2 (step 0.01) | 0 | ◇ |  |
| `rFromB` | Red ← B | float | -2 … 2 (step 0.01) | 0 | ◇ |  |
| `gFromR` | Green ← R | float | -2 … 2 (step 0.01) | 0 | ◇ | section Green; active when `!params.monochrome` |
| `gFromG` | Green ← G | float | -2 … 2 (step 0.01) | 1 | ◇ | section Green; active when `!params.monochrome` |
| `gFromB` | Green ← B | float | -2 … 2 (step 0.01) | 0 | ◇ | section Green; active when `!params.monochrome` |
| `bFromR` | Blue ← R | float | -2 … 2 (step 0.01) | 0 | ◇ | section Blue; active when `!params.monochrome` |
| `bFromG` | Blue ← G | float | -2 … 2 (step 0.01) | 0 | ◇ | section Blue; active when `!params.monochrome` |
| `bFromB` | Blue ← B | float | -2 … 2 (step 0.01) | 1 | ◇ | section Blue; active when `!params.monochrome` |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Channel Split

id `channelSplit` · [channelSplit.ts](src/engine/modules/channelSplit.ts) · static

Summary: Pulls one channel out of the picture -- red, green, blue, alpha or luma -- as grey, in its colour, or as a matte.

> One channel of the picture on its own: red, green, blue, alpha or luma,
> as TouchDesigner's channel picks or Nuke's Shuffle out to a single
> channel. Splitting a picture is one Channel Split per channel, each
> reading the same input.
>
> Greyscale gives the channel as an opaque grey picture -- the form a
> mask, a height map or a displacement reads. In Colour keeps the channel
> where it was and zeroes the other two (luma and alpha, having no colour
> of their own, come out grey). Matte puts the channel in the alpha of a
> white picture, so it can be laid over something as a stencil.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `channel` | Channel | enum | 0=Luma, 1=Red, 2=Green, 3=Blue, 4=Alpha | 1 (Red) | ◇ |  |
| `view` | Output | enum | 0=Greyscale, 1=In Colour, 2=Matte | 0 (Greyscale) | ◇ |  |
| `invert` | Invert | bool | on / off | false | ◇ |  |

#### Color Balance

id `colorBalance` · [colorBalance.ts](src/engine/modules/colorBalance.ts) · static

Summary: Tints shadows, midtones and highlights separately, like teal shadows under warm highlights.

> Tints the shadows, midtones and highlights each their own colour -- teal
> shadows under warm highlights, and the rest of the grading look book.
>
> White is neutral.
>
> How it works:
>
> Each colour is normalised to its own luma before it is applied, so a tint
> shifts hue without darkening, and each is weighted by a smooth mask over
> the tonal range so the three blend into one another.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `shadows` | Shadows | color | RGB 0…1 | [1, 1, 1] | ◇ |  |
| `midtones` | Midtones | color | RGB 0…1 | [1, 1, 1] | ◇ |  |
| `highlights` | Highlights | color | RGB 0…1 | [1, 1, 1] | ◇ |  |
| `strength` | Strength | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Curves

id `curves` · [curves.ts](src/engine/modules/curves.ts) · static

Summary: Reshapes the tones with curves, for all channels together or each one on its own.

> Tone curves: one through the three channels together, and one per
> channel, each through up to eight points.
>
> Each channel goes through its own curve first, then the RGB curve, the
> order Photoshop applies them in.
>
> The curve through the points is a monotone cubic (Fritsch-Butland
> tangents): smooth, but it never overshoots a point, so a curve cannot
> push a value out of range or make a gradient run backwards between two
> points that both go up. Past the end points it is flat.
>
> How it works:
>
> The points are plain params -- a count and eight point slots per curve
> -- edited on the card by CurvesEditor rather than as rows, the way a
> Gradient's stops are. That keeps save, undo and presets working unchanged.
> They are hidden and portless: a curve is shaped by hand, not wired.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `mCount`, `mP0`, `mP1`, `mP2`, … | (editor data) | int, vec2 | edited by the card's own editor | — | none | 36 hidden params; no row, no port, not exposable |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Exposure

id `exposure` · [exposure.ts](src/engine/modules/exposure.ts) · static

Summary: Brightens or darkens in camera stops, the way more or less light would.

> Exposure in stops, as a camera counts it: +1 doubles the light, -1 halves
> it. A multiply rather than Levels' add, so black stays black and the
> picture brightens the way more light would, not the way a grey wash does.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `exposure` | Exposure | float | -4 … 4 (step 0.01) | 0 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Invert

id `invert` · [invert.ts](src/engine/modules/invert.ts) · static

Summary: Turns the picture into its negative.

> A negative. Mix dials it back, which passes through flat grey on the
> way -- a look of its own.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Levels

id `levels` · [levels.ts](src/engine/modules/levels.ts) · static · 4 passes (the first 3 only with Auto on)

Summary: Sets black and white points and gamma on a histogram, brightness and contrast, or stretches the picture to full range by itself (Auto): the usual first and last step of a chain.

> Brightness, contrast and gamma -- the module that goes at both ends of
> most chains, to set the signal up and to claw it back afterwards.
>
> Contrast pivots around 0.5 rather than 0 so raising it does not also
> brighten the picture, and gamma is applied last, on clamped values, since
> pow() of a negative is undefined and contrast can easily push below zero.
>
> Opacity, as on TouchDesigner's Level TOP, fades the picture toward
> transparent: it scales alpha only, since every module reads alpha straight.
>
> Black and White are the input points: what maps to black and to white,
> as in Photoshop's Levels.
>
> The card draws a **levels graph** under Auto: the histogram of the picture
> coming in as Black, Gamma and White see it (after Auto's stretch when Auto
> is on), luma filled with R, G, B outlined (stronger in Per Channel), and
> under it a handle for each point -- black, gamma, white -- dragged
> sideways, with their values beneath. Gamma's handle sits where the output
> reaches 50% (black + (white - black) × 0.5^gamma); moving Black or White
> keeps Gamma, so it follows. A drag is one undo step and keys a keyed
> point; a wired point shows the value coming in and takes no drag;
> double-click a handle to reset it.
>
> Black, Gamma and White keep their rows, ports and keys, folded under
> **Points**.
>
> Auto stretches the picture first, so its darkest Auto Clip % lands on
> black and its brightest Auto Clip % on white.
>
> Luma stretches every channel by the brightness's points; Per Channel
> stretches each channel by its own, which also takes out a colour cast. A
> picture with almost no range (a span under 0.02, fading in to 0.06) is
> left alone rather than its noise blown up. Transparent pixels are not
> measured. Black, White, Brightness, Contrast and Gamma then work on the
> stretched picture.
>
> How it works:
>
> The picture is a small copy (192 px on its long side) drawn from the
> module's input, read back without stalling, and only while the card is on
> screen (it takes one of the live preview places).
>
> The points are measured on every frame on the GPU (a 128 × 64 sample grid
> into a 128-bin cumulative histogram, the points interpolated inside a
> bin), with no readback: it plays live on video, is frame-exact in a file
> and draws the same on the render thread.
>
> With Auto off the measuring passes are skipped, so it is the one pass it
> always was.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `auto` | Auto | enum | 0=Off, 1=Luma, 2=Per Channel | 0 (Off) | ◇ | old documents read Off |
| `brightness` | Brightness | float | -0.5 … 0.5 (step 0.01) | 0 | ◇ |  |
| `contrast` | Contrast | float | 0 … 3 (step 0.01) | 1 | ◇ |  |
| `black` | Black | float | 0 … 1 (step 0.01) | 0 | ◇ | section Points; input black point, the graph's left handle; old documents read 0 |
| `gamma` | Gamma | float | 0.1 … 3 (step 0.01) | 1 | ◇ | section Points; the graph's middle handle |
| `white` | White | float | 0 … 1 (step 0.01) | 1 | ◇ | section Points; input white point (below Black inverts), the graph's right handle; old documents read 1 |
| `clip` | Auto Clip % | float | 0 … 5 (step 0.05) | 0.5 | ◇ | section Advanced; active when `params.auto !== 0`; percent cut at each end |
| `opacity` | Opacity | float | 0 … 1 (step 0.01) | 1 | ◇ | section Advanced; multiplies the alpha; old documents read 1 |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### LUT

id `lut` · [lut.ts](src/engine/modules/lut.ts) · static

Summary: Applies a `.cube` 3D or 1D LUT colour grade, kept in the browser's media cache.

> Loads a `.cube` colour lookup table from disk (1D or 3D) via the card's
> click-or-drop `.cube` target (it shows "Not on this device yet: drop it
> again" if missing on another device) and applies it with trilinear
> interpolation. While no LUT is loaded, passes the picture through
> untouched.
>
> How it works:
>
> The loaded file is kept in `mediaCache`.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Palette

id `palette` · [palette.ts](src/engine/modules/palette.ts) · static

Summary: Snaps every colour to the nearest of a fixed retro palette (Game Boy, CGA, C64, PICO-8, riso inks), dithered or flat.

> Every pixel snapped to the nearest colour of a fixed palette: the Game
> Boy's four greens, CGA, the C64, PICO-8, risograph ink pairs, tone ramps.
>
> The match is made in CIELAB (ΔE, CIE76) by default, so a colour lands on
> the swatch it looks closest to rather than the one nearest in raw RGB; RGB
> is there for the harsher, more "machine" result. Perceptual and Brightness
> skip the search: the picture's brightness (Lab L, or plain Rec. 709 luma)
> is cut into equal bands, one per swatch (sorted dark to light), so every
> colour of the palette is used. Hue bands the picture's hue over the
> palette's coloured swatches in wheel order (near-greys take the palette's
> own greys by lightness).
>
> An ordered dither offset is added before the snap, sized to the
> palette's own step in brightness, so Spread 1 is a classic ordered
> dither whatever the palette's size. Pixel Size makes the picture chunky
> first, dither cells and all, without a Pixelate in front.
>
> How it works:
>
> The palettes' Lab values are baked into the shader as constant tables.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `palette` | Palette | enum | 0=Game Boy Classic, 1=Game Boy Pocket, 2=Game Boy Light, 3=CGA Cyan & Magenta, 4=CGA Green & Red, 5=Commodore 64, 6=Apple II Hi-Res, 7=ZX Spectrum, 8=PICO-8, 9=Teletext, 10=CRT Amber Monitor, 11=Riso Fluo Pink & Cornflower, 12=Riso Sunflower & Teal, 13=Riso Gold & Crimson, 14=Riso 4-Ink, 15=CMYK Process, 16=Bronze Leaf, 17=Cyberpunk Neon, 18=Acid Techno, 19=Bauhaus Primary, 20=Swiss International, 21=Solarized Dark, 22=Nord, 23=Dracula, 24=Vaporwave Sunset, 25=Thermal, 26=Magma Glow, 27=Sunset Horizon, 28=Deep Ocean, 29=Vaporwave Dream, 30=Sepia Print, 31=Blueprint, 32=Amber CRT, 33=Matrix Terminal, 34=Mono High Contrast, 35=Cyan & Magenta, 36=Neon Ramp, 37=Solarized Ramp; menu headings Retro hardware (0–10), Print & ink (11–16), Mood (17–24), Tone ramps (25–37) | 0 (Game Boy Classic) | ◇ | each option shows its colours as a strip in the menu (`swatches`) |
| `dither` | Dither | enum | 0=None, 1=Bayer 4×4, 2=Bayer 8×8, 3=Blue Noise, 4=IGN | 1 (Bayer 4×4) | ◇ |  |
| `spread` | Spread | float | 0 … 1 (step 0.01) | 0.75 | ◇ | dither strength, in steps of the palette's brightness; active when `params.dither !== 0` |
| `cell` | Pixel Size | float | 1 … 32 (step 1) | 1 | ◇ | source pixels per cell; the dither runs per cell |
| `match` | Match | enum | 0=Lab (ΔE), 1=RGB, 2=Perceptual, 3=Brightness, 4=Hue | 0 (Lab (ΔE)) | ◇ | Perceptual (Lab L) and Brightness (Rec. 709 luma): brightness in equal bands over the swatches sorted dark to light, so all are applied; Hue: hue in equal bands over the coloured swatches in wheel order, near-greys on the palette's greys by lightness; section Advanced |
| `contrast` | Contrast | float | 0 … 2 (step 0.01) | 1 | ◇ | before the snap; section Advanced |
| `brightness` | Brightness | float | -1 … 1 (step 0.01) | 0 | ◇ | before the snap; section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Saturation

id `saturation` · [saturation.ts](src/engine/modules/saturation.ts) · static

Summary: Makes colours stronger or weaker and shifts their hue.

> Saturation and hue, as one module because they are the same operation
> seen from two angles and are almost always reached for together.
>
> Hue is in turns rather than degrees or radians, so the slider reads
> -0.5..0.5 and the ends meet where the colour wheel does.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `saturation` | Saturation | float | 0 … 2 (step 0.01) | 1 | ◇ |  |
| `hue` | Hue | float | -0.5 … 0.5 (step 0.005) | 0 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Selective Color

id `selectiveColor` · [selectiveColor.ts](src/engine/modules/selectiveColor.ts) · static

Summary: Adjusts one range of hues and leaves the rest alone, or greys out everything else.

> Adjusts one band of hues and leaves the rest alone -- or, with Outside
> Saturation at zero, greys out everything but that band: the red coat in
> a black-and-white street.
>
> The band is a hue and a half-width either side of it, feathered by
> Softness. Selection also fades out as a pixel loses saturation, since a
> grey's hue is noise: without that, every near-grey pixel would flicker
> in and out of the band.
>
> Hue is a slider in degrees rather than a colour pick so a signal can
> sweep it round the wheel. A click on the module's preview picks it from the
> picture coming in (the pipette, `HuePipette`).

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `hue` | Hue (°) | float | 0 … 360 (step 1) | 0 | ◇ |  |
| `range` | Range (°) | float | 0 … 180 (step 1) | 25 | ◇ |  |
| `hueShift` | Hue Shift (°) | float | -180 … 180 (step 1) | 0 | ◇ |  |
| `saturation` | Saturation | float | 0 … 2 (step 0.01) | 1 | ◇ |  |
| `lightness` | Lightness | float | -1 … 1 (step 0.01) | 0 | ◇ |  |
| `outside` | Outside Saturation | float | 0 … 1 (step 0.01) | 1 | ◇ |  |
| `softness` | Softness (°) | float | 0 … 90 (step 1) | 15 | ◇ | section Advanced |
| `showMask` | Show Mask | bool | on / off | false | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Shadows & Highlights

id `shadowsHighlights` · [shadowsHighlights.ts](src/engine/modules/shadowsHighlights.ts) · static

Summary: Lifts the shadows and recovers the highlights, each without touching the other.

> Lifts or crushes the dark end and recovers or pushes the bright end,
> each without touching the other -- the photo editor's first two sliders.
>
> Each side fades out smoothly through the midtones rather than drawing a
> line where it stops, and hues do not wash out as they would if each
> channel were pushed on its own.
>
> How it works:
>
> Each side is weighted by a smooth mask on luma. The shift is applied to
> luma and the colour scaled to match.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `shadows` | Shadows | float | -1 … 1 (step 0.01) | 0 | ◇ |  |
| `highlights` | Highlights | float | -1 … 1 (step 0.01) | 0 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Threshold

id `threshold` · [threshold.ts](src/engine/modules/threshold.ts) · static

Summary: Cuts the picture to pure black and white at a brightness level.

> Black where the picture's brightness is below Level, white above.
>
> Softness widens the edge into a ramp of grey either side of Level. At 0
> the edge is still antialiased over one pixel, so a hard cut stays clean
> at any resolution. Alpha is kept, so a cut-out stays cut out.
>
> How it works:
>
> It used to cut alpha through fractal noise with a hot rim, for burns, in
> Stylize; documents from then keep their Level and Softness, and the rest
> is unused.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `level` | Level | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `softness` | Softness | float | 0 … 0.5 (step 0.005) | 0 | ◇ | never below one pixel |
| `invert` | Invert | bool | on / off | false | ◇ | white below Level, black above |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Vibrance

id `vibrance` · [vibrance.ts](src/engine/modules/vibrance.ts) · static

Summary: Boosts dull colours more than vivid ones, so skin and sky stay natural.

> Saturation that goes easy on what is already saturated. Dull colours get
> the most of it and vivid ones the least, so skin and sky can be livened
> up without the reds going neon first. Negative values mute the same way.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `vibrance` | Vibrance | float | -1 … 1 (step 0.01) | 0 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### White Balance

id `whiteBalance` · [whiteBalance.ts](src/engine/modules/whiteBalance.ts) · static

Summary: Warms or cools the picture and corrects a green or magenta cast.

> Temperature along blue to amber, tint along green to magenta: the two
> axes a camera's white balance moves on. Warming a picture does not also
> brighten it.
>
> How it works:
>
> Applied as channel gains and then rescaled to the luma the pixel came in
> with.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `temperature` | Temperature | float | -1 … 1 (step 0.01) | 0 | ◇ |  |
| `tint` | Tint | float | -1 … 1 (step 0.01) | 0 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

### Stylize

#### Bands

id `bands` · [bands.ts](src/engine/modules/bands.ts) · animated when `params.speed !== 0`

Summary: Slices brightness into repeating bands of two colours: contour lines, marbling, topographic maps.

> A threshold that repeats: brightness cut into Count bands of Color A and
> Color B, so every contour of the picture becomes a line. Behind a warped
> field (Plasma through Displace) it is marbling; on a photo, a topographic
> map.
>
> Width is the share of each cycle that is Color A. Softness widens each
> edge, in fractions of a cycle; at 0 the edges are still antialiased over
> one pixel, so they stay clean at any resolution. Jitter makes the
> bands hand-drawn: each band gets its own thickness (scaled around Width,
> so none vanishes) and the lines wander with smooth noise.
> Offset slides the bands through the picture; Speed keeps them sliding.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `count` | Count | float | 1 … 64 (step 0.5) | 8 | ◇ | cycles across the brightness range |
| `width` | Width | float | 0 … 1 (step 0.01) | 0.5 | ◇ | share of each cycle in Color A |
| `colorA` | Color A | color | RGB 0…1 | [1, 1, 1] | ◇ |  |
| `colorB` | Color B | color | RGB 0…1 | [0, 0, 0] | ◇ |  |
| `speed` | Speed | float | -2 … 2 (step 0.01) | 0 | ○ | phased: integrated over time, single value only; cycles per second |
| `softness` | Softness | float | 0 … 0.5 (step 0.005) | 0 | ◇ | in cycles; never below one pixel; section Advanced |
| `jitter` | Jitter | float | 0 … 1 (step 0.01) | 0 | ◇ | per-band thickness and wandering lines; section Advanced |
| `offset` | Offset | float | -1 … 1 (step 0.01) | 0 | ◇ | in cycles; section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Crystal Mosaic

id `crystalMosaic` · [crystalMosaic.ts](src/engine/modules/crystalMosaic.ts) · animated when `params.speed !== 0`

Summary: Breaks the picture into irregular cells of flat colour, like stained glass.

> The picture broken into irregular cells -- a Voronoi diagram -- each
> filled with the colour under its seed, like stained or cut glass.
>
> Seeds are jittered from a square grid, so Randomness at 0 is a plain
> grid of squares and at 1 fully irregular cells. Speed sets them orbiting
> their grid spot; it is phased, so changing it mid-play never jumps.
>
> How it works:
>
> The edge line is the exact distance to the border between the nearest
> seed and its neighbours (the second pass), not the cheaper difference
> of the two nearest distances, which draws lines of uneven width.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `cellSize` | Cell Size | float | 4 … 200 (step 1) | 32 | ◇ |  |
| `randomness` | Randomness | float | 0 … 1 (step 0.01) | 1 | ◇ |  |
| `facet` | Facet | float | 0 … 1 (step 0.01) | 0 | ◇ |  |
| `edgeWidth` | Edge Width | float | 0 … 10 (step 0.1) | 1 | ◇ |  |
| `edgeColor` | Edge Color | color | RGB 0…1 | [0.05, 0.05, 0.06] | ◇ |  |
| `speed` | Speed | float | -4 … 4 (step 0.01) | 0 | ○ | phased: integrated over time, single value only |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Disintegrate

id `disintegrate` · [disintegrate.ts](src/engine/modules/disintegrate.ts) · static · extra picture inputs: `map` (Order)

Summary: Breaks the picture into flakes that drift away, turn to ash and burn out.

> The picture coming apart into flakes that drift away and burn out.
>
> The frame is cut into square cells, each with its own moment to let go:
> a sweep across the frame (Direction), broken up by noise (Roughness), or
> the brightness of the Order input where one is wired -- dark goes first,
> so a matte or a ramp says where it starts. Progress runs every cell
> through it: from 0, the whole picture, to 1, nothing left.
>
> A cell that has let go leaves a hole (transparent, for Layers to put
> something behind) and becomes a flake carrying its piece of the picture.
> Over its life the flake rises along Drift, sways, spins, shrinks, turns
> to ash and fades. The edge still holding, and flakes just released, glow
> with the Burn colour.
>
> Everything is a function of Progress, never of time: key or wire Progress
> and the dissolve scrubs, plays backwards and renders the same every time.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `progress` | Progress | float | 0 … 1 (step 0.001) | 0.5 | ◇ | 0 whole picture, 1 all gone; key or wire it to play the dissolve |
| `angle` | Direction | float | 0 … 360 (step 1) | 0 | ◇ | degrees the sweep travels, 0 = left to right; ignored where Order is wired |
| `roughness` | Roughness | float | 0 … 1 (step 0.01) | 0.5 | ◇ | 0 a straight front, 1 noise patches |
| `scale` | Noise Scale | float | 0.5 … 20 (step 0.1) | 4 | ◇ |  |
| `ash` | Ash Color | color | RGB 0…1 | [0.02, 0.02, 0.02] | ◇ |  |
| `ashAmount` | Ash | float | 0 … 1 (step 0.01) | 0.7 | ◇ | 0 keeps the picture's colour on the flakes |
| `cellSize` | Flake Size | float | 2 … 64 (step 0.5) | 6 | ◇ | pixels; section Flakes |
| `life` | Flake Life | float | 0.02 … 1 (step 0.01) | 0.25 | ◇ | how much of Progress a flake lasts; section Flakes |
| `travel` | Travel | float | 0 … 32 (step 0.5) | 12 | ◇ | in flake sizes; section Flakes |
| `wind` | Drift | float | 0 … 360 (step 1) | 90 | ◇ | degrees the flakes fly, 90 = up; section Flakes |
| `sway` | Sway | float | 0 … 0.5 (step 0.01) | 0.3 | ◇ | section Flakes |
| `spin` | Spin | float | 0 … 1 (step 0.01) | 0.4 | ◇ | section Flakes |
| `edge` | Burn Edge | float | 0 … 0.3 (step 0.005) | 0.04 | ◇ | width of the glowing front; section Burn |
| `glow` | Burn Glow | float | 0 … 4 (step 0.05) | 1.5 | ◇ | section Burn |
| `edgeColor` | Burn Color | color | RGB 0…1 | [1, 0.25, 0.08] | ◇ | section Burn |

#### Dither

id `dither` · [dither.ts](src/engine/modules/dither.ts) · static

Summary: Reduces the picture to a few colours with dither patterns: 1-bit Mac, Game Boy, print.

> Dithering module featuring notorious ordered, blue-noise, clustered-dot,
> and stochastic dithering algorithms for retro 1-bit Mac, Game Boy, VGA,
> print halftone, and modern rendering aesthetics.
>
> Quantizes luminance or color channels against threshold patterns including
> recursive Bayer matrices, clustered-dot print screens, Ulichney void-and-cluster
> blue noise, Jimenez interleaved gradient noise (IGN), and stochastic noise.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `matrix` | Pattern | enum | 0=Bayer 2x2, 1=Bayer 4x4, 2=Bayer 8x8, 3=Cluster Dot 4x4, 4=Cluster Dot 8x8, 5=Blue Noise, 6=IGN (Jimenez), 7=White Noise, 8=Diagonal Lines, 9=Horizontal Lines, 10=Floyd-Steinberg, 11=Atkinson, 12=Bayer 16x16, 13=Crosshatch 8x8, 14=Spiral, 15=Void-and-Cluster, 16=R-Sequence, 17=Knuth Dot Diffusion, 18=Vertical Lines | 1 (Bayer 4x4) | ◇ | menu grouped (Ordered, Halftone, Lines, Noise, Error diffusion); Void-and-Cluster is a 16x16 tile built at load; Knuth Dot Diffusion is approximated as its 8x8 class matrix used as an ordered threshold; Spiral is one spiral line over the whole frame, centred, wider where the picture is lighter, turned by Screen Angle |
| `scale` | Pattern Scale | float | 1 … 8 (step 1) | 1 | ◇ |  |
| `levels` | Color Levels | int | 2 … 16 | 2 | ◇ |  |
| `monochrome` | Monochrome | bool | on / off | false | ◇ |  |
| `angle` | Screen Angle | float | -180 … 180 (step 1) | 0 | ◇ | turns the pattern lookup, degrees; dimmed for Floyd-Steinberg and Atkinson |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Edge Detect

id `edgeDetect` · [edgeDetect.ts](src/engine/modules/edgeDetect.ts) · static

Summary: Keeps only the outlines: line art, neon edges, sketches.

> Edge detector for technical line art, cyberpunk neon outlines, and
> sketch looks. Can output pure monochrome lines, coloured neon outlines,
> or composite glowing edges directly back over the source.
>
> Laid out as TouchDesigner's Edge TOP, under its names and in its order:
> Select picks what is compared (luminance or one channel, for a loop
> carrying a height in red), Black Level drops the edges weaker than it
> and stretches the rest back to full, so a loop's grain doesn't come out
> as edges, Strength scales them, and Sample Step is how far apart the
> neighbours compared are. A wide step is what gives TouchDesigner's broad
> edges, the shape showing through them: the difference with neighbours
> that far off is a band carrying the picture's own gradients, not a
> hairline. Mode is ours; Comp Over Input lays the edges over the picture
> as TouchDesigner's toggle does. Edges in Alpha makes the picture
> transparent off the edges, as TouchDesigner's Alpha: Edge, to lay them
> over something else with a Layers module (all but Comp Over Input, which
> already lays them over the picture).
>
> How it works:
>
> The edges are found with a Sobel operator: spatial image gradients
> computed with a 3x3 kernel. Mode's keys are kept as they were so
> documents look the same.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `mode` | Mode | enum | 0=White on Black, 1=Black on White, 2=Neon Edge, 3=Comp Over Input | 0 (White on Black) | ◇ |  |
| `channel` | Select | enum | 0=Luminance, 1=Red, 2=Green, 3=Blue, 4=Alpha | 0 (Luminance) | ◇ | what is compared |
| `blackLevel` | Black Level | float | 0 … 1 (step 0.01) | 0 | ◇ | edges weaker than this go black, the rest stretched to full |
| `sensitivity` | Strength | float | 0.01 … 10 (step 0.01) | 2 | ◇ |  |
| `thickness` | Sample Step | float | 0.5 … 64 (step 0.1) | 1 | ◇ | how far apart the neighbours compared are, in px; wide for broad edges |
| `edgeColor` | Edge Color | color | RGB 0…1 | [0, 1, 0.85] | ◇ |  |
| `edgeAlpha` | Edges in Alpha | bool | on / off | false | ◇ | transparent off the edges (not in Comp Over Input) |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Emboss

id `emboss` · [emboss.ts](src/engine/modules/emboss.ts) · static

Summary: Raises the picture into a relief, lit from one side.

> Relief: the picture's brightness read as height and lit from one side,
> so edges facing the light rise and the ones facing away sink.
>
> The slope is the difference between two samples either side of the pixel
> along the light's direction. Grey shows the relief alone, on mid grey;
> Colour lights the picture with it; Overlay lays the grey relief over the
> picture as an overlay blend, which keeps the colours and adds the bevel.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `angle` | Angle (°) | float | 0 … 360 (step 1) | 135 | ◇ |  |
| `height` | Height | float | 0 … 10 (step 0.1) | 2 | ◇ |  |
| `distance` | Distance | float | 0.5 … 16 (step 0.5) | 1.5 | ◇ |  |
| `mode` | Mode | enum | 0=Grey, 1=Colour, 2=Overlay | 0 (Grey) | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Glyphs

id `glyphs` · [glyphs.ts](src/engine/modules/glyphs.ts) · animated when `params.set === 2 && params.speed !== 0`

Summary: Redraws the picture as characters on a grid, picked by brightness: ASCII art.

> The picture redrawn as characters on a grid: each cell becomes a glyph
> picked by how bright that part of the picture is.
>
> Sets:
> - ASCII: characters from space up, by how much ink each has, from one of
>   several ramps -- Classic punctuation, die-face Dots, Lines, typewriter
>   Letters, or Shapes from a dot to a solid square; Box Drawing lines.
>   Braille and Quadrants are not bitmaps: each of a cell's 2 x 4 dots (or
>   2 x 2 quadrants) is lit by the picture sampled at its own spot (a Braille
>   cell is half as wide as tall).
> - Blocks: the shade characters, empty to full in five steps.
> - Code Rain: flickering digits in columns that fall, lit by the picture.
> - LED: a board of round lamps, each at its cell's brightness.
>
> Cell Size is in source pixels, so a preview and the export break up the
> same way.
>
> How it works:
>
> The font is 5 x 5 pixels, drawn below as text and packed into one int per
> glyph, so it lives in the shader and needs nothing loaded.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `set` | Set | enum | 0=ASCII, 1=Blocks, 2=Code Rain, 3=LED | 0 (ASCII) | ◇ |  |
| `ramp` | Ramp | enum | 0=Classic, 1=Dots, 2=Lines, 3=Letters, 4=Shapes, 5=Braille, 6=Quadrants, 7=Box Drawing | 0 (Classic) | ◇ | active when `params.set === 0` |
| `size` | Cell Size | float | 4 … 48 (step 1) | 10 | ◇ |  |
| `tint` | Color | enum | 0=Source, 1=Ink | 0 (Source) | ◇ |  |
| `ink` | Ink | color | RGB 0…1 | [0.35, 1, 0.55] | ◇ | active when `params.tint === 1` |
| `speed` | Speed | float | 0 … 4 (step 0.05) | 1 | ○ | phased: integrated over time, single value only; active when `params.set === 2` |
| `contrast` | Contrast | float | 0.25 … 4 (step 0.05) | 1 | ◇ | section Advanced |
| `background` | Background | color | RGB 0…1 | [0, 0, 0] | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Goo

id `goo` · [goo.ts](src/engine/modules/goo.ts) · static · 6 passes

Summary: Makes shapes melt and stick together like blobs of liquid.

> Shapes that stick together: the metaball trick on a picture.
>
> Each shape gives off a field that fades with distance; the fields add up,
> and the outline is drawn where the sum crosses a level. Close shapes grow
> a bridge between them, far ones stay apart.
>
> Blur and cut shrinks small shapes and erases thin lines; Hold Shapes keeps
> the input's shapes whole and only adds the bridges. Moves when its input
> moves; Trails before it gives strings and drips.
>
> How it works:
>
> Mask, two rounds of blur, cut. The colour is blurred premultiplied and
> divided back out, so a bridge between a red and a blue shape is their
> blend.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `shape` | Shape From | enum | 0=Alpha, 1=Brightness, 2=Darkness | 1 (Brightness) | ◇ | what counts as a shape: Brightness is the brightest channel, Darkness the darkest one's distance from white |
| `reach` | Reach | float | 0 … 128 (step 0.5) | 24 | ◇ | how far apart shapes still pull together, in source pixels |
| `stickiness` | Stickiness | float | 0 … 1 (step 0.01) | 0.5 | ◇ | higher merges from further away, and fattens |
| `softness` | Softness | float | 0 … 0.5 (step 0.005) | 0.02 | ◇ | edge width; never under a pixel |
| `hold` | Hold Shapes | bool | on / off | false | ◇ | keep the input's shapes whole |
| `colour` | Colour | enum | 0=Blend, 1=Original | 0 (Blend) | ◇ | Original: each shape keeps its colour, graded into the blend outside it (no seam at its edge) |
| `background` | Background | enum | 0=Transparent, 1=Original | 0 (Transparent) | ◇ | Transparent: the goo alone, ready to composite |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Gradient Map

id `gradientMap` · [gradientMap.ts](src/engine/modules/gradientMap.ts) · static

Summary: Recolours the picture by mapping its brightness onto a gradient.

> Remap brightness onto a gradient of up to eight stops.
>
> Driven by luma rather than per channel, so the result is the gradient's
> colours and nothing of the original hue survives -- which is the point:
> this is how a grey burn map becomes embers, a depth map a heat map, and
> a picture a duotone.
>
> Index picks what reads the gradient: luma, or one channel -- a picture
> carrying its height in red and a second field in green is coloured by
> each on its own, as TouchDesigner's Lookup TOP reads one channel.
>
> The stops are the Gradient's, edited with the same editor on the card.
>
> How it works:
>
> They used to be three fixed colours and a midpoint (`low`, `mid`, `high`,
> `midpoint`); `document.ts` reads those as stops 1-3.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `channel` | Index | enum | 0=Luma, 1=Red, 2=Green, 3=Blue, 4=Alpha | 0 (Luma) | ◇ | what reads the gradient |
| `interpolation` | Interpolation | enum | 0=Linear, 1=Smooth, 2=Step | 0 (Linear) | ◇ |  |
| `stopCount` | Stops | int | 2 … 8 | 3 | none | edited by the card's gradient editor; no row |
| `pos0` | Pos 1 | float | 0 … 1 (step 0.01) | 0 | none | gradient editor; kept sorted by position |
| `color0` | Color 1 | color | RGB 0…1 | [0.05, 0.02, 0.1] | none | gradient editor |
| `pos1` | Pos 2 | float | 0 … 1 (step 0.01) | 0.5 | none | gradient editor |
| `color1` | Color 2 | color | RGB 0…1 | [0.85, 0.25, 0.05] | none | gradient editor |
| `pos2` | Pos 3 | float | 0 … 1 (step 0.01) | 1 | none | gradient editor |
| `color2` | Color 3 | color | RGB 0…1 | [1, 0.95, 0.7] | none | gradient editor |
| `pos3` … `pos7` | Pos 4 … 8 | float | 0 … 1 (step 0.01) | 1 | none | gradient editor; used up to `stopCount` |
| `color3` … `color7` | Color 4 … 8 | color | RGB 0…1 | as the Gradient's | none | gradient editor; used up to `stopCount` |
| `alpha0` … `alpha7` | Opacity 1 … 8 | float | 0 … 1 (step 0.01) | 1 | none | gradient editor (in percent); multiplies the picture's alpha; colours blend premultiplied |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Halftone

id `halftone` · [halftone.ts](src/engine/modules/halftone.ts) · static

Summary: Turns the picture into a print dot screen: comics, pop art, newspapers.

> Halftone dot screen for print reproduction, pop art, and comic books.
>
> Simulates ink rosettes and printing screens. Sizes dots proportionally
> to local ink density, with adjustable dot frequency, angle, and softness.
>
> Dot Shape picks the spot function (shared with Print).
> Round is the original dot, its radius the square root of the density;
> every other shape prints the same ink area Round would at that density,
> so changing shape changes the texture, not the exposure.
>
> How it works:
>
> The spot functions are in dotShapes.ts.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `scale` | Screen Frequency | float | 10 … 120 (step 1) | 45 | ◇ |  |
| `angle` | Screen Angle | float | 0 … 90 (step 1) | 45 | ◇ |  |
| `softness` | Dot Softness | float | 0.01 … 0.5 (step 0.01) | 0.1 | ◇ |  |
| `paper` | Paper Color | color | RGB 0…1 | [0.96, 0.94, 0.9] | ◇ |  |
| `ink` | Ink Color | color | RGB 0…1 | [0.08, 0.08, 0.1] | ◇ |  |
| `dotShape` | Dot Shape | enum | 0=Round, 1=Euclidean, 2=Ellipse, 3=Square, 4=Diamond, 5=Line | 0 (Round) | ◇ | spot functions shared with Print (`dotShapes.ts`); Round is the original dot (radius √density), every other shape area-calibrated to print the same ink area Round would; Dot Softness widens their edge in spot units |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Hatching

id `hatching` · [hatching.ts](src/engine/modules/hatching.ts) · static

Summary: Draws the tones with parallel ink lines, like an engraving or a banknote.

> The picture engraved: tone carried by parallel ink lines, as on a
> banknote or an etching, rather than by dots (Halftone) or a threshold
> pattern (Dither).
>
> Each layer is a set of lines at its own angle -- the first at Angle, the
> second across it, the third and fourth on the diagonals between -- and
> comes in only where the picture is dark enough for it, thickening as it
> darkens. Light areas get thin single lines, shadows a dense cross-hatch.
> However many layers, black ends up all but covered in ink.
>
> Contour bends the lines with the picture's (smoothed) brightness, so they
> swell round shapes the way an engraver's lines follow the form instead of
> running ruler-straight across it.
>
> Spacing is in source pixels; the lines are antialiased at any size.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `spacing` | Line Spacing | float | 2 … 32 (step 0.5) | 6 | ◇ |  |
| `angle` | Angle | float | 0 … 180 (step 1) | 45 | ◇ |  |
| `layers` | Layers | int | 1 … 4 | 3 | ◇ |  |
| `weight` | Line Weight | float | 0.2 … 2 (step 0.05) | 1 | ◇ |  |
| `contour` | Contour | float | 0 … 2 (step 0.01) | 0.4 | ◇ |  |
| `ink` | Ink | color | RGB 0…1 | [0.1, 0.1, 0.13] | ◇ |  |
| `paper` | Paper | color | RGB 0…1 | [0.95, 0.93, 0.86] | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Holographic Foil

id `holoFoil` · [holoFoil.ts](src/engine/modules/holoFoil.ts) · animated when `params.speed !== 0 && params.sway !== 0`

Summary: Adds the shifting rainbow sheen of a hologram sticker.

> The rainbow sheen of a hologram sticker or a CD: a foil ruled with a
> diffraction grating, its colour set by the angle you hold it at.
>
> Tiles is the classic sticker, patches ruled in different directions so
> they flash at different tilts; Radial (CD) runs the grooves round the
> centre as a disc's do, which gives the familiar spokes of colour;
> Linear is one ruling over the whole sheet. Sparkle scatters glitter
> flakes that each catch the light at their own angle.
>
> The foil is screened over the picture -- everywhere, or only where it is
> light or dark, as foil under or over a print shows -- and Sway rocks
> the card as a hand does, on Speed's phase.
>
> How it works:
>
> A grating of spacing d sends wavelength lambda out where the change in
> the sine of the angle across it, light in to eye out, is m lambda / d.
> So for each pixel the module takes that change -- the card's Tilt, plus
> how the angle to the eye drifts across the surface -- measured along the
> grating's direction, and reads off which wavelength comes back: the
> first order brightest, the second fainter beside it, nothing where the
> answer falls outside the visible, and a plain silver flash at the zero
> order, where the foil is a mirror.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `pattern` | Pattern | enum | 0=Tiles, 1=Radial (CD), 2=Linear | 0 (Tiles) | ◇ |  |
| `amount` | Amount | float | 0 … 1 (step 0.01) | 0.8 | ◇ |  |
| `tileSize` | Tile Size | float | 0.01 … 0.3 (step 0.001) | 0.04 | ◇ | active when `params.pattern === TILES` |
| `tiltX` | Tilt X | float | -1 … 1 (step 0.01) | 0.3 | ◇ |  |
| `tiltY` | Tilt Y | float | -1 … 1 (step 0.01) | 0 | ◇ |  |
| `sparkle` | Sparkle | float | 0 … 1 (step 0.01) | 0.3 | ◇ |  |
| `speed` | Sway Speed | float | 0 … 2 (step 0.01) | 0.2 | ○ | phased: integrated over time, single value only |
| `grating` | Grating Density | float | 0.8 … 3 (step 0.01) | 1.6 | ◇ | section Advanced |
| `sway` | Sway | float | 0 … 1 (step 0.01) | 0.5 | ◇ | section Advanced |
| `applyTo` | Apply To | enum | 0=Whole Picture, 1=Highlights, 2=Shadows | 0 (Whole Picture) | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Iridescent Metal

id `iridescentMetal` · [iridescentMetal.ts](src/engine/modules/iridescentMetal.ts) · static

Summary: Turns the picture into embossed liquid metal with an oily rainbow sheen.

> 3D embossed normal estimation with thin-film optical interference, liquid chrome
> reflections, and metallic sheen.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `depth` | Depth | float | 0 … 5 (step 0.05) | 1.5 | ◇ |  |
| `smoothness` | Smoothness | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `roughness` | Roughness | float | 0 … 1 (step 0.01) | 0.2 | ◇ |  |
| `iridescence` | Iridescence | float | 0 … 1 (step 0.01) | 0.7 | ◇ |  |
| `palette` | Palette | enum | 0=Oil Slick, 1=Rainbow, 2=Titanium, 3=Pearl, 4=Mercury | 0 (Oil Slick) | ◇ |  |
| `lightAngle` | Light Angle | float | 0 … 360 (step 1) | 45 | ◇ |  |
| `reflection` | Reflection | float | 0 … 1 (step 0.01) | 0.4 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Painterly

id `painterly` · [painterly.ts](src/engine/modules/painterly.ts) · static · 4 passes

Summary: Repaints the picture in brush strokes that follow its shapes.

> Brush strokes that follow the picture's shapes.
>
> Brush Size is in source pixels. Large ellipses are sampled sparsely,
> so the cost stays bounded at the price of some speckle in huge strokes.
>
> How it works:
>
> It is an anisotropic Kuwahara filter (Kyprianidis, Kang and Döllner,
> with polynomial sector weights).
>
> A plain Kuwahara takes, at each pixel, the mean of whichever nearby
> region is flattest, so areas go flat while edges stay put -- paint
> rather than blur. This one first measures which way the picture runs
> at every pixel (the structure tensor), then stretches the region into
> an ellipse along it, so the flat patches become strokes laid along the
> edges and folds of the picture.
>
> Passes: 0 finds the gradient at each pixel, 1 and 2 smooth it into a
> direction and how strongly it holds (float targets, read raw), 3 paints.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `radius` | Brush Size | float | 1 … 24 (step 0.5) | 6 | ◇ |  |
| `stretch` | Stroke Length | float | 0 … 4 (step 0.05) | 1 | ◇ |  |
| `sharpness` | Sharpness | float | 1 … 18 (step 0.5) | 8 | ◇ |  |
| `hardness` | Hardness | float | 1 … 100 (step 1) | 8 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Paper

id `paper` · [paper.ts](src/engine/modules/paper.ts) · static

Summary: Prints the picture on paper, with its grain and fibres showing.

> The picture printed on paper: ink soaked into a sheet with a real
> surface, lit from the side so its tooth and fibres show.
>
> The sheet has fine tooth, short straight fibres lying mostly the way the
> sheet ran through the machine, and -- for watercolour -- the small,
> packed, uneven mounds of cold-pressed paper. Paper Type sets how much of
> each there is and how thirsty the sheet is. A raking light from Light
> Angle shades it, so Relief brings the surface up the way a sheet held to
> a window does.
>
> Ink is subtractive: the picture's darkness in each channel is the ink's
> density there, laid over Paper Color. It pools in the valleys of the
> surface and thins on its peaks, as Ink Absorption says; it wicks outward
> by Bleed, with ragged edges rather than soft ones; and Mottle makes the
> coverage blotchy across the sheet, the way a press never lays ink
> perfectly evenly. Density is capped short of black, as no ink on paper
> reaches it.
>
> Built to follow Halftone, Dither or Hatching, so their ink lands on a
> sheet instead of a perfect surface.
>
> How it works:
>
> The sheet is a height field. Its slopes are taken by differencing the
> field twice more, and the raking light shades them. Bleed is feathered
> by random taps, which is what makes the edges ragged.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `paperType` | Paper Type | enum | 0=Fine, 1=Newsprint, 2=Watercolour, 3=Cardboard | 1 (Newsprint) | ◇ |  |
| `relief` | Relief | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `textureScale` | Texture Scale | float | 0.25 … 4 (step 0.01) | 1 | ◇ |  |
| `lightAngle` | Light Angle (°) | float | -180 … 180 (step 1) | 135 | ◇ |  |
| `ink` | Ink | float | 0 … 1.5 (step 0.01) | 1 | ◇ |  |
| `paperColor` | Paper Color | color | RGB 0…1 | [0.96, 0.93, 0.86] | ◇ |  |
| `absorption` | Ink Absorption | float | 0 … 1 (step 0.01) | 0.5 | ◇ | section Advanced |
| `bleed` | Bleed | float | 0 … 8 (step 0.1) | 1.5 | ◇ | section Advanced |
| `mottle` | Mottle | float | 0 … 1 (step 0.01) | 0.3 | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Photocopy

id `photocopy` · [photocopy.ts](src/engine/modules/photocopy.ts) · static

Summary: Runs the picture through a tired photocopier: harsh toner, a crooked page, dirt.

> The picture run through a tired photocopier: crushed to toner, a little
> crooked, with all the dirt a copy picks up.
>
> The copier's optics soften the original first. Edges then come out
> harder than flat areas -- the edge effect -- so the dark side of every
> edge is darkened. Threshold and Contrast decide where toner lands, which
> is what flattens a photo into the stark copy look.
>
> The toner clumps, so solids are mottled and midtones break into speckle.
> Stray toner leaves specks in the whites, a scratched drum draws thin
> lines down the page, and a drum running low leaves pale vertical bands.
> Skew and Zoom place the original crooked on the glass; where it does not
> reach, the copy shows the grey shadow of the lid.
>
> How it works:
>
> The drum develops edges harder than flat areas because charge gathers at
> the border of a dark patch. It is made by darkening each pixel by
> comparing the softened picture with a wider ring round it. Threshold and
> Contrast make a steep tone curve.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `threshold` | Threshold | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `contrast` | Contrast | float | 0.5 … 8 (step 0.05) | 2.5 | ◇ |  |
| `tonerGrain` | Toner Grain | float | 0 … 1 (step 0.01) | 0.4 | ◇ |  |
| `specks` | Specks | float | 0 … 1 (step 0.01) | 0.3 | ◇ |  |
| `paperColor` | Paper Color | color | RGB 0…1 | [0.95, 0.95, 0.93] | ◇ |  |
| `tonerColor` | Toner Color | color | RGB 0…1 | [0.07, 0.07, 0.08] | ◇ |  |
| `skew` | Skew (°) | float | -5 … 5 (step 0.05) | 0.5 | ◇ | section Scan |
| `zoom` | Zoom | float | 0.8 … 1.3 (step 0.005) | 1 | ◇ | section Scan |
| `lidShadow` | Lid Shadow | float | 0 … 1 (step 0.01) | 0.8 | ◇ | section Scan |
| `softness` | Softness | float | 0 … 4 (step 0.05) | 0.8 | ◇ | section Advanced |
| `edgeDarkening` | Edge Darkening | float | 0 … 1 (step 0.01) | 0.5 | ◇ | section Advanced |
| `streaks` | Streaks | float | 0 … 1 (step 0.01) | 0.3 | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Pixelate

id `pixelate` · [pixelate.ts](src/engine/modules/pixelate.ts) · static

Summary: Blows the picture up into big square pixels.

> Mosaic pixel grid with optional colour quantization.
>
> Each cell is filled with the colour at its centre. The grid is laid out
> in pixels, so cells keep their shape whatever the frame's aspect.
>
> Shapes: square cells; hexagons (pointy-top, Pixel Size across the
> flats); triangles, each square split along a diagonal that alternates
> cell to cell so they tile as a lattice; and dots, a disc per square cell
> on the Background colour.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `size` | Pixel Size | float | 1 … 64 (step 1) | 8 | ◇ |  |
| `shape` | Shape | enum | 0=Square, 1=Hex, 2=Triangle, 3=Dots | 0 (Square) | ◇ |  |
| `quantize` | Color Depth | int | 0 … 32 | 0 | ◇ |  |
| `background` | Background | color | RGB 0…1 | [0, 0, 0] | ◇ | active when `params.shape === 3` |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Posterize

id `posterize` · [posterize.ts](src/engine/modules/posterize.ts) · static

Summary: Reduces the picture to a few flat steps of colour.

> Quantisation to a fixed number of steps.
>
> Two modes, because they fail differently and both failures are useful:
> RGB quantises each channel independently and drifts the hue as it does
> (the banded, cheap-digital look), while Luma quantises brightness only
> and scales the colour back up, holding the hue intact.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `levels` | Levels | int | 2 … 32 | 6 | ◇ |  |
| `mode` | Mode | enum | 0=RGB, 1=Luma | 0 (RGB) | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Print

id `print` · [print.ts](src/engine/modules/print.ts) · static

Summary: Prints the picture on a press: separated into CMYK or spot inks, each screened into dots at its own angle, overprinted on paper.

> The picture printed on a press: separated into inks, each ink screened
> at its own angle, the plates overprinted on paper.
>
> Screening: each plate is a lattice of dots, Ruling cells down the
> frame's height (so preview and export match), turned to its ink's
> angle plus Rotate (CMYK: C 15°, M 75°, Y 0°, K 45°, which beat into a
> rosette). Dot Shape picks the spot function , every
> shape area-calibrated so 40% asked is 40% printed. Dot Gain grows dots
> by Gain × sin(π·area): most in the midtones, none on paper or solids.
> Misregistration shifts each plate, picture and screen together, by its
> own seeded offset in pixels. Below about 3 pixels a cell the screen
> fades to its average, so a small preview doesn't alias into moiré.
>
> The plates overprint on the paper multiplicatively, each ink's
> transmittance raised to Ink Density; Paper Grain adds paper fibre and
> tooth that the ink skips.
>
> How it works:
>
> Separation works in linear light against the paper. Layered ink films
> multiply, so in density (-log reflectance) they add, and the colour's
> density above the paper is solved per pixel as the inks' least-squares
> mix, so any spot colours work, out-of-gamut ones included. The solve
> knows the inks print as dots: a cell of ink at area a reflects
> 1 - a(1 - T) (Murray-Davies) and independent screens multiply
> (Demichel), so it runs box-constrained Gauss-Newton coordinate descent
> (eight sweeps, a small ridge) on each ink's density in the channel it
> absorbs most, from none to solid. CMYK first takes its black from the
> grey (GCR): (1 - the lightest channel) raised to a power Black sets
> (4 at 0: black only in the shadows; 1 at 1: every grey on black
> alone), then solves cyan, magenta and yellow for what is left, and
> keeps the total under 300%.
>
> The spot functions are in dotShapes.ts.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `inks` | Inks | enum | 0=CMYK Process, 1=Riso Pink + Blue, 2=Riso Pink, Yellow, Blue, 3=Riso Green + Purple, 4=Duotone Black + Orange, 5=Duotone Black + Blue, 6=Black Only, 7=Custom | 0 (CMYK Process) | ◇ | each built-in set shows its inks as a strip in the menu (`swatches`); angles per ink from the set; Custom prints the inks of section Custom Inks |
| `ruling` | Ruling | float | 8 … 300 (step 1) | 70 | ◇ | screen cells down the frame's height |
| `dotShape` | Dot Shape | enum | 0=Round, 1=Euclidean, 2=Ellipse, 3=Square, 4=Diamond, 5=Line | 0 (Round) | ◇ | area-calibrated (`dotShapes.ts`, shared with Halftone) |
| `dotGain` | Dot Gain | float | 0 … 0.4 (step 0.01) | 0.06 | ◇ | added as Gain × sin(π·area) |
| `misregister` | Misregistration | float | 0 … 20 (step 0.1) | 0 | ◇ | per-plate offset in source pixels, seeded; above 0 every plate is separated from its own shifted sample (4× the solve) |
| `paper` | Paper | color | RGB 0…1 | [0.97, 0.96, 0.93] | ◇ |  |
| `inkDensity` | Ink Density | float | 0 … 2 (step 0.01) | 1 | ◇ | section Press; ink transmittance raised to it |
| `black` | Black | float | 0 … 1 (step 0.01) | 0.5 | ◇ | section Press; black generation (GCR); active when `params.inks === CMYK` |
| `paperGrain` | Paper Grain | float | 0 … 1 (step 0.01) | 0.2 | ◇ | section Press |
| `inkCount` | Inks | int | 1 … 4 | 2 | ◇ | section Custom Inks; shown only for Custom |
| `ink1` | Ink 1 | color | RGB 0…1 | [0, 0.47, 0.75] | ◇ | section Custom Inks; shown for Custom; screened at 45° |
| `ink2` | Ink 2 | color | RGB 0…1 | [1, 0.28, 0.69] | ◇ | section Custom Inks; shown for Custom with 2+ inks; 75° |
| `ink3` | Ink 3 | color | RGB 0…1 | [1, 0.91, 0] | ◇ | section Custom Inks; shown for Custom with 3+ inks; 15° |
| `ink4` | Ink 4 | color | RGB 0…1 | [0.11, 0.11, 0.11] | ◇ | section Custom Inks; shown for Custom with 4 inks; 0° |
| `rotate` | Rotate (°) | float | -45 … 45 (step 0.5) | 0 | ◇ | section Advanced; added to every plate's angle |
| `variation` | Variation | int | 0 … 99 | 0 | ◇ | section Advanced; reseeds the misregistration |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Relight

id `relight` · [relight.ts](src/engine/modules/relight.ts) · static · extra picture inputs: `height` (Height)

Summary: Lights the picture like a surface in relief, with a light you move and a material you pick.

> The picture as a lit surface: its brightness read as height, and the
> relief that makes lit by a movable light as plastic, metal, clay or
> leather.
>
> Both fine detail and broad forms stand up; Smoothing sets the finer
> scale and Depth how far the relief goes. Invert Height pushes bright
> areas in instead of out. A picture wired into Height is read as the
> height instead, so a surface can be coloured by one picture and shaped
> by another -- a palette lit by the field it was mapped from.
>
> The light comes from Light Angle, raised Light Height above the surface.
> Each material answers it differently: metal has little diffuse, takes
> its highlight's colour from the surface, and reflects a soft room,
> brighter above; clay is matte with a fine tooth; leather has a pebbled
> grain pressed into it, and both are added to the surface before it is
> lit.
>
> Highlight Color tints the highlight of the materials that are not metal
> (metal's takes the surface's colour). Rim lights the surface where it
> turns away from the eye, the steep walls between flat tops, in its own
> colour -- a wet, glossy edge.
>
> The surface's colour is the picture's, or one Material Color, so the
> picture can become an embossed plate of a single metal.
>
> How it works:
>
> Height is the picture's luma; its slope is measured at two scales --
> Smoothing and three times that -- and averaged.
>
> The light is shaded the usual way: Lambert for the diffuse part and a
> normalised Blinn-Phong lobe for the highlight, whose tightness each
> material sets.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `material` | Material | enum | 0=Plastic, 1=Metal, 2=Clay, 3=Leather | 0 (Plastic) | ◇ |  |
| `depth` | Depth | float | 0 … 20 (step 0.1) | 4 | ◇ |  |
| `lightAngle` | Light Angle (°) | float | -180 … 180 (step 1) | 135 | ◇ |  |
| `lightHeight` | Light Height (°) | float | 5 … 90 (step 1) | 35 | ◇ |  |
| `specular` | Specular | float | 0 … 2 (step 0.01) | 1 | ◇ |  |
| `ambient` | Ambient | float | 0 … 1 (step 0.01) | 0.25 | ◇ |  |
| `colorSource` | Color Source | enum | 0=Picture, 1=Material Color | 0 (Picture) | ◇ | section Color |
| `materialColor` | Material Color | color | RGB 0…1 | [0.75, 0.55, 0.4] | ◇ | active when `params.colorSource === MATERIAL_COLOR`; section Color |
| `highlightColor` | Highlight Color | color | RGB 0…1 | [1, 1, 1] | ◇ | metal ignores it; section Color |
| `smoothing` | Smoothing | float | 0.5 … 8 (step 0.1) | 1.5 | ◇ | section Advanced |
| `invert` | Invert Height | bool | on / off | false | ◇ | section Advanced |
| `rim` | Rim | float | 0 … 2 (step 0.01) | 0 | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Risograph

id `risograph` · [risograph.ts](src/engine/modules/risograph.ts) · static

Summary: Prints the picture in two or three spot inks, grainy and slightly off register.

> The picture printed on a risograph: two or three spot inks, each laid
> by its own drum, so each is a little out of register, grainy, and
> unevenly inked.
>
> Any spot colours work, and the inks overprint into the colours between
> them the way transparent riso ink does: pink over blue is purple.
>
> Each ink is separated from its own, shifted and slightly turned copy
> of the picture -- Misregistration, the drift between drums -- and laid
> through a stochastic screen of Grain Size, as the master's thermal head
> makes one. Unevenness starves each drum differently: bands across the
> sheet where the drum ran low and blotches where it inked heavily.
>
> How it works:
>
> Separation works in absorbance, where layered inks add: the picture's
> darkness against the paper, -log(picture / paper), is solved per pixel as
> the least-squares mix of the inks' own absorbances (a small ridge keeps
> two inks of near-identical hue from blowing up).

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `inks` | Inks | enum | 0=2 Inks, 1=3 Inks | 0 (2 Inks) | ◇ |  |
| `ink1` | Ink 1 | color | RGB 0…1 | [1, 0.28, 0.55] | ◇ |  |
| `ink2` | Ink 2 | color | RGB 0…1 | [0, 0.47, 0.75] | ◇ |  |
| `ink3` | Ink 3 | color | RGB 0…1 | [1, 0.91, 0] | ◇ | active when `params.inks === THREE_INKS` |
| `density` | Density | float | 0 … 2 (step 0.01) | 1 | ◇ |  |
| `misregistration` | Misregistration | float | 0 … 20 (step 0.1) | 3 | ◇ |  |
| `grain` | Grain | float | 0 … 1 (step 0.01) | 0.6 | ◇ |  |
| `grainSize` | Grain Size | float | 1 … 6 (step 0.1) | 1.5 | ◇ | section Advanced |
| `unevenness` | Unevenness | float | 0 … 1 (step 0.01) | 0.35 | ◇ | section Advanced |
| `paperColor` | Paper Color | color | RGB 0…1 | [0.97, 0.95, 0.9] | ◇ | section Advanced |
| `variation` | Variation | int | 0 … 99 | 0 | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Scatter

id `scatter` · [scatter.ts](src/engine/modules/scatter.ts) · static · extra picture inputs: `sprite` (Sprite, read at its own size)

Summary: Covers the frame in copies of a shape, each sized, turned and coloured by the picture under it.

> Copies of a sprite laid over the frame, each sized, turned and coloured
> by the picture under it (TouchDesigner's instancing): dot portraits,
> glyph walls, confetti fields.
>
> The frame is cut into Columns cells across, as a grid or a hex grid
> (rows offset by half a cell), jittered by Jitter so the copies scatter.
> Each cell holds one copy, which reads the picture at its centre once: its
> brightness scales it (Size By) and turns it (Turn by Brightness), its
> colour tints it (Colour), and where the picture is transparent there is
> no copy. Random Size and Random Turn vary them by the module's seed.
>
> The sprite is the picture wired into Sprite, fitted into the copy's square
> box with its shape kept (a Shape, a Text, an Image), or a disc with
> nothing wired. Copies are laid over the Background in reading order, lower
> rows on top. Copies up to Size 2.5 fit.
>
> How it works:
>
> Each pixel looks at the cells within two of its own, so the cost is the
> same at any count.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `layout` | Layout | enum | 0=Grid, 1=Hex | 0 (Grid) | ◇ |  |
| `columns` | Columns | int | 2 … 200 | 40 | ◇ | copies across |
| `size` | Size | float | 0 … 2.5 (step 0.01) | 1 | ◇ | 1 fills the cell |
| `sizeBy` | Size By | enum | 0=Nothing, 1=Brightness, 2=Darkness | 1 (Brightness) | ◇ |  |
| `rotation` | Rotation (°) | float | -180 … 180 (step 1) | 0 | ◇ |  |
| `colorBy` | Colour | enum | 0=Picture, 1=Sprite, 2=Tint | 0 (Picture) | ◇ | the sprite times the picture's colour, as it is, or times Tint |
| `tint` | Tint | color | RGB 0…1 | [1, 1, 1] | ◇ | active with Colour Tint |
| `jitter` | Jitter | float | 0 … 1 (step 0.01) | 0 | ◇ | section Random; how far a copy strays from its cell's centre, in cells |
| `sizeJitter` | Random Size | float | 0 … 1 (step 0.01) | 0 | ◇ | section Random |
| `randomTurn` | Random Turn | float | 0 … 1 (step 0.01) | 0 | ◇ | section Random; up to half a turn either way |
| `turnBy` | Turn by Brightness (°) | float | -360 … 360 (step 1) | 0 | ◇ | section Advanced; added at full brightness |
| `background` | Background | enum | 0=Transparent, 1=Colour, 2=Picture | 1 (Colour) | ◇ | section Advanced |
| `backgroundColor` | Background Colour | color | RGB 0…1 | [0, 0, 0] | ◇ | section Advanced; active with Background Colour |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Slope

id `slope` · [slope.ts](src/engine/modules/slope.ts) · static

Summary: The picture's slope as a picture: red/green slope, a normal map, or its steepness.

> The picture's brightness read as height, and which way and how steeply
> it slopes at each pixel -- TouchDesigner's Slope TOP, and its Normal Map
> TOP as one of the outputs.
>
> The slope is the difference between the samples either side of the
> pixel, Distance apart, times Strength. Slope puts it out as a picture
> of its own: red the slope across (up to the right), green the slope up,
> both centred on the Zero Point (mid grey), so flat ground is (0.5, 0.5)
> -- what Remap's Red / Green Vector mode reads, for a displacement
> along the picture's own slope. Normal Map turns it into which way the
> surface faces, packed as normal maps are (flat is (0.5, 0.5, 1), Y up),
> for Remap's Normal Map mode or anything else lit from one.
> Magnitude is how steep it is, whichever way: black on the flat, white on
> the steepest -- the picture's edges, soft.
>
> Custom picks each of red, green, blue and alpha on its own, as
> TouchDesigner's Slope TOP does: the height's slope across or up, any
> channel's slope, the zero point, 0, 1, or the channel as it came in. It
> starts as Slope, so switching changes nothing until a channel is picked.
>
> Height is the picture's luma, or one of its channels: Red reads a loop
> that carries its height in red and something else -- a colour, a second
> field -- in green.
>
> Method is which samples the difference is taken between: either side
> (centred, the default), or the pixel and the one before or after it --
> sharper, half a pixel off centre. One-sided differences are doubled so
> Strength reads the same whichever is picked.
>
> Distance is in the picture's own pixels, so a preview and a file at full
> size slope alike; wider measures broader slopes and passes over grain.
> Separate Y measures up the picture over a distance of its own.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `output` | Output | enum | 0=Slope, 1=Normal Map, 2=Magnitude, 3=Custom | 0 (Slope) | ◇ |  |
| `red` | Red | enum | 0=Horizontal Slope, 1=Vertical Slope, 2=Magnitude, 3=Horizontal Red, 4=Vertical Red, 5=Horizontal Green, 6=Vertical Green, 7=Horizontal Blue, 8=Vertical Blue, 9=Horizontal Alpha, 10=Vertical Alpha, 11=Zero Point, 12=Zero, 13=One, 14=Input | 0 (Horizontal Slope) | ◇ | shown when `params.output === 3` |
| `green` | Green | enum | same as Red | 1 (Vertical Slope) | ◇ | shown when `params.output === 3` |
| `blue` | Blue | enum | same as Red | 11 (Zero Point) | ◇ | shown when `params.output === 3` |
| `alpha` | Alpha | enum | same as Red | 14 (Input) | ◇ | shown when `params.output === 3` |
| `strength` | Strength | float | 0 … 100 (step 0.1) | 10 | ◇ |  |
| `distance` | Distance | float | 0.5 … 16 (step 0.5) | 1 | ◇ | in source pixels |
| `method` | Method | enum | 0=Previous and Next, 1=Previous, 2=Next | 0 (Previous and Next) | ◇ | section Sampling |
| `separate` | Separate Y | bool | on / off | false | ◇ | section Sampling |
| `distanceY` | Distance Y | float | 0.5 … 16 (step 0.5) | 1 | ◇ | section Sampling; shown when `params.separate === true`; in source pixels |
| `channel` | Height From | enum | 0=Luma, 1=Red, 2=Green, 3=Blue, 4=Alpha | 0 (Luma) | ◇ | section Advanced |
| `zero` | Zero Point | float | 0 … 1 (step 0.01) | 0.5 | ◇ | section Advanced; active when Output is Slope or Custom |

### Optics & Blur

#### Anamorphic Streak

id `streak` · [streak.ts](src/engine/modules/streak.ts) · static · 4 passes

Summary: Stretches bright lights into long horizontal streaks, like an anamorphic lens.

> Anamorphic lens flare / horizontal streak.
>
> Simulates cylindrical anamorphic lens elements that stretch bright point
> highlights into cinematic horizontal flare streaks with characteristic blue tint.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `threshold` | Threshold | float | 0.3 … 1 (step 0.01) | 0.75 | ◇ |  |
| `length` | Length | float | 4 … 120 (step 1) | 45 | ◇ |  |
| `angle` | Angle | float | -30 … 30 (step 0.5) | 0 | ◇ |  |
| `intensity` | Intensity | float | 0 … 3 (step 0.01) | 1.2 | ◇ |  |
| `tint` | Tint | color | RGB 0…1 | [0.2, 0.6, 1] | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Aura

id `aura` · [aura.ts](src/engine/modules/aura.ts) · animated when `params.speed !== 0 && (params.turbulence !== 0 || params.flicker !== 0)` · 4 passes · extra picture inputs: `matte` (Matte)

Summary: Puts a shimmering glow round a shape: a cut-out, or a matte wired in.

> A glow that rises off a shape and shimmers: the haze round someone
> possessed, a hero's energy, a ghost.
>
> The shape is the Matte input's brightness where one is wired (Cut Out's
> Matte, Text Mask, any picture white where the subject is), otherwise the
> picture's own transparency -- so after a Cut Out it is the cut-out. With
> neither, an opaque picture has no edge to glow from.
>
> The glow goes outside the shape; Inner Rim adds it a little way in from
> the edge too. Flicker breathes the whole thing. Round a cut-out it also
> fills the transparency, so the aura survives a Layers module over another
> background.
>
> How it works:
>
> Four passes, as Bloom: the shape, blurred across, blurred down, then the
> combine reads the blurred shape through a drifting noise warp, so the glow
> licks and climbs rather than sitting as a soft outline.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `color` | Color | color | RGB 0…1 | [1, 0.08, 0.04] | ◇ |  |
| `radius` | Radius | float | 0 … 64 (step 0.5) | 18 | ◇ | pixels |
| `intensity` | Intensity | float | 0 … 4 (step 0.01) | 1.5 | ◇ |  |
| `rim` | Inner Rim | float | 0 … 1 (step 0.01) | 0.3 | ◇ |  |
| `turbulence` | Turbulence | float | 0 … 1 (step 0.01) | 0.4 | ◇ |  |
| `flicker` | Flicker | float | 0 … 1 (step 0.01) | 0.3 | ◇ |  |
| `speed` | Speed | float | 0 … 4 (step 0.05) | 1 | ○ | phased: integrated over time, single value only |

#### Bloom

id `bloom` · [bloom.ts](src/engine/modules/bloom.ts) · static · 4 passes

Summary: Makes the bright parts glow.

> Phosphor glow: isolate what is bright, blur it, add it back.
>
> The threshold has a soft knee rather than a hard cut. A hard one makes
> the glow pop into existence along a contour as the slider moves, and that
> contour is visible in the result.
>
> How it works:
>
> Four passes -- threshold, blur across, blur down, combine -- and the
> combine is the one that needs `u_orig`. By then `u_src` holds nothing but
> the blurred highlights; the picture they have to be added back onto is
> long gone from the ping-pong, which is exactly what the hold buffer is
> there for.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `threshold` | Threshold | float | 0 … 1 (step 0.01) | 0.6 | ◇ |  |
| `knee` | Knee | float | 0.001 … 0.5 (step 0.005) | 0.15 | ◇ |  |
| `radius` | Radius | float | 0 … 64 (step 0.5) | 16 | ◇ |  |
| `intensity` | Intensity | float | 0 … 3 (step 0.01) | 0.8 | ◇ |  |

#### Blur

id `blur` · [blur.ts](src/engine/modules/blur.ts) · static · 4 passes

Summary: Softens the picture with an even blur, as TouchDesigner's Blur TOP: kernel type, edges, pre-shrink for wide blurs.

> Blur, laid out as TouchDesigner's Blur TOP, under its names and in its
> order.
>
> Pre-Shrink halves the picture that many times before blurring and scales
> the blur back up after, as TouchDesigner does: Filter Size counts shrunk
> pixels, so each step doubles the reach for the same taps.
>
> It shapes the passes, so nothing can drive it.
>
> Filter Size is the reach either side (the key stays `radius`, so old
> documents keep their blur). Sample Step is how far apart the taps are, in
> shrunk pixels, along each pass: 1 takes every pixel (up to 128 either
> side), more is cheaper and coarser. Type is the kernel's shape:
> Catmull-Rom and Mitchell dip below zero at their edges, so they blur with
> a little sharpening. Extend is what lies off the frame. Rotate Kernel
> turns both directions. Dither adds a trace of noise to break up banding.
>
> How it works:
>
> It is separated into a horizontal and a vertical pass, since a 2D kernel
> that is the product of two 1D ones costs two rows of taps, not a square.
>
> The shrunk picture is kept in the corner of the pass targets, so the blur
> passes only work on that corner; the last pass reads it back, filtered, at
> full size. At 0 the first and last passes are plain copies.
>
> A picture wired into another setting is read where each shrunk pixel lies
> in the frame (`EffectDef.fieldUv`).

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `method` | Method | enum | 0=Horizontal and Vertical, 1=Horizontal, 2=Vertical | 0 (Horizontal and Vertical) | ◇ | one direction alone smears along it |
| `radius` | Filter Size | float | 0 … 64 (step 0.5) | 6 | ◇ | reach either side, in shrunk pixels |
| `kernel` | Type | enum | 0=Gaussian, 1=Box, 2=Bartlett, 3=Catmull-Rom, 4=Mitchell, 5=B-Spline | 0 (Gaussian) | ◇ | the kernel's shape |
| `rotate` | Rotate Kernel | float | -180 … 180 (step 1) | 0 | ◇ | degrees; turns both directions; section Advanced |
| `extend` | Extend | enum | 0=Hold, 1=Zero, 2=Repeat, 3=Mirror | 0 (Hold) | ◇ | what lies off the frame; Zero darkens and clears the edges; section Advanced |
| `preShrink` | Pre-Shrink | int | 0 … 6 | 0 | none | halves the picture this many times before blurring: each step doubles the reach and keeps the cost; section Advanced |
| `sampleStep` | Sample Step | vec2 | 0.25 … 16 (step 0.05) | [1, 1] | ◇ | tap spacing along each pass, in shrunk pixels; section Advanced |
| `dither` | Dither | bool | on / off | false | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Bokeh

id `bokeh` · [bokeh.ts](src/engine/modules/bokeh.ts) · static

Summary: Blurs like a real lens, with bright points turning into discs or polygons.

> Lens blur: out of focus the way a lens is, where a bright point spreads
> into the shape of the aperture -- a disc, or the polygon of its blades --
> instead of a soft Gaussian smudge.
>
> A plain average lets a bright point be swamped by its dark surroundings.
> Highlight Boost weighs bright points more, so lights come out as crisp,
> bright shapes -- the look the module is for.
>
> How it works:
>
> The taps lie on a golden-angle spiral, which covers a disc evenly with no
> rings or spokes for the eye to catch. For a polygon each tap is pushed
> out to where the polygon's edge is at its angle, so the same taps fill
> a hexagon or an octagon instead. One pass of a fixed tap count: the
> radius spreads them out, it never adds to the cost.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `radius` | Radius | float | 0 … 48 (step 0.5) | 10 | ◇ |  |
| `shape` | Shape | enum | 0=Disc, 1=Hexagon, 2=Octagon | 0 (Disc) | ◇ |  |
| `rotation` | Rotation (°) | float | 0 … 90 (step 1) | 0 | ◇ | active when `params.shape !== 0` |
| `boost` | Highlight Boost | float | 0 … 4 (step 0.01) | 1.5 | ◇ |  |
| `threshold` | Threshold | float | 0 … 1 (step 0.01) | 0.6 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Caustics

id `caustics` · [caustics.ts](src/engine/modules/caustics.ts) · animated when `params.speed !== 0 && params.surface !== HEIGHT_MAP` · extra picture inputs: `heightMap` (Height Map, active when `params.surface === HEIGHT_MAP`)

Summary: Puts the picture under moving water, with dancing light patterns on top.

> The picture under moving water: the swimming web of light that sunlight
> focuses on the bottom of a pool, and the wobble of seeing through the
> surface.
>
> Focus is the depth of the water: shallow, the light barely gathers;
> deeper, the folds form and then cross into a finer net. Sharpness caps
> how bright a fold can get. Dispersion gives red and blue their own
> depth, fringing the lines with colour, and Distortion moves the picture
> itself by the same slopes. Speed is phased.
>
> Surface Height Map swaps the waves for the brightness of the picture on
> the Height Map input: light through a piece of glass in that shape -- a
> word, a Shape, a video -- casting its caustics. Map Softness (in pixels)
> sets how smooth the light is, wider for smoother, and Map Relief is how
> far white stands proud of black. With nothing wired in,
> the waves stay.
>
> How it works:
>
> The surface is eight waves in scattered directions, each a little
> shorter than the last, travelling at the speed deep water gives its
> wavelength (the square root of the wavenumber), so the pattern churns
> rather than sliding. Light through it is bent by the surface's slope; a
> patch of floor is lit by how much the bending squeezes the light onto
> it, one over the determinant of the map's Jacobian. Where neighbouring
> rays cross, that determinant passes through zero and the light piles up
> into the bright folds that are caustics. Slopes and curvature come from
> the waves analytically, so the lines are crisp at any size.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `surface` | Surface | enum | 0=Waves, 1=Height Map | 0 (Waves) | ◇ |  |
| `scale` | Scale | float | 0.05 … 2 (step 0.01) | 0.5 | ◇ | active when `params.surface !== HEIGHT_MAP` |
| `speed` | Speed | float | 0 … 3 (step 0.01) | 0.5 | ○ | phased: integrated over time, single value only; active when `params.surface !== HEIGHT_MAP` |
| `mapSoftness` | Map Softness | float | 1 … 16 (step 0.1) | 4 | ◇ | active when `params.surface === HEIGHT_MAP` |
| `relief` | Map Relief | float | 0 … 4 (step 0.01) | 1 | ◇ | active when `params.surface === HEIGHT_MAP` |
| `focus` | Focus | float | 0 … 3 (step 0.01) | 1.2 | ◇ |  |
| `intensity` | Intensity | float | 0 … 2 (step 0.01) | 1 | ◇ |  |
| `lightColor` | Light Color | color | RGB 0…1 | [1, 0.97, 0.88] | ◇ | section Colour |
| `tint` | Water Tint | color | RGB 0…1 | [0.55, 0.85, 0.9] | ◇ | section Colour |
| `tintAmount` | Tint Amount | float | 0 … 1 (step 0.01) | 0.25 | ◇ | section Colour |
| `sharpness` | Sharpness | float | 0 … 1 (step 0.01) | 0.6 | ◇ | section Advanced |
| `dispersion` | Dispersion | float | 0 … 0.5 (step 0.005) | 0.08 | ◇ | section Advanced |
| `distortion` | Distortion | float | 0 … 0.05 (step 0.0005) | 0.008 | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Chromatic Aberration

id `chromaticAberration` · [chromaticAberration.ts](src/engine/modules/chromaticAberration.ts) · static

Summary: Splits red and blue apart at the edges, like a cheap lens.

> Red and blue pulled apart, green left where it is.
>
> Two kinds at once because real optics and real signals do both. Radial
> grows with distance from the centre and vanishes in the middle, which is
> what a lens does. Lateral is a flat sideways shift across the whole frame,
> which is what a badly timed signal does.
>
> Green stays put in both: the eye reads detail mostly from green, so
> splitting the outer two around it keeps the picture legible while the
> fringing still shows.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `radial` | Radial | float | -0.1 … 0.1 (step 0.001) | 0.008 | ◇ |  |
| `lateral` | Lateral | float | -16 … 16 (step 0.5) | 0 | ◇ |  |
| `center` | Center | vec2 | x,y ∈ 0 … 1 | [0.5, 0.5] | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Crystal Ball

id `crystalBall` · [crystalBall.ts](src/engine/modules/crystalBall.ts) · static

Summary: Shows the picture through a glass sphere, flipped and wrapped around it.

> A glass sphere in front of the picture -- a crystal ball, a marble, a
> drop of water -- with the picture seen through it upside down and
> wrapped, as a real one shows the world. A ball is a strong lens, so past
> its focus the picture comes back inverted and squeezed into a fisheye
> toward the rim. Backdrop Distance, in radii, is how far behind the ball
> the picture lies. Dispersion gives each colour its own bend, fringing
> the rim with colour.
>
> Light that does not go in is reflected: little face on, nearly all at
> the rim, which darkens the edge into the ring every glass sphere has.
> The reflection shows a soft room, brighter above, and a sharp highlight
> from Light Angle.
>
> Behind the ball, its shadow falls on the backdrop away from the light,
> with the bright spot of light the ball focuses at its heart -- a glass
> sphere's caustic.
>
> How it works:
>
> The sphere is traced, not warped. A ray from the eye meets the front of
> the sphere and is bent in by Snell's law; it crosses the glass, meets
> the back, and is bent out again -- or, too steep to leave, totally
> internally reflected -- and runs on to the picture, Backdrop Distance
> radii behind. The inverted fisheye comes out of that without being
> written in anywhere.
>
> Dispersion gives each colour its own index. How much light is reflected
> is a Fresnel term.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `center` | Center | vec2 | x,y ∈ -0.5 … 1.5 | [0.5, 0.5] | ◇ |  |
| `radius` | Radius | float | 0.02 … 1 (step 0.005) | 0.3 | ◇ |  |
| `ior` | Refractive Index | float | 1 … 2.4 (step 0.01) | 1.5 | ◇ |  |
| `distance` | Backdrop Distance | float | 0 … 10 (step 0.05) | 2 | ◇ |  |
| `dispersion` | Dispersion | float | 0 … 0.1 (step 0.001) | 0.02 | ◇ |  |
| `reflection` | Reflections | float | 0 … 1 (step 0.01) | 0.5 | ◇ | section Light |
| `lightAngle` | Light Angle (°) | float | -180 … 180 (step 1) | 135 | ◇ | section Light |
| `shadow` | Shadow | float | 0 … 1 (step 0.01) | 0.4 | ◇ | section Light |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Diffraction Spikes

id `diffractionSpikes` · [diffractionSpikes.ts](src/engine/modules/diffractionSpikes.ts) · static · 2 passes

Summary: Adds star-shaped spikes to bright lights, as a camera aperture does.

> The star a bright light gets from a camera's aperture: thin spikes of
> light diffracted off the straight edges of its blades.
>
> Each blade edge throws a spike out both ways, perpendicular to it. With
> an even count, opposite blades are parallel and share their spikes, so
> six blades make six spikes; with an odd count none line up and seven
> blades make fourteen -- which is why the count shows on a photo. A
> star or cross-screen filter is the same thing with two or three
> blades' worth of lines.
>
> Diffraction spreads each wavelength by its own angle, longer waves
> further, so a spike is white at its root and fringes into colour toward
> its tip, red reaching out past blue; Dispersion is how far apart they
> spread.
>
> How it works:
>
> Two passes. The first keeps only what is above Threshold, softened a
> little, so even a small light is wide enough to be found. The second
> walks out along every spike from each pixel, taps packed close to the
> root and spreading out along the length, nudged per pixel so they never
> leave the spike dotted, and adds what it gathers to the picture.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `blades` | Blades | int | 2 … 8 | 6 | ◇ |  |
| `rotation` | Rotation (°) | float | -180 … 180 (step 1) | 15 | ◇ |  |
| `length` | Length | float | 0 … 0.5 (step 0.001) | 0.15 | ◇ |  |
| `threshold` | Threshold | float | 0 … 1 (step 0.01) | 0.8 | ◇ |  |
| `intensity` | Intensity | float | 0 … 4 (step 0.01) | 1 | ◇ |  |
| `dispersion` | Dispersion | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Denoise

id `denoise` · [denoise.ts](src/engine/modules/denoise.ts) · static

Summary: Removes grain and noise while keeping edges sharp.

> Edge-preserving denoise: a bilateral filter over a disc. Every pixel
> averages its neighbours within Radius, each weighted by its distance and
> by how close its colour is to this pixel's (read as the mean of its 3 × 3,
> so its own grain doesn't count); Strength widens that colour tolerance.
> Across an edge the far side counts for almost nothing, so edges stay; on a
> flat stretch the grain averages away.
>
> Radius is in source pixels; Keep Detail mixes the original back in.
>
> How it works:
>
> The 64 taps lie on a golden-angle spiral turned per pixel, so no direction
> is favoured (the guided filter it replaces haloed along the axes).

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `strength` | Strength | float | 0 … 1 (step 0.01) | 0.35 | ◇ | colour tolerance: 0.02 + 0.2 × Strength |
| `radius` | Radius | float | 1 … 16 (step 0.5) | 4 | ◇ | source pixels |
| `detail` | Keep Detail | float | 0 … 1 (step 0.01) | 0 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Directional Blur

id `directionalBlur` · [directionalBlur.ts](src/engine/modules/directionalBlur.ts) · static

Summary: Smears the picture along one direction, like motion blur.

> A smear along one angle -- motion blur, or the horizontal drag of a
> signal that cannot keep up with itself.
>
> Trail is the difference between motion blur and a smear. Centred, the
> samples sit either side of the pixel with a Gaussian falloff and the
> picture stays where it is. Trailing, they only reach backwards with a
> linear decay, so the image keeps its leading edge sharp and drags a tail
> -- which is the half that reads as tape.
>
> How it works:
>
> Three passes keep a long smear smooth: a small tent, a fine comb weighted
> as a tent 16 times wider, then a comb of 33 taps at the falloff's
> weights, so the overlapping tents leave no gaps and no stacked copies at
> any length.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `length` | Length | float | 0 … 1024 (step 0.5) | 12 | ◇ |  |
| `angle` | Angle | float | -0.5 … 0.5 (step 0.005) | 0 | ◇ |  |
| `trail` | Trail | bool | on / off | false | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Dirty Lens

id `dirtyLens` · [dirtyLens.ts](src/engine/modules/dirtyLens.ts) · static

Summary: Adds smudges, fingerprints and dust that light up around bright lights.

> A lens that has not been cleaned: smudges, wipe marks, fingerprints and
> dust that are invisible until a bright light sits behind them, and then
> light up.
>
> That is how lens dirt works. It is far out of focus, so it never shows
> as dirt; it scatters stray light from the bright parts of the scene
> across the frame. So the module first gathers the light the lens would
> scatter: every bright part of the picture, above Threshold, spread over
> Glow Spread by a golden-angle spiral of taps. The dirt is lit by that
> gathered light and added to the picture -- a dark scene shows a clean
> lens, and a light moving through the frame drags the smudges into view
> behind it.
>
> The dirt is drawn in frame heights, so it stays put as the picture
> changes: greasy smudges and the long marks of a wipe from fractal
> noise, fingerprints as rings of ridges in an oval, partly lifted, and
> dust as out-of-focus discs, bright at the rim as defocused specks are.
> A faint veil of the gathered light lifts the whole frame, as a dirty
> lens loses contrast.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `intensity` | Intensity | float | 0 … 3 (step 0.01) | 1 | ◇ |  |
| `threshold` | Threshold | float | 0 … 1 (step 0.01) | 0.6 | ◇ |  |
| `spread` | Glow Spread | float | 0.02 … 0.5 (step 0.005) | 0.15 | ◇ |  |
| `smudges` | Smudges | float | 0 … 1 (step 0.01) | 0.6 | ◇ |  |
| `fingerprints` | Fingerprints | float | 0 … 1 (step 0.01) | 0.3 | ◇ |  |
| `dust` | Dust | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `dirtScale` | Dirt Scale | float | 0.25 … 4 (step 0.01) | 1 | ◇ | section Advanced |
| `tint` | Tint | color | RGB 0…1 | [1, 0.95, 0.88] | ◇ | section Advanced |
| `variation` | Variation | int | 0 … 99 | 0 | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Glass

id `glass` · [glass.ts](src/engine/modules/glass.ts) · animated when `typeof params.speed === "number" && params.speed !== 0 && params.surface !== SMOOTH` · extra picture inputs: `heightMap` (Height Map, active when Surface is Height Map)

Summary: Shows the picture through a pane of textured glass: fluted, reeded, antique, ice and more.

> The picture seen through a pane of textured glass. Each rib or block
> works as a real little lens: with enough Distance it flips the slice of
> the picture behind it, as fluted glass does.
>
> The surfaces, as the menu groups them:
>
> - Panes: a smooth pane; antique, the long wavy cords of old window
>   glass; ice / crackle, a clear sheet crazed into facets, each on its
>   own tilt and domed with Relief, between thin cracks.
> - Ribbed: fluted ribs; prism ribs, two faces to a rib, so each strip
>   shows a shifted slice, bent more as Relief bows the faces; concave
>   flutes, hollow grooves that spread and shrink each strip; wavy reeds,
>   ribs snaking from side to side as they run; sunburst, ribs radiating
>   from the centre.
> - Tiled: glass blocks; hammered dimples; pyramids, four faces to a
>   tile, bowing with Relief, each tile splitting the picture into four;
>   honeycomb, a hexagonal cushion per cell.
> - Lenses: a Fresnel lens, one big magnifier folded flat into rings of
>   Size, Relief its power, each ring ending in a steep groove that takes
>   up Groove Width of it; fly's eye, a round lenslet in every hexagonal
>   cell, each holding its own small upside-down picture; bullseye, a
>   disc of crown glass in every cell, a thick lump ringed by ripples.
> - Water: rippled waves; concentric rings, ripples spreading from a
>   point and fading as a drop's do.
> - Custom: the brightness of a picture on the Height Map input.
>
> Center places the round surfaces -- the Fresnel lens, concentric rings
> and the sunburst. Flow sets a surface moving: a straight one drifts
> across, a cell a second at 1, rings spread outward and the sunburst
> turns. Flow is phased, so changing it never jumps.
>
> Frost is the roughness of the face, the fine grain of etched glass
> rather than a smooth blur. As with real frosted glass, the blur grows
> with Distance, and a picture pressed against the glass stays sharp.
> Dispersion lets red, green and blue bend by different amounts, so edges
> split into colour the way they do through a prism.
>
> Light that is not refracted is reflected: a dim room and a key light
> from Light Angle, which rakes the ribs and dimples, are mixed in. Tint
> is the glass's own colour, deeper where the glass is thicker, so the
> middle of a rib is a shade deeper than its edges.
>
> How it works:
>
> The glass is traced rather than faked: each pixel's view ray is bent by
> Snell's law into the glass at its textured face, out again at its flat
> back, and carried across the gap to the picture. Rays too steep to leave
> the back are totally internally reflected.
>
> Slopes are worked out analytically wherever a surface allows, not by
> differencing, so the creases stay crisp.
>
> Frost: each tap tilts the normal at random on a golden-angle spiral,
> turned per pixel, so the scatter reads as grain instead of a smooth
> blur. Dispersion gives red, green and blue their own index. The
> reflected share is a Fresnel term, from the index. Tint is absorbed in
> proportion to how thick the glass is under each pixel (Beer-Lambert).

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `surface` | Surface | enum | 0=Smooth Pane, 1=Fluted, 2=Glass Blocks, 3=Hammered, 4=Rippled, 5=Height Map, 6=Fresnel Lens, 7=Prism Ribs, 8=Concave Flutes, 9=Wavy Reeds, 10=Pyramids, 11=Honeycomb, 12=Fly's Eye, 13=Bullseye, 14=Antique, 15=Ice / Crackle, 16=Concentric Rings, 17=Sunburst | 1 (Fluted) | ◇ | menu headings: Panes (0, 14, 15), Ribbed (1, 7, 8, 9, 17), Tiled (2, 3, 10, 11), Lenses (6, 12, 13), Water (4, 16), Custom (5) |
| `size` | Size | float | 0.005 … 0.5 (step 0.001) | 0.06 | ◇ | active when `params.surface !== SMOOTH` |
| `angle` | Rotation (°) | float | -180 … 180 (step 1) | 0 | ◇ | active when Surface is not Smooth Pane, Height Map, Fresnel Lens or Concentric Rings |
| `center` | Center | vec2 | x,y ∈ -0.5 … 1.5 | [0.5, 0.5] | ◇ | active when Surface is Fresnel Lens, Concentric Rings or Sunburst |
| `relief` | Relief | float | 0 … 1 (step 0.01) | 0.5 | ◇ | active when `params.surface !== SMOOTH` |
| `frost` | Frost | float | 0 … 1 (step 0.01) | 0.1 | ◇ |  |
| `speed` | Flow | float | -2 … 2 (step 0.01) | 0 | ○ | phased: integrated over time, single value only; active when `params.surface !== SMOOTH && params.surface !== HEIGHT_MAP` |
| `distance` | Distance | float | 0 … 0.5 (step 0.001) | 0.05 | ◇ | section Optics |
| `ior` | Refractive Index | float | 1 … 2.4 (step 0.01) | 1.5 | ◇ | section Optics |
| `dispersion` | Dispersion | float | 0 … 0.2 (step 0.001) | 0.015 | ◇ | section Optics |
| `absorption` | Absorption | float | 0 … 2 (step 0.01) | 0.3 | ◇ | section Optics |
| `tint` | Tint | color | RGB 0…1 | [0.86, 0.95, 0.93] | ◇ | section Optics |
| `reflection` | Reflections | float | 0 … 1 (step 0.01) | 0.5 | ◇ | section Optics |
| `lightAngle` | Light Angle (°) | float | -180 … 180 (step 1) | 135 | ◇ | section Optics |
| `grooveWidth` | Groove Width | float | 0.02 … 1 (step 0.01) | 0.15 | ◇ | active when `params.surface === FRESNEL_LENS`; section Advanced |
| `edge` | Edge | enum | 0=Clamp, 1=Wrap, 2=Black, 3=Mirror | 3 (Mirror) | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### God Rays

id `godRays` · [godRays.ts](src/engine/modules/godRays.ts) · static · 3 passes

Summary: Casts rays of light from the bright parts, like sun through mist.

> Light shafts: the bright parts of the picture smeared out along lines
> that run to a light, as sun through mist or a window into a dusty room.
>
> How it works:
>
> Three passes, after Bloom: keep what is bright (with the same soft knee),
> march each pixel a fixed number of steps toward the light summing what
> it passes with each step weighing Decay times the last, then add the
> result back onto the picture. The step count is fixed and Length scales
> the stride, so a long ray costs the same as a short one.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `threshold` | Threshold | float | 0 … 1 (step 0.01) | 0.7 | ◇ |  |
| `knee` | Knee | float | 0.001 … 0.5 (step 0.005) | 0.15 | ◇ |  |
| `light` | Light | vec2 | x,y ∈ -0.5 … 1.5 | [0.5, 0.75] | ◇ |  |
| `length` | Length | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `decay` | Decay | float | 0.8 … 1 (step 0.001) | 0.96 | ◇ |  |
| `intensity` | Intensity | float | 0 … 4 (step 0.01) | 1.2 | ◇ |  |
| `tint` | Tint | color | RGB 0…1 | [1, 0.92, 0.75] | ◇ |  |

#### Halation

id `halation` · [halation.ts](src/engine/modules/halation.ts) · static · 4 passes

Summary: Adds the red glow film gets around bright highlights.

> 35mm motion picture film halation (Kodak Vision3 emulsion glow).
>
> Bright highlights scatter through the film base and reflect off the
> anti-halation backing, creating a warm, red-orange bloom around specular
> edges and high-contrast silhouettes.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `threshold` | Threshold | float | 0.2 … 1 (step 0.01) | 0.65 | ◇ |  |
| `knee` | Knee | float | 0.001 … 0.5 (step 0.005) | 0.15 | ◇ |  |
| `radius` | Radius | float | 1 … 48 (step 0.5) | 14 | ◇ |  |
| `intensity` | Intensity | float | 0 … 2.5 (step 0.01) | 0.9 | ◇ |  |
| `tint` | Tint | color | RGB 0…1 | [1, 0.22, 0.06] | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Lens

id `lens` · [lens.ts](src/engine/modules/lens.ts) · static

Summary: A gentle bulge or pinch, like a CRT tube's curve.

> Radial lens distortion -- the glass bulge of a CRT tube, or a fisheye.
>
> Curvature is bipolar: positive magnifies the centre and pushes content
> off the edges (barrel, what a tube face does), negative pulls it in
> (pincushion). Zoom is the companion knob, because barrel distortion
> leaves the corners sampling from outside the image and zooming back in
> is how you crop that away rather than living with a smeared border.
>
> There is no Mix: crossfading a warped image against its unwarped self is
> a double exposure, not a weaker warp. Curvature already is the strength.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `curvature` | Curvature | float | -1 … 1 (step 0.01) | 0.2 | ◇ |  |
| `zoom` | Zoom | float | 0.5 … 2 (step 0.01) | 1 | ◇ |  |
| `edge` | Edge | enum | 0=Clamp, 1=Wrap, 2=Black, 3=Mirror, 4=Color | 2 (Black) | ◇ |  |
| `background` | Background | color | RGB 0…1 | [0, 0, 0] | ◇ | active when `params.edge === 4` |

#### Lens Flare

id `lensFlare` · [lensFlare.ts](src/engine/modules/lensFlare.ts) · static · 5 passes

Summary: Adds lens flare ghosts and halos around the picture's own bright spots.

> Lens flare made from the picture's own highlights, so it works on any
> footage with nothing to place by hand: every bright spot throws ghosts
> across the frame and a halo around it, as light bouncing between lens
> elements does.
>
> How it works:
>
> After John Chapman's pseudo lens flare. A real lens images each ghost of
> a light on the line through the frame's centre, on the far side -- so
> the highlights are mirrored through the centre and sampled at steps of
> Spacing back along that line, each step a ghost. The halo is the same
> picture sampled a fixed distance out along the line instead, which turns
> a spot near the centre into a ring. Dispersion reads red and blue a
> little either side of green along the line, for the coloured fringes a
> flare always has. Ghosts fade toward the frame's edge so they never end
> at a hard line, then the whole flare is blurred and added on.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `threshold` | Threshold | float | 0 … 1 (step 0.01) | 0.75 | ◇ |  |
| `knee` | Knee | float | 0.001 … 0.5 (step 0.005) | 0.1 | ◇ |  |
| `ghosts` | Ghosts | int | 1 … 8 | 4 | ◇ |  |
| `spacing` | Spacing | float | 0.05 … 0.8 (step 0.01) | 0.35 | ◇ |  |
| `halo` | Halo | float | 0 … 0.8 (step 0.01) | 0.4 | ◇ |  |
| `dispersion` | Dispersion | float | 0 … 30 (step 0.5) | 6 | ◇ |  |
| `blur` | Blur | float | 0 … 32 (step 0.5) | 6 | ◇ |  |
| `intensity` | Intensity | float | 0 … 4 (step 0.01) | 1 | ◇ |  |

#### Lenticular

id `lenticular` · [lenticular.ts](src/engine/modules/lenticular.ts) · animated when `params.speed !== 0 && params.sway !== 0` · extra picture inputs: `pictureB` (Picture B)

Summary: Makes a 3D postcard: two pictures in ridged strips that swap as the angle changes.

> A lenticular print, the ridged plastic of a 3D postcard: two pictures
> printed in interleaved strips under a sheet of cylindrical lenses, so
> which one you see depends on the angle you look from.
>
> Each lens covers one strip of each picture and magnifies the strip the
> eye is lined up with. So the picture is sampled once per lens across
> it -- the coarse vertical banding every lenticular print has -- and the
> view angle, plus where across its lens a pixel sits, says which strip
> that is. Tilt past the middle and the flip runs across each lens, not
> all at once; Ghosting is the crosstalk that lets a little of the other
> picture through, which real prints never quite lose.
>
> The lenses themselves catch the light: a sheen sliding across each rib
> as the view turns, and the faint dark line where two ribs meet. Sway
> rocks the view back and forth as a hand tilting the card does, on
> Speed's phase.
>
> With nothing on Picture B, both strips show the main picture, which
> leaves the ribs and their sheen.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `pitch` | Lens Pitch | float | 2 … 40 (step 0.5) | 8 | ◇ |  |
| `direction` | Lens Direction | enum | 0=Vertical, 1=Horizontal | 0 (Vertical) | ◇ |  |
| `view` | View Angle | float | -1 … 1 (step 0.01) | 0 | ◇ |  |
| `sway` | Sway | float | 0 … 1 (step 0.01) | 0.8 | ◇ |  |
| `speed` | Sway Speed | float | 0 … 2 (step 0.01) | 0.25 | ○ | phased: integrated over time, single value only |
| `ghosting` | Ghosting | float | 0 … 0.5 (step 0.005) | 0.15 | ◇ |  |
| `sheen` | Sheen | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Optic Compensation

id `opticCompensation` · [opticCompensation.ts](src/engine/modules/opticCompensation.ts) · static · with Reverse and Resize on, sets a bigger frame for everything downstream

Summary: Bends the picture as a lens of a given field of view would, or flattens a fisheye, like After Effects' Optic Compensation.

> After Effects' Optic Compensation: the picture treated as shot through a
> lens of a given field of view.
>
> Field of View is the angle the picture spans along Orientation's axis
> (its width, height or diagonal). Forward, a flat (rectilinear) picture is
> bent into an equidistant fisheye of that angle: the middle swells and
> the edges crowd in, and past 90 degrees off axis nothing is left (the
> corners go transparent at wide angles). Reverse Lens Distortion does the
> opposite, flattening a fisheye: the middle shrinks and the edges stretch
> out, as far as the angle lets them. Either way the edge on the chosen axis
> stays put, so 0 degrees changes nothing.
>
> View Center is the lens's optical centre; Zoom magnifies about it (not
> in After Effects, which leaves that to the layer's scale). Edge says what
> fills where the lens looks past the picture: Black (transparent, as in
> After Effects), Clamp, Wrap, Mirror or a Color. Past 90 degrees there is
> nothing to repeat, so only Color fills that.
>
> Dispersion (not in After Effects) splits the colours as a real lens
> does at its edges: each wavelength magnified a little differently, summed
> over the spectrum into rainbow fringes that grow away from the centre.
> There is no refractive index: Field of View already is how hard the lens
> bends.
>
> Resize, with Reverse on, makes the frame bigger so the stretched corners
> stay in it rather than being cut off at the input's edges: by as much as
> they need, up to 2x, 4x, or without limit (held at 8x).
>
> How it works:
>
> The frame is worked out from the settings as set; the shader reads the
> size it got, so a wired Field of View still lands right, cropped to that
> frame.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `fov` | Field of View | float | 0 … 180 (step 0.1) | 0 | ◇ | degrees along FOV Orientation; a new one starts at 60 |
| `center` | View Center | vec2 | x,y ∈ -0.5 … 1.5 | [0.5, 0.5] | ◇ | a point on the preview |
| `zoom` | Zoom | float | 0.5 … 2 (step 0.01) | 1 | ◇ | over 1 crops the edges, under 1 shows past them |
| `reverse` | Reverse Lens Distortion | bool | on / off | false | none |  |
| `resize` | Resize | enum | 0=Off, 1=Max 2X, 2=Max 4X, 3=Unlimited | 0 (Off) | none | active when `params.reverse === true`; Unlimited is held at 8x |
| `dispersion` | Dispersion | float | 0 … 0.2 (step 0.001) | 0 | ◇ | spread of magnification across the spectrum; as many taps as the fringe is pixels wide (3 to 32), jittered per pixel |
| `orientation` | FOV Orientation | enum | 0=Horizontal, 1=Vertical, 2=Diagonal | 0 (Horizontal) | none | section Advanced |
| `edge` | Edge | enum | 0=Clamp, 1=Wrap, 2=Black, 3=Mirror, 4=Color | 2 (Black) | ◇ | section Advanced |
| `background` | Background | color | RGB 0…1 | [0, 0, 0] | ◇ | active when `params.edge === 4`; section Advanced |

#### Prism Filter

id `prismFilter` · [prismFilter.ts](src/engine/modules/prismFilter.ts) · static

Summary: Repeats the picture in soft ghosts with rainbow fringes, like a prism filter.

> A faceted crystal held in front of the lens: the picture repeated in
> soft, offset ghosts with rainbow fringes, the dreamy look of a prism
> filter.
>
> Each outer facet is a flat face tilted away from the lens, so the scene
> through it is the same picture shifted toward that face -- a ghost --
> and, being a prism, it shifts each colour its own amount: the ghosts
> come with rainbow edges, red bent least. The crystal is far out of
> focus, so where one facet gives way to the next the ghosts cross-fade
> instead of cutting, over Facet Softness.
>
> Ring puts Facets faces round a clear centre, each ghost strongest on
> its own side of the frame. Line repeats the picture along one direction,
> fainter at each step, as a linear prism does. Split is the half prism:
> one face over half the frame, its ghost taking that half over.
>
> Light caught in the crystal's edges leaks across the boundaries between
> faces as bands of spectrum, brightest where the picture is bright.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `layout` | Layout | enum | 0=Ring, 1=Line, 2=Split | 0 (Ring) | ◇ |  |
| `facets` | Facets | int | 1 … 8 | 3 | ◇ | active when `params.layout !== SPLIT` |
| `offset` | Offset | float | 0 … 0.5 (step 0.001) | 0.12 | ◇ |  |
| `rotation` | Rotation (°) | float | -180 … 180 (step 1) | 90 | ◇ |  |
| `strength` | Ghost Strength | float | 0 … 1 (step 0.01) | 0.6 | ◇ |  |
| `softness` | Facet Softness | float | 0 … 1 (step 0.01) | 0.5 | ◇ | active when `params.layout === RING \|\| params.layout === SPLIT`; section Advanced |
| `dispersion` | Dispersion | float | 0 … 1 (step 0.01) | 0.4 | ◇ |  |
| `leak` | Rainbow Leak | float | 0 … 1 (step 0.01) | 0.3 | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Radial Blur

id `radialBlur` · [radialBlur.ts](src/engine/modules/radialBlur.ts) · static

Summary: Blurs outward from a centre as a zoom, or around it as a spin.

> Radial zoom and spin blur.
>
> Simulates high-speed camera motion, zoom bursts, or rotational momentum
> radiating from a configurable center point.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `mode` | Mode | enum | 0=Zoom, 1=Spin | 0 (Zoom) | ◇ |  |
| `amount` | Amount | float | 0 … 0.3 (step 0.002) | 0.05 | ◇ |  |
| `center` | Center | vec2 | x,y ∈ -0.5 … 1.5 | [0.5, 0.5] | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Rain on Glass

id `rain` · [rain.ts](src/engine/modules/rain.ts) · animated when `params.speed !== 0`

Summary: Puts the picture behind a rainy, fogged-up window.

> The picture through a rainy window: a fogged pane, beads of condensation
> that gather and evaporate, and drops that run down it in fits and
> starts, wiping a clear trail that slowly fogs over again.
>
> Every drop is a small lens: pushed far enough by Refraction, each drop
> holds the whole scene in miniature, upside down, as real drops do. Its
> rim darkens, and a highlight sits where it faces the light.
>
> The fog is a frosted blur with the grain of a misted pane, lifted a
> little toward grey by the light it scatters. Drops and trails are clear
> glass: running drops pick up the beads in their way, so their trails are
> empty of them. Each running drop wanders as it falls, at a pace that
> nearly stops and lurches on. Slowing Speed never makes the rain jump.
>
> How it works:
>
> A drop's face is a spherical cap, so the picture is sampled across it by
> the cap's normal; the rim darkens where the cap turns away, and the
> highlight sits where it faces the light.
>
> The fog is scattered on a golden-angle spiral turned per pixel. Beads
> sit in a jittered grid at two scales, each bead in its own cell so a
> pixel looks at one bead per scale. Running drops each have a column, a
> path that wanders across it, and a pace that nearly stops and lurches
> on. Everything runs on Speed's phase.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `amount` | Rain | float | 0 … 1 (step 0.01) | 0.6 | ◇ |  |
| `size` | Drop Size | float | 0.01 … 0.3 (step 0.001) | 0.06 | ◇ |  |
| `speed` | Speed | float | 0 … 4 (step 0.01) | 1 | ○ | phased: integrated over time, single value only |
| `refraction` | Refraction | float | 0 … 0.3 (step 0.001) | 0.06 | ◇ |  |
| `fog` | Fog | float | 0 … 1 (step 0.01) | 0.7 | ◇ |  |
| `blur` | Fog Blur | float | 0 … 48 (step 0.5) | 16 | ◇ | section Advanced |
| `trail` | Trail Length | float | 0 … 1 (step 0.01) | 0.35 | ◇ | section Advanced |
| `highlight` | Highlights | float | 0 … 1 (step 0.01) | 0.5 | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Reflection

id `waterReflection` · [waterReflection.ts](src/engine/modules/waterReflection.ts) · animated when `params.speed !== 0 && params.ripples !== 0`

Summary: Reflects the picture in water below a horizon line.

> The picture reflected in water below a horizon: a lake, a puddle, a wet
> street.
>
> Everything below Horizon shows the picture above it, mirrored across
> the line. The water is a flat plane seen in perspective, so its ripples
> are laid out in perspective too: the distance into the water grows as
> one over the height below the horizon, which crowds the ripples into
> fine lines toward the horizon and spreads them into broad swells near
> the viewer, where they also push the reflection furthest. They roll
> toward the viewer on Speed's phase.
>
> Rough water smears a reflection up and down rather than sideways --
> each facet of the surface tilts mostly toward or away from the eye -- so
> Roughness blurs along the vertical only, more near the viewer.
>
> How much is reflected follows Fresnel: water is nearly a mirror at the
> grazing angle near the horizon and mostly clear close by, where Water
> Color, the water's own body, shows through. Reflectivity scales it all.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `horizon` | Horizon | float | 0 … 1 (step 0.001) | 0.45 | ◇ |  |
| `ripples` | Ripples | float | 0 … 0.05 (step 0.0005) | 0.006 | ◇ |  |
| `rippleScale` | Ripple Scale | float | 0.25 … 4 (step 0.01) | 1 | ◇ |  |
| `speed` | Speed | float | 0 … 3 (step 0.01) | 0.6 | ○ | phased: integrated over time, single value only |
| `roughness` | Roughness | float | 0 … 32 (step 0.5) | 4 | ◇ |  |
| `reflectivity` | Reflectivity | float | 0 … 1 (step 0.01) | 0.85 | ◇ |  |
| `waterColor` | Water Color | color | RGB 0…1 | [0.04, 0.08, 0.1] | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Sharpen

id `sharpen` · [sharpen.ts](src/engine/modules/sharpen.ts) · static · 3 passes

Summary: Brings out fine detail.

> Unsharp mask: blur a copy, take what the blur took away -- the detail --
> and add more of it back.
>
> Threshold leaves detail smaller than it alone, so a flat sky or a noisy
> shadow is not sharpened into grit; it opens with a soft ramp rather than
> a cut, or the edge of what counts as detail would itself show. Luma Only
> sharpens brightness and not colour, which is what keeps sharpened edges
> from growing coloured fringes.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `amount` | Amount | float | 0 … 5 (step 0.01) | 1 | ◇ |  |
| `radius` | Radius | float | 0.5 … 40 (step 0.1) | 1.5 | ◇ |  |
| `threshold` | Threshold | float | 0 … 0.5 (step 0.005) | 0.02 | ◇ |  |
| `lumaOnly` | Luma Only | bool | on / off | true | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Shattered Glass

id `shatter` · [shatter.ts](src/engine/modules/shatter.ts) · static

Summary: Breaks the picture into shards of glass spreading from an impact point.

> The picture behind a pane that has taken a blow: shards spreading from
> an impact point, small and crushed at the centre and growing outward,
> each tilted its own way, with chipped, glinting cracks between them.
>
> Each shard is a pane on its own tilt: the picture under it is shifted
> (and split slightly into colour, as a tilted plate refracts each colour
> its own amount), and it catches the light a shade brighter or darker.
> Cracks are measured as the exact distance to the shard's border, turned
> back from log-polar into pixels, so they keep their width at every
> distance; their width wavers along their length, which reads as chips.
> Where the shards get smaller than a few pixels the cracks give way to
> the white, powdered glass of the impact itself.
>
> How it works:
>
> The shards are a Voronoi diagram drawn in log-polar space round the
> impact -- angle across, the log of the distance down. That map is
> conformal, so cells keep their shape but shrink toward the centre, and
> they come out as the wedges and rings of a real break. Cells are drawn
> out a little along the radius, as shards are, and the angle wraps every
> Shards cells so the ring closes without a seam.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `impact` | Impact | vec2 | x,y ∈ -0.5 … 1.5 | [0.45, 0.55] | ◇ |  |
| `spread` | Spread | float | 0.05 … 2 (step 0.01) | 0.7 | ◇ |  |
| `shards` | Shards | int | 4 … 48 | 14 | ◇ |  |
| `displacement` | Displacement | float | 0 … 0.05 (step 0.0005) | 0.006 | ◇ |  |
| `dispersion` | Dispersion | float | 0 … 1 (step 0.01) | 0.3 | ◇ | section Advanced |
| `shading` | Shard Shading | float | 0 … 0.5 (step 0.005) | 0.12 | ◇ | section Advanced |
| `crackWidth` | Crack Width | float | 0 … 6 (step 0.1) | 1.2 | ◇ |  |
| `glint` | Crack Glint | float | 0 … 1 (step 0.01) | 0.6 | ◇ | section Advanced |
| `variation` | Variation | int | 0 … 99 | 0 | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Soap Film

id `soapFilm` · [soapFilm.ts](src/engine/modules/soapFilm.ts) · animated when `params.speed !== 0`

Summary: Lays swirling rainbow bands over the picture, like a soap bubble or an oil slick spreading on water.

> A soap film stretched over the picture: the swirling, draining bands of
> colour of a bubble's skin, or oil on water.
>
> The thickness is what moves. Gravity drains the film, so it is thinnest
> at the top and the bands run across; Drainage sets how much. Over that
> a flowing, folded noise field swirls the bands into eddies, on Speed's
> phase. Thickness is the film's mean thickness in microns.
>
> Radial lays it as oil spreading on water from a drop at Center: thick
> (muddy, pale higher orders) in the middle, thinning outward into the
> saturated first orders, Drainage setting how much thinner the rim is.
> Fingers stretches the eddies along the radius into the feathery tongues
> of a spreading slick; the noise is read on rays from the centre, so
> there is no seam around it. Crinkle adds the fine labyrinth relief of a
> skin on the oil, both in the thickness and as a little shading.
>
> The film is transparent: the picture shows through, less what the film
> reflects, plus the reflected colour, by Strength.
>
> How it works:
>
> The colour is thin-film interference. Light reflects off the film's
> front and back, and the two reflections meet out of step by twice the
> film's thickness inside it; a wavelength is reflected as sin^2 of
> 2 pi n d / lambda, with n = 1.33 for soapy water. Summed over eight
> wavelengths, that gives the true sequence of soap-film colours as the
> film thins: the pale pinks and greens of thick film, the saturated
> magentas, blues and golds of the first orders, and -- thinner than any
> wavelength can resolve -- the black film at the very top of a bubble,
> where nothing reflects at all.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `shape` | Shape | enum | 0=Draining, 1=Radial | 0 (Draining) | ◇ |  |
| `center` | Center | vec2 | x,y ∈ -0.5 … 1.5 | [0.5, 0.5] | ◇ | a point on the preview; shown when Radial |
| `thickness` | Thickness | float | 0 … 2 (step 0.01) | 0.6 | ◇ |  |
| `drainage` | Drainage | float | 0 … 1 (step 0.01) | 0.6 | ◇ |  |
| `swirl` | Swirl | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `speed` | Speed | float | 0 … 2 (step 0.01) | 0.3 | ○ | phased: integrated over time, single value only |
| `strength` | Strength | float | 0 … 1 (step 0.01) | 0.6 | ◇ |  |
| `scale` | Scale | float | 0.1 … 3 (step 0.01) | 1 | ◇ | section Advanced |
| `fingers` | Fingers | float | 0 … 1 (step 0.01) | 0.6 | ◇ | section Advanced; dimmed unless Radial |
| `crinkle` | Crinkle | float | 0 … 1 (step 0.01) | 0 | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Spectral Prism

id `spectralPrism` · [spectralPrism.ts](src/engine/modules/spectralPrism.ts) · static

Summary: Spreads the picture into a smooth rainbow, as a prism splits light.

> Dispersion the way a prism does it: the picture spread into a smooth
> spectrum instead of three offset copies.
>
> Chromatic Aberration moves red, green and blue apart, which leaves three
> hard-edged fringes. Light is a continuum, so here an edge opens into a
> full rainbow, and anything that does not move stays exactly its colour.
>
> Directional spreads along one angle, as light through a prism. Radial
> spreads outward from Center, more the further from it, as a lens's
> lateral colour does.
>
> How it works:
>
> It walks twelve wavelengths from violet to red, shifts the picture by
> each one's own amount, and weighs it by that wavelength's colour; the
> weights are summed per channel and divided out. The wavelengths are
> nudged per pixel, so the spectrum is smooth rather than twelve bands.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `mode` | Mode | enum | 0=Directional, 1=Radial | 0 (Directional) | ◇ |  |
| `amount` | Amount | float | 0 … 0.1 (step 0.0005) | 0.015 | ◇ |  |
| `angle` | Angle (°) | float | -180 … 180 (step 1) | 0 | ◇ | active when `params.mode === DIRECTIONAL` |
| `center` | Center | vec2 | x,y ∈ -0.5 … 1.5 | [0.5, 0.5] | ◇ | active when `params.mode === RADIAL` |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Tilt-Shift

id `tiltShift` · [tiltShift.ts](src/engine/modules/tiltShift.ts) · static · 3 passes

Summary: Keeps a band in focus and blurs the rest, making real scenes look like miniatures.

> The miniature look: a band of sharp focus across the frame and blur that
> grows away from it, the shallow depth of field of a lens tilted against
> the sensor -- which is how a real street comes to look like a model.
>
> Focus places the band across the frame and Angle turns it; Width is how
> much stays sharp either side of its centre line and Falloff how far the
> blur takes to reach Max Blur. The band's own pixels are never blurred at
> all.
>
> Saturation adds the bright, painted colour of a toy model; at 1 it is
> off.
>
> How it works:
>
> The blur radius is worked out per pixel in both blur passes.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `focus` | Focus | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `angle` | Angle (°) | float | -90 … 90 (step 1) | 0 | ◇ |  |
| `width` | Width | float | 0 … 0.5 (step 0.005) | 0.08 | ◇ |  |
| `falloff` | Falloff | float | 0.01 … 1 (step 0.01) | 0.25 | ◇ |  |
| `maxBlur` | Max Blur | float | 0 … 48 (step 0.5) | 12 | ◇ |  |
| `saturation` | Saturation | float | 0 … 2 (step 0.01) | 1.3 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Vignette

id `vignette` · [vignette.ts](src/engine/modules/vignette.ts) · static

Summary: Darkens or tints the edges of the picture.

> Darkened (or tinted) falloff towards the edges.
>
> The distance is aspect-corrected, so on a wide image the vignette stays
> circular instead of being stretched into an ellipse by the UV space.
> Centre is exposed because an off-centre vignette is how you fake a light
> source sitting off to one side.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `center` | Center | vec2 | x,y ∈ 0 … 1 | [0.5, 0.5] | ◇ |  |
| `radius` | Radius | float | 0 … 1.2 (step 0.01) | 0.7 | ◇ |  |
| `softness` | Softness | float | 0.01 … 1 (step 0.01) | 0.35 | ◇ |  |
| `strength` | Strength | float | 0 … 1 (step 0.01) | 0.6 | ◇ |  |
| `color` | Color | color | RGB 0…1 | [0, 0, 0] | ◇ |  |

### Transform & Warp

#### Corner Pin

id `cornerPin` · [cornerPin.ts](src/engine/modules/cornerPin.ts) · static

Summary: Moves the picture's four corners to put it in perspective, onto a screen or a wall.

> Pins the picture's four corners anywhere, warping it in true
> perspective -- onto a screen, a sign, the side of a building.
>
> Corners are in the frame's own coordinates, (0, 0) at the bottom left
> as everywhere in the engine, and default to the frame's corners: the
> identity. Outside the quad is transparent, black, or the picture as it
> was underneath.
>
> How it works:
>
> The square-to-quad homography after Heckbert: eight numbers, solved in
> closed form from the four corners, that take the picture's square to the
> pinned quad. Each output pixel is taken back through its inverse to find
> where in the picture it came from. A projective map, not a bilinear one,
> so straight lines stay straight and the far side of a plane is really
> foreshortened.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `topLeft` | Top Left | vec2 | x,y ∈ -0.5 … 1.5 | [0, 1] | ◇ |  |
| `topRight` | Top Right | vec2 | x,y ∈ -0.5 … 1.5 | [1, 1] | ◇ |  |
| `bottomRight` | Bottom Right | vec2 | x,y ∈ -0.5 … 1.5 | [1, 0] | ◇ |  |
| `bottomLeft` | Bottom Left | vec2 | x,y ∈ -0.5 … 1.5 | [0, 0] | ◇ |  |
| `outside` | Outside | enum | 0=Transparent, 1=Black, 2=Source | 0 (Transparent) | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Depth Mesh

id `depthMesh` · [depthMesh.ts](src/engine/modules/depthMesh.ts) · animated when `params.speed !== 0` · extra picture inputs: `height` (Height)

Summary: Raises the picture into 3D by its brightness or a depth map, as points, a wireframe or a surface you orbit.

> The picture raised into 3D, each part as far forward as it is bright --
> or as its Height input is, so Depth's depth map makes a scene of a
> photo -- seen through a camera you orbit: TouchDesigner's depth point
> cloud and mesh.
>
> The grid is drawn first: Columns cells
> across, square, as a surface with the picture on it, a wireframe that
> still hides what is behind it, or a point at each cell. The surface
> tears where the height jumps by more than Tear allows, so a person in
> front of a wall stands apart from it instead of being skinned to it.
> This shades the drawing as a Model's: the picture, lit by its slope, one
> colour, its depth or its normals; Fade with Distance sinks the far parts
> into the background.
>
> The grid and the camera are worked out once a frame, not per pixel, so
> their settings take a single value (a wire from a modulator, or keys),
> never a picture.
>
> How it works:
>
> The grid is drawn by reliefRender.ts.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `style` | Style | enum | 0=Surface, 1=Wireframe, 2=Points | 2 (Points) | ○ |  |
| `columns` | Columns | int | 8 … 400 | 160 | ○ | grid cells across; rows follow the picture's shape |
| `depth` | Depth | float | 0 … 2 (step 0.01) | 0.5 | ○ | how far white stands out from black, in picture heights |
| `pointSize` | Point Size | float | 0.05 … 3 (step 0.01) | 0.7 | ○ | active with Style Points; 1 touches its neighbours |
| `lineWidth` | Line Width (px) | float | 0.25 … 6 (step 0.05) | 1 | ○ | active with Style Wireframe; pixels at 1080 lines |
| `tear` | Tear | float | 0 … 1 (step 0.01) | 0.6 | ○ | inactive with Style Points; 0 never tears, higher tears at smaller height jumps |
| `orbit` | Orbit (°) | float | -180 … 180 (step 0.5) | 25 | ○ | 0 looks straight at the picture |
| `tilt` | Tilt (°) | float | -90 … 90 (step 0.5) | 10 | ○ |  |
| `distance` | Distance | float | 0.2 … 6 (step 0.01) | 1.2 | ○ | 1 sees the flat picture fill the frame |
| `speed` | Turntable (turns/s) | float | -2 … 2 (step 0.01) | 0 | ○ | added to Orbit; integrated, so changing it never jumps |
| `fov` | Field of View (°) | float | 5 … 120 (step 0.5) | 35 | ○ | under Camera |
| `position` | Position | vec2 | -0.5 … 1.5 (step 0.001) | [0.5, 0.5] | ◇ | under Camera; where the picture's centre lands, 0..1 from the bottom left; a lens shift |
| `shading` | Shading | enum | 0=Picture, 1=Lit, 2=Colour, 3=Depth, 4=Normals | 0 (Picture) | ◇ | Depth: white near |
| `color` | Colour | color | RGB 0…1 | [0.35, 1, 0.7] | ◇ | active with Shading Colour |
| `lightAngle` | Light Angle (°) | float | -180 … 180 (step 0.5) | -40 | ◇ | under Light; active with Shading Lit; 0 shines from the camera |
| `lightHeight` | Light Height (°) | float | -90 … 90 (step 0.5) | 35 | ◇ | under Light; active with Shading Lit |
| `ambient` | Ambient | float | 0 … 1 (step 0.01) | 0.35 | ◇ | under Light; active with Shading Lit |
| `fog` | Fade with Distance | float | 0 … 1 (step 0.01) | 0 | ◇ | far parts sink into the background |
| `background` | Background | enum | 0=Transparent, 1=Colour, 2=Picture | 1 (Colour) | ◇ | under Background |
| `backgroundColor` | Background Colour | color | RGB 0…1 | [0, 0, 0] | ◇ | under Background; active with Background Colour |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Displace

id `displace` · [displace.ts](src/engine/modules/displace.ts) · animated when `params.speed !== 0`

Summary: Warps the picture with noise: heat haze, wet glass, worn tape.

> Warp driven by a fractal noise field -- heat haze, wet glass, the swim of
> a tape that has been played too many times.
>
> Stacking a coarse Displace and a fine one warps twice rather than warping
> the same shape harder.
>
> How it works:
>
> The X and Y offsets are read from the same field at points far enough
> apart to be uncorrelated. Sampling one field twice at the same spot would
> give dx == dy and collapse every displacement onto the diagonal.
>
> The field carries `u_seed` so that it does.
>
> This is the module that will later take an optional second input to use
> as its field instead of the internal noise; the knobs are already the
> ones that generator would expose.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `amount` | Amount | float | 0 … 0.2 (step 0.001) | 0.02 | ◇ |  |
| `scale` | Scale | float | 0.5 … 40 (step 0.5) | 4 | ◇ |  |
| `octaves` | Octaves | int | 1 … 8 | 3 | ◇ |  |
| `speed` | Speed | float | -2 … 2 (step 0.01) | 0.2 | ○ | phased: integrated over time, single value only |
| `edge` | Edge | enum | 0=Clamp, 1=Wrap, 2=Black, 3=Mirror | 0 (Clamp) | ◇ |  |

#### Kaleidoscope

id `kaleidoscope` · [kaleidoscope.ts](src/engine/modules/kaleidoscope.ts) · static

Summary: Mirrors the picture into kaleidoscope wedges or across its axes.

> Mirror symmetry: a kaleidoscope of wedges, or a plain mirror across one or
> both axes.
>
> The kaleidoscope folds the angle around Center into a single wedge and
> mirrors every other one, so neighbouring wedges meet seamlessly. Rotation
> turns the wedge pattern itself; Source Angle turns the picture under it,
> which is what changes the content of every wedge at once.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `mode` | Mode | enum | 0=Kaleidoscope, 1=Mirror X, 2=Mirror Y, 3=Mirror Quad | 0 (Kaleidoscope) | ◇ |  |
| `segments` | Segments | int | 2 … 32 | 6 | ◇ | active when `params.mode === 0` |
| `rotation` | Rotation | float | -360 … 360 (step 1) | 0 | ◇ |  |
| `sourceAngle` | Source Angle | float | -360 … 360 (step 1) | 0 | ◇ |  |
| `center` | Center | vec2 | x,y ∈ -0.5 … 1.5 | [0.5, 0.5] | ◇ |  |
| `zoom` | Zoom | float | 0.1 … 8 (step 0.01) | 1 | ◇ |  |
| `edge` | Edge | enum | 0=Clamp, 1=Wrap, 2=Black, 3=Mirror | 3 (Mirror) | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Polar Coordinates

id `polarCoordinates` · [polarCoordinates.ts](src/engine/modules/polarCoordinates.ts) · static

Summary: Wraps the picture around a centre, turning a horizon into a tiny planet, or unrolls it back.

> Rectangular to polar and back: the picture's width wrapped round a
> centre and its height run out from it, so a horizon becomes a little
> planet and a stripe a ring -- or, the other way, a ring unrolled flat.
>
> The two modes are each other's inverse at the same settings, so one
> after the other gives the picture back. Measured in square units, so a
> ring is a circle on any frame. Edge defaults to Wrap, which is what
> joins the seam where the angle comes back round.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `mode` | Mode | enum | 0=To Polar, 1=To Rectangular | 0 (To Polar) | ◇ |  |
| `center` | Center | vec2 | x,y ∈ -0.5 … 1.5 | [0.5, 0.5] | ◇ |  |
| `rotation` | Rotation (°) | float | -360 … 360 (step 1) | 0 | ◇ |  |
| `radius` | Radius | float | 0.1 … 2 (step 0.01) | 0.5 | ◇ |  |
| `edge` | Edge | enum | 0=Clamp, 1=Wrap, 2=Black, 3=Mirror | 1 (Wrap) | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Remap

id `mapDisplace` (once Map Displace) · [mapDisplace.ts](src/engine/modules/mapDisplace.ts) · static · extra picture inputs: `map` (Map)

Summary: Warps the picture by another picture: pushed by its slopes or vectors, or read at the places its red and green point to.

> Texture-driven displacement / optical refraction.
>
> Warps UV coordinates using another node's output as a surface heightmap or
> vector field (e.g. frosted glass, liquid ripples, normal maps, or text cutouts).
> An unplugged Map input passes the image through untouched.
>
> The gradient modes bend the picture where the map changes -- its edges and
> bumps -- so a smooth map (a depth map) barely moves it. Luma Value pushes
> by the map's brightness itself, along Direction: a depth map for parallax,
> mid grey staying put. Normal Map reads a tangent-space normal map's red and
> green as the slope, flat (128, 128) staying put; Flip Green for DirectX maps.
>
> Coordinates (STMap) takes the place outright (TouchDesigner's Remap TOP,
> Nuke's STMap): red and green are where to read, 0..1 across and up, so the
> identity map is a red ramp across and a green ramp up, and a lens
> distortion exported as an STMap applies as is. Strength slides from the
> identity (0) to the map (1); Flip V reads green from the top down. An
> eight-bit map steps the picture every 1/255 of the frame; with High
> precision on, maps made in the graph are half float.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `amount` | Amount | float | -0.2 … 0.2 (step 0.001) | 0.04 | ◇ | shown in every mode but Coordinates |
| `source` | Vector Mode | enum | 0=Luma Gradient (Glass), 1=Red / Green Vector, 2=Alpha Gradient, 3=Luma Value (Depth), 4=Normal Map, 5=Coordinates (STMap) | 0 (Luma Gradient (Glass)) | ◇ |  |
| `direction` | Direction | float | 0 … 360 (step 1) | 0 | ◇ | degrees, 0 = right; shown in Luma Value |
| `flipGreen` | Flip Green | bool | on / off | false | ◇ | for DirectX normal maps; shown in Normal Map |
| `strength` | Strength | float | 0 … 1 (step 0.01) | 1 | ◇ | 0 the picture as it is, 1 wholly the map; shown in Coordinates |
| `flipV` | Flip V | bool | on / off | false | ◇ | green from the top down; shown in Coordinates |
| `edge` | Edge | enum | 0=Clamp, 1=Wrap, 2=Black, 3=Mirror | 0 (Clamp) | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Resize / Crop

id `resize` · [resize.ts](src/engine/modules/resize.ts) · static · sets the frame size for everything downstream

Summary: Changes the picture's size or crops it.

> Resize or crop: the one module that changes the picture's size.
>
> Every other module works inside the frame it is handed. This one makes
> a new frame , and everything after it on the main path --
> and an export of it -- is that size and shape:
>
>   - Resize by a scale, to a width and height, or to a width or height
>     with the shape kept. Given both and a new shape, Fit says what
>     happens to the difference: stretch, fill and crop, or fit and leave
>     transparent bars. Anchor says which part is kept or where it sits.
>   - Crop to Aspect cuts the largest piece of a given shape out of the
>     picture, from where Anchor says.
>   - Crop Margins takes a share off each side.
>
> Sizes are source pixels, like every pixel param, so a 1080 x 1080
> resize exports at 1080 x 1080 at render scale 1, whatever the preview
> works at. They shape the plan rather than a frame of it, so they have
> no port -- a wire could not resize the picture from one frame to the next.
>
> Shrinking averages every input pixel an output pixel covers, up to 4 x 4,
> rather than sampling four of them, so fine detail resizes down to the tone
> it averages to instead of breaking into moire.
>
> How it works:
>
> The new frame is made in frames.ts.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `mode` | Mode | enum | 0=Resize, 1=Crop to Aspect, 2=Crop Margins | 0 (Resize) | none |  |
| `sizeBy` | Size By | enum | 0=Scale, 1=Width & Height, 2=Width, 3=Height | 0 (Scale) | none | active when Mode is Resize |
| `scale` | Scale | float | 0.05 … 4 (step 0.01) | 1 | none | active when Mode is Resize and Size By is Scale |
| `width` | Width | float | free number (typed) | 1920 | none | active when Mode is Resize and Size By is Width & Height or Width |
| `height` | Height | float | free number (typed) | 1080 | none | active when Mode is Resize and Size By is Width & Height or Height |
| `fit` | Fit | enum | 0=Stretch, 1=Fill (Crop), 2=Fit (Bars) | 1 (Fill (Crop)) | ◇ | active when Mode is Resize and Size By is Width & Height |
| `aspect` | Aspect | enum | 0=1:1, 1=4:5, 2=9:16, 3=16:9, 4=4:3, 5=3:2, 6=21:9 | 0 (1:1) | none | active when Mode is Crop to Aspect |
| `anchor` | Anchor | vec2 | x,y ∈ -1 … 1 | [0, 0] | ◇ | active when Mode is Crop to Aspect, or Mode is Resize with Size By Width & Height and Fit is not Stretch |
| `left` | Left | float | 0 … 0.95 (step 0.005) | 0 | none | active when Mode is Crop Margins; section Margins |
| `right` | Right | float | 0 … 0.95 (step 0.005) | 0 | none | active when Mode is Crop Margins; section Margins |
| `top` | Top | float | 0 … 0.95 (step 0.005) | 0 | none | active when Mode is Crop Margins; section Margins |
| `bottom` | Bottom | float | 0 … 0.95 (step 0.005) | 0 | none | active when Mode is Crop Margins; section Margins |

#### Ripple

id `ripple` · [ripple.ts](src/engine/modules/ripple.ts) · animated when `params.speed !== 0`

Summary: Sends rings out from a point, like a stone dropped in water.

> Rings spreading from a point, as on water after a stone goes in.
>
> Each pixel is pushed toward or away from Center by a sine of its
> distance, so the picture bends along circles; Speed sends the circles
> outward. Speed is phased, so changing it mid-play never jumps the rings.
> Decay fades the waves with distance -- at 0 they run to the frame's edge
> at full height. Measured in square units, so the rings are round.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `center` | Center | vec2 | x,y ∈ -0.5 … 1.5 | [0.5, 0.5] | ◇ |  |
| `amplitude` | Amplitude | float | 0 … 0.1 (step 0.001) | 0.01 | ◇ |  |
| `wavelength` | Wavelength | float | 0.01 … 0.5 (step 0.005) | 0.08 | ◇ |  |
| `speed` | Speed | float | -4 … 4 (step 0.01) | 0.5 | ○ | phased: integrated over time, single value only |
| `decay` | Decay | float | 0 … 10 (step 0.1) | 2 | ◇ |  |
| `edge` | Edge | enum | 0=Clamp, 1=Wrap, 2=Black, 3=Mirror | 0 (Clamp) | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Swirl

id `swirl` · [swirl.ts](src/engine/modules/swirl.ts) · static

Summary: Twists the picture into a whirlpool.

> Rotational swirl / whirlpool warp.
>
> Twirls pixels around an adjustable center point with quadratic falloff.
> Aspect ratio is compensated so the swirl retains circular symmetry.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `angle` | Angle | float | -720 … 720 (step 5) | 180 | ◇ |  |
| `radius` | Radius | float | 0.05 … 1 (step 0.01) | 0.5 | ◇ |  |
| `center` | Center | vec2 | x,y ∈ -0.5 … 1.5 | [0.5, 0.5] | ◇ |  |
| `edge` | Edge | enum | 0=Clamp, 1=Wrap, 2=Black, 3=Mirror | 0 (Clamp) | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Tile

id `tile` · [tile.ts](src/engine/modules/tile.ts) · static

Summary: Repeats the picture in a grid.

> The picture repeated in a grid: Count X across and Count Y down, each
> tile the whole picture.
>
> Brick Offset shifts each row along by that fraction of a tile, as a
> brick wall's courses are. Mirror flips every other column or row so
> neighbouring tiles meet edge to matching edge -- a seamless pattern from
> any picture. Rotation turns the grid as a whole, about the frame's
> centre and in square units, so the tiles stay rectangles.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `countX` | Count X | int | 1 … 32 | 3 | ◇ |  |
| `countY` | Count Y | int | 1 … 32 | 3 | ◇ |  |
| `brick` | Brick Offset | float | 0 … 1 (step 0.01) | 0 | ◇ |  |
| `mirrorX` | Mirror X | bool | on / off | false | ◇ |  |
| `mirrorY` | Mirror Y | bool | on / off | false | ◇ |  |
| `rotation` | Rotation (°) | float | -180 … 180 (step 1) | 0 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Transform

id `transform` · [transform.ts](src/engine/modules/transform.ts) · static

Summary: Moves, scales, rotates and flips the picture.

> Pan, zoom, rotate and flip.
>
> Unglamorous on its own, but it is what lets a chain build a ghost: two
> branches of the same picture, one nudged a few pixels sideways, is the
> whole trick behind a VHS echo once there is something to blend them with.
>
> Rotation works in a space where one unit is the same distance across and
> down, so a square stays square on a wide image rather than shearing.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `offset` | Offset | vec2 | x,y ∈ -1 … 1 | [0, 0] | ◇ |  |
| `scale` | Scale | float | 0.1 … 4 (step 0.01) | 1 | ◇ |  |
| `rotation` | Rotation | float | -0.5 … 0.5 (step 0.005) | 0 | ◇ |  |
| `flipX` | Flip H | bool | on / off | false | ◇ |  |
| `flipY` | Flip V | bool | on / off | false | ◇ |  |
| `edge` | Edge | enum | 0=Clamp, 1=Wrap, 2=Black, 3=Mirror | 0 (Clamp) | ◇ |  |

#### Wobble

id `wobble` · [wobble.ts](src/engine/modules/wobble.ts) · animated when `params.rate !== 0`

Summary: Waves the picture with a travelling ripple.

> A travelling wave that displaces the picture -- the image-space half of
> "modulation".
>
> Frequency is how many cycles fit across the image and Rate is how fast
> they travel, which are independent: a slow fat swell and a fast fine
> ripple are the same module at opposite ends of two knobs.
>
> How it works:
>
> On Both, the vertical wave is pushed out of phase with the horizontal one
> by an arbitrary fraction. Left aligned, the two axes would move together
> and the result would just be a diagonal wobble rather than a churn.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `waveform` | Waveform | enum | 0=Sine, 1=Triangle, 2=Square, 3=Noise | 0 (Sine) | ◇ |  |
| `amplitude` | Amplitude | float | 0 … 0.2 (step 0.001) | 0.01 | ◇ |  |
| `frequency` | Frequency | float | 0.5 … 40 (step 0.5) | 6 | ◇ |  |
| `rate` | Rate | float | -4 … 4 (step 0.05) | 0.5 | ○ | phased: integrated over time, single value only |
| `phase` | Phase | float | 0 … 1 (step 0.01) | 0 | ◇ |  |
| `axis` | Axis | enum | 0=Horizontal, 1=Vertical, 2=Both | 0 (Horizontal) | ◇ |  |
| `edge` | Edge | enum | 0=Clamp, 1=Wrap, 2=Black, 3=Mirror | 0 (Clamp) | ◇ |  |

### CRT & Display

#### Composite Video

id `compositeVideo` · [compositeVideo.ts](src/engine/modules/compositeVideo.ts) · animated when `params.crawl === true` · 3 passes

Summary: Gives the colour bleeding and artifacts of old composite video, from consoles to VHS.

> The picture sent down one wire as NTSC composite video and decoded again,
> which is where a console or a VHS deck's colour artifacts come from.
>
> Composite puts colour on a subcarrier riding on top of brightness, in the
> same band as fine detail, and the TV has to pull them apart again. It
> never quite can:
> - Dot crawl: what is left of the carrier in the brightness, a checker of
>   dots along colour edges that crawls as the carrier's phase turns over
>   from line to line and frame to frame.
> - Rainbows: fine stripes in the brightness near the carrier's frequency
>   are taken for colour, and shimmer in false hues.
> - Soft colour: the colour is filtered to a fraction of the brightness's
>   detail.
>
> Carrier is in cycles across the width, so the pattern holds its size at
> any resolution; a line is a source pixel tall.
>
> How it works:
>
> Done for real: pass 0 encodes YIQ onto the carrier, pass 1 separates the
> brightness (a notch filter, or a comb against the line above, whose
> carrier is in opposite phase) and demodulates the rest, pass 2 filters
> the colour and decodes to RGB. Float targets in between.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `cycles` | Carrier | float | 60 … 400 (step 1) | 180 | ◇ |  |
| `decoder` | Decoder | enum | 0=Notch, 1=Comb | 0 (Notch) | ◇ |  |
| `lumaFilter` | Luma Filter | float | 0.1 … 1 (step 0.01) | 0.4 | ◇ |  |
| `chromaFilter` | Chroma Filter | float | 0.25 … 4 (step 0.05) | 1.2 | ◇ |  |
| `saturation` | Saturation | float | 0 … 2 (step 0.01) | 1 | ◇ |  |
| `hue` | Hue Error | float | -45 … 45 (step 0.5) | 0 | ◇ |  |
| `crawl` | Dot Crawl | bool | on / off | true | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Frequency Modulation

id `fmScanlines` · [fmScanlines.ts](src/engine/modules/fmScanlines.ts) · animated when `params.speed !== 0` · 4 passes · extra picture inputs: `modulator` (Modulator)

Summary: Bends each scanline with the picture's brightness, like a frequency-modulated signal.

> True frequency modulation along each scanline.
>
> The picture sets how fast the lines come, not where they sit: brightness
> is the instantaneous frequency, and the phase is its running integral
> along the row. So a bright patch packs the lines tight *and* everything
> after it on the row stays shifted, even once the row goes dark again --
> the cascading look of the After Effects "Modulation" plugin and the
> TouchDesigner FM patches. Velocity Modulation, by contrast, displaces
> the phase locally (PM), and its lines snap back to the grid the moment
> the driver lets go.
>
> Normalising by the row length means Carrier is a count of lines across
> the frame, like Scanlines' Lines, and a preview and a full-size export
> draw the same picture.
>
> How it works:
>
> The integral is a prefix sum, done on the GPU because the input is a
> live picture (a video, an animated chain) rather than a still that could
> be summed once on the CPU:
>
>   0. integrand -- the frequency at each pixel, in cycles per pixel:
>      (carrier + depth * driver) / length of the row. Carrier and Depth
>      are read here, at each pixel, so either can take a field and the
>      sum is still the true integral of a varying frequency;
>   1. local scan -- each pixel sums its own block of BLOCK pixels up to
>      itself;
>   2. block scan -- adds the totals of every earlier block, read off the
>      last pixel of each, which gives the full running sum;
>   3. render -- draws the wave at that phase.
>
> Only the fractional part of a phase is ever seen, so the scans keep
> their sums modulo one. That keeps them small and exact in full float,
> and still usable where the GPU only has half float to give. The whole
> cycles are counted alongside, modulo LINE_IDS, which numbers each line
> the same on every row it runs through -- enough for Scatter to give each
> one its own random offset.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `carrier` | Carrier | float | 0 … 160 (step 0.1) | 35 | ◇ |  |
| `depth` | Depth | float | 0 … 300 (step 1) | 90 | ◇ |  |
| `driver` | Driver | enum | 0=Luminance, 1=Inverted Luma, 2=Red, 3=Green, 4=Blue, 5=Saturation | 0 (Luminance) | ◇ |  |
| `waveform` | Waveform | enum | 0=Hairline, 1=Sine, 2=Pulse, 3=Saw, 4=Dots, 5=Dashes, 6=Double, 7=Trail | 0 (Hairline) | ◇ |  |
| `width` | Line Width | float | 1 … 8 (step 0.5) | 1 | ◇ | active when Waveform is Hairline, Dots, Dashes, Double or Trail |
| `speed` | Drift | float | -2 … 2 (step 0.01) | 0 | ○ | phased: integrated over time, single value only |
| `lineColor` | Line Color | color | RGB 0…1 | [1, 1, 1] | ◇ |  |
| `spacing` | Spacing | float | 2 … 64 (step 1) | 6 | ◇ | active when `[4, 5, 6].includes(params.waveform)`; section Waveform |
| `scatter` | Scatter | float | 0 … 1 (step 0.01) | 0 | ◇ | active when `[4, 5].includes(params.waveform)`; section Waveform |
| `duty` | Duty | float | 0.05 … 0.95 (step 0.01) | 0.5 | ◇ | active when Waveform is Sine, Pulse, Saw or Dashes; section Waveform |
| `axis` | Axis | enum | 0=Vertical Lines, 1=Horizontal Lines | 0 (Vertical Lines) | ◇ | section Advanced |
| `start` | Start | enum | 0=Left / Bottom, 1=Right / Top | 0 (Left / Bottom) | ◇ | the edge the scan, and so the bending, builds from; Drift moves away from it; section Advanced |
| `lumMask` | Luma Mask | float | 0 … 1 (step 0.01) | 0 | ◇ | section Advanced |
| `output` | Output | enum | 0=Lines, 1=Source Colour | 0 (Lines) | ◇ | section Advanced |
| `bgColor` | Background | color | RGB 0…1 | [0, 0, 0] | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Interlace

id `interlace` · [interlace.ts](src/engine/modules/interlace.ts) · animated when `params.rate !== 0`

Summary: Shows odd and even lines on alternate frames, like interlaced video.

> Alternating fields: odd lines on one frame, even on the next.
>
> Two artefacts in one, because they are the same mechanism. Dim is the
> inactive field fading between refreshes -- the flicker. Shift displaces
> the two fields vertically, which is what makes movement comb apart the
> way an interlaced still of a moving subject does.
>
> Lines counts field rows down the whole picture and Shift is in lines,
> not pixels, for the reason Scanlines gives -- and so the two line up
> when set to the same count.
>
> At Rate 0 the fields stop alternating and this becomes a static line
> structure, which is a legitimate place to park it.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `lines` | Lines | float | 20 … 1080 (step 1) | 240 | ◇ |  |
| `dim` | Dim | float | 0 … 1 (step 0.01) | 0.35 | ◇ |  |
| `offset` | Shift (lines) | float | 0 … 4 (step 0.05) | 0 | ◇ |  |
| `rate` | Rate | float | 0 … 60 (step 1) | 30 | ○ | phased: integrated over time, single value only |

#### Particle Flow

id `particleFlow` · [particleFlow.ts](src/engine/modules/particleFlow.ts) · animated when `params.speed !== 0 || params.trail > 0`

Summary: Lets particles flow over the picture, moving faster or slower with its brightness.

> Particles stream over the picture and move faster or slower with its
> brightness (or another driver), so they bunch up and draw the picture.
>
> - Particles stream steadily from the emitter (Edge, Point Cone, Point 360°,
>   Fullscreen), so many per second, and move in straight lines.
> - How fast each one moves is set by the driver you pick (Luminance,
>   Saturation, Edges, RGB, Hue): they slow down where the driver peaks, and
>   the bunching and congestion there is what forms the image.
> - When particles reach the frame boundary, they are gone.
> - The simulation takes one step per frame of the comp.
> - Particles are drawn as crisp single pixels with configurable size and
>   phosphor decay trails.
>
> How it works:
>
> Particle Flow is a real discrete GPU particle simulator with luminance
> speed modulation. Each particle moves strictly along a straight path;
> slowing down in driver peaks causes physical bunching and particle
> congestion. Particles are rendered as crisp integer point pixels.

**Bake** (on the card) runs the comp once, frame by frame like an export, and
keeps every frame's particles in memory, so the timeline replays them
exactly: scrubbing, a seek and the loop going round show what playing
through showed, trails included. Until reload, and until anything the
particles depend on changes (what comes in, a setting that moves them, the
comp's start, end or frame rate): then the card says the bake was let go and
the module simulates live again. Size, Shape, Color, Brightness, Trail, Mode
and Mix only change how the baked particles are drawn, so they keep the bake.
At most 768 MB a bake.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `emitter` | Emitter Shape | enum | 0=Edge (Directional), 1=Point (Directional Cone), 2=Point (Radial 360°), 3=Fullscreen Drift | 0 (Edge (Directional)) | ○ |  |
| `angle` | Direction Angle | float | 0 … 360 (step 1) | 270 | ○ |  |
| `origin` | Emitter Origin | vec2 | x,y ∈ 0 … 1 | [0.5, 0.5] | ○ | 0..1 from the top left; a dot to drag on the preview; Point emitters only |
| `speed` | Travel Speed | float | -4 … 4 (step 0.05) | 1 | ○ | phased: integrated over time, single value only |
| `quantity` | Particles / Second | float | 100 … 20000 (step 100) | 4000 | ○ | How many the emitter puts out each second; at most 65,536 in flight, past which each newborn takes the place of one picked at random, so the flow thins evenly |
| `color` | Phosphor Color | color | RGB 0…1 | [1, 1, 1] | ○ |  |
| `trail` | Trail / Persistence | float | 0 … 1 (step 0.02) | 0.25 | ○ |  |
| `spread` | Cone Spread | float | 0 … 360 (step 2) | 0 | ○ | Point (Directional Cone) only; section Advanced |
| `driver` | Speed Driver | enum | 0=Luminance, 1=Inverted Luma, 2=Saturation, 3=Edges, 4=Red, 5=Green, 6=Blue, 7=Hue | 0 (Luminance) | ○ | section Advanced |
| `slowdown` | Driver Slowdown | float | 0 … 3 (step 0.02) | 1.2 | ○ | section Advanced |
| `size` | Particle Size (px) | float | 1 … 8 (step 0.5) | 1 | ○ | section Advanced |
| `shape` | Particle Shape | enum | 0=Pixel (Square), 1=Phosphor (Circle Dot) | 0 (Pixel (Square)) | ○ | section Advanced |
| `brightness` | Brightness | float | 0.2 … 4 (step 0.05) | 1.5 | ○ | section Advanced |
| `mode` | Output Mode | enum | 0=CRT Phosphor (Black BG), 1=Source Tinted (Black BG), 2=Inverted Ink (White BG), 3=Overlay on Source | 0 (CRT Phosphor (Black BG)) | ○ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ○ | injected Mix: crossfade against the input |

#### Phase Modulation

id `velocityMod` · [velocityMod.ts](src/engine/modules/velocityMod.ts) · animated when `params.speed !== 0`

Summary: Draws rolling raster lines, dots, dashes or a grid that the picture pushes sideways.

> Phase Modulation: rolling raster lines whose phase is offset by the
> picture, pixel by pixel.
>
>   phase = Lines * y - Depth * driver - ripple
>
> with y across the lines -- down the frame for horizontal lines, along
> it for vertical ones.
>
> The offset depends on the driver at this pixel and nothing else, which
> is what makes it PM rather than FM: lines bend where the picture is
> bright and are back on the carrier's grid wherever it is dark again.
> Depth is in cycles -- 1 moves a line onto the next one's place -- so it
> means the same at any line count. Frequency Modulation is the
> integrating counterpart, where a bright patch shifts everything after it.
>
> Pattern is what the beam draws on each line: a solid line, round dots,
> dashes, or a grid (the lines crossed by as many again the other way,
> bent by the same offset). Density counts dots or dashes across the
> frame. Dots once rode on the lines whatever their density, merging into
> solid line where the driver was bright; old documents read Dots (and a
> Density of 0 still draws plain lines), a new module starts on Lines.
>
> How it works:
>
> Kept as id `velocityMod` so saved documents still find it. It used to
> have a Slowdown that multiplied the line density by the driver; density
> times position is neither PM nor FM -- its effect grew towards the
> bottom of the frame and tore lines at every edge -- so it is gone, and
> Deflection became Depth.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `driver` | Driver | enum | 0=Luminance, 1=Inverted Luma, 2=Saturation, 3=Edges, 4=Red, 5=Green, 6=Blue, 7=Hue | 0 (Luminance) | ◇ |  |
| `pattern` | Pattern | enum | 0=Lines, 1=Dots, 2=Dashes, 3=Grid | 1 (Dots) | ◇ | a new module starts on Lines; old documents read Dots, as they looked |
| `lines` | Lines | float | 20 … 250 (step 2) | 100 | ◇ |  |
| `depth` | Depth | float | -8 … 8 (step 0.05) | 2 | ◇ |  |
| `ripple` | Ripple | float | 0 … 2 (step 0.01) | 0.6 | ◇ |  |
| `speed` | Roll Speed | float | -3 … 3 (step 0.05) | 1 | ○ | phased: integrated over time, single value only |
| `color` | Color | color | RGB 0…1 | [1, 1, 1] | ◇ |  |
| `axis` | Axis | enum | 0=Horizontal Lines, 1=Vertical Lines | 0 (Horizontal Lines) | ◇ | section Advanced |
| `lineWidth` | Line Width | float | 0.5 … 3.5 (step 0.1) | 1.2 | ◇ | section Advanced |
| `frequency` | Ripple Freq | float | 5 … 100 (step 1) | 35 | ◇ | section Advanced |
| `dotDensity` | Density | float | 0 … 150 (step 1) | 45 | ◇ | dots or dashes across the frame; only with Dots or Dashes; section Advanced |
| `brightness` | Brightness | float | 0.5 … 2.5 (step 0.05) | 1.4 | ◇ | section Advanced |
| `shadowFade` | Shadow Fade | float | 0 … 1 (step 0.02) | 0.2 | ◇ | section Advanced |
| `baseBrightness` | Shadow Lines | float | 0 … 0.3 (step 0.01) | 0.05 | ◇ | section Advanced |
| `mode` | Mode | enum | 0=Additive Glow, 1=Source Shaded, 2=Inverted Ink, 3=Overlay | 0 (Additive Glow) | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Roll

id `roll` · [roll.ts](src/engine/modules/roll.ts) · animated when `params.speed !== 0`

Summary: Makes the picture roll vertically, like a TV losing vertical hold.

> The picture sliding vertically through the frame, with the sync seam
> visible where it wraps -- a set that has lost vertical hold.
>
> The seam is the point of the module. Scrolling alone just looks like a
> pan; the dark torn line arriving with it is what says the signal has
> slipped rather than the camera moved.
>
> Offset parks the roll at a chosen position, so the seam can be placed
> deliberately with Speed at zero.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `speed` | Speed | float | -2 … 2 (step 0.005) | 0.1 | ○ | phased: integrated over time, single value only |
| `offset` | Offset | float | 0 … 1 (step 0.005) | 0 | ◇ |  |
| `seam` | Seam Width | float | 0 … 0.2 (step 0.002) | 0.02 | ◇ |  |
| `darkness` | Seam Darkness | float | 0 … 1 (step 0.01) | 0.8 | ◇ |  |

#### Rutt-Etra

id `ruttEtra` · [ruttEtra.ts](src/engine/modules/ruttEtra.ts) · animated when `params.speed !== 0` · 2 passes

Summary: Turns the picture into raised scanlines, like the Rutt-Etra video synthesizer; with Occlusion, a ridgeline relief like the Unknown Pleasures cover.

> Rutt-Etra / raster deflection video synthesizer effect.
>
> Emulates the iconic 1970s analog scan-processor (Steve Rutt & Bill Etra),
> converting video into horizontal electron-beam scanlines deflected vertically
> by luminance and modulated by a high-frequency carrier wave ripple.
>
> Occlusion turns the scan into a relief (the Unknown Pleasures cover): lines
> lower on the picture are nearer, and each line hides what lies behind it
> under its curve, as if every line were painted far to near with the ground
> filled in beneath it. Carrier breaks the beam into pulses where the picture
> is dark (solid from about two-thirds luma up), Beam Cutoff turns it off
> entirely below a brightness, and Smoothing smooths the brightness along
> the beam only, so a line settles without bleeding into its neighbours.
>
> How it works:
>
> Two passes: the first is the smoothing (a horizontal tent, an exact copy at
> Smoothing 0), the second the scan itself.

Deflection is `(luma - bias) * deflection` plus the ripple; positive pushes bright parts up. Occlusion is an amount: at 1 a line hides everything behind it under its curve, in between the lines behind show through partly; its ground follows Beam Cutoff (no beam, no ground) but not the dot break, so a dotted ridge still hides what is behind it. Smoothing's radius is up to 4% of the picture's width, and every reading of the luma (deflection, ripple, dot break, cutoff) uses the smoothed one, so Beam Cutoff softens as Smoothing rises. Dot Break and the ripple drift with Speed. A line is drawn by its distance across the curve (the vertical distance over √(1 + slope²), the slope capped at 8), so steep stretches stay one solid stroke instead of dashes.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `deflection` | Deflection | float | -0.3 … 0.3 (step 0.005) | 0.09 | ◇ |  |
| `lines` | Lines | float | 20 … 350 (step 2) | 120 | ◇ |  |
| `occlusion` | Occlusion | float | 0 … 1 (step 0.01) | 0 | ◇ | lower lines are nearer and hide the lines behind under their curve |
| `speed` | Speed | float | -4 … 4 (step 0.05) | 1 | ○ | phased: integrated over time, single value only |
| `brightness` | Brightness | float | 0.5 … 3 (step 0.05) | 1.4 | ◇ |  |
| `mode` | Mode | enum | 0=Additive Glow, 1=Source Shaded, 2=Inverted Ink, 3=Overlay | 0 (Additive Glow) | ◇ |  |
| `color` | Color | color | RGB 0…1 | [1, 1, 1] | ◇ |  |
| `lineWidth` | Line Width | float | 0.5 … 4 (step 0.1) | 1.2 | ◇ | section Beam |
| `smoothing` | Smoothing | float | 0 … 1 (step 0.01) | 0 | ◇ | section Beam; low-pass of the luma along the beam, radius up to 4% of the width |
| `bias` | Bias | float | 0 … 1 (step 0.01) | 0 | ◇ | section Beam; the luma that deflects to zero |
| `cutoff` | Beam Cutoff | float | 0 … 0.6 (step 0.005) | 0 | ◇ | section Beam; no beam below this luma (0 = always on) |
| `baseBrightness` | Shadow Lines | float | 0 … 0.4 (step 0.01) | 0.06 | ◇ | section Beam |
| `carrier` | Dot Break | float | 0 … 1 (step 0.01) | 0 | ◇ | section Carrier; the beam breaks into pulses in the dark (duty 1 - amount at black, solid from luma 2/3) |
| `pulses` | Pulses | float | 10 … 400 (step 1) | 120 | ◇ | section Carrier; dot-break cycles across the width |
| `ripple` | Ripple | float | 0 … 0.05 (step 0.001) | 0.015 | ◇ | section Carrier |
| `frequency` | Ripple Freq | float | 5 … 150 (step 1) | 45 | ◇ | section Carrier |
| `spread` | Ripple Spread | float | 0 … 1 (step 0.01) | 0.25 | ◇ | section Carrier |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Scanlines

id `scanlines` · [scanlines.ts](src/engine/modules/scanlines.ts) · animated when `params.roll !== 0`

Summary: Adds the dark lines between a CRT's scanlines.

> Horizontal scanline darkening.
>
> Density is a count of lines down the whole picture, the way a CRT is
> described, rather than a pitch in pixels. Pixels here would be working
> pixels -- a frame of up to 2048 that is never shown at that size -- so a
> pitch in them looked different on every photo and, at the small end,
> was finer than the viewer could draw at all. A count looks the same on
> any photo in any viewer. Lines too dense for a small viewer average out
> to the tint they would really make, and come back as it is enlarged.
>
> Thickness is relative to the line, so it needs no unit: it shapes each
> cycle, and the lines can be as dense as you like without it changing
> meaning.
>
> Roll is the slow vertical drift of an unlocked vertical hold. At zero the
> module is a still image,
>
> How it works:
>
> That is why `animated` is a function -- a parked scanline node should not
> pin a frame loop for the whole session.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `lines` | Lines | float | 20 … 1080 (step 1) | 240 | ◇ |  |
| `thickness` | Thickness | float | 0.1 … 4 (step 0.05) | 1 | ◇ |  |
| `darkness` | Darkness | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `roll` | Roll | float | -5 … 5 (step 0.05) | 0 | ○ | phased: integrated over time, single value only |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Shadow Mask

id `shadowMask` · [shadowMask.ts](src/engine/modules/shadowMask.ts) · static

Summary: Adds the red, green and blue dot pattern of a CRT screen.

> The RGB pattern a tube's aperture lifts off the phosphor.
>
> The 1.6 gain is a partial brightness repay. A mask whose average is 0.5
> halves the picture, and the three types do not all average the same, so
> the compensation is deliberately approximate -- follow with Levels.
>
> How it works:
>
> Built from three phase-shifted cosines rather than hard stripes: a
> pattern this fine aliases badly against the pixel grid, and a smooth one
> degrades into an even tint as it goes sub-pixel instead of into moire.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `type` | Type | enum | 0=Grille, 1=Slot, 2=Dot | 0 (Grille) | ◇ |  |
| `pitch` | Pitch | float | 1 … 24 (step 0.5) | 3 | ◇ |  |
| `strength` | Strength | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Sub-pixels

id `subpixels` · [subpixels.ts](src/engine/modules/subpixels.ts) · static

Summary: Shows the picture as screen sub-pixels: LCD, OLED, old handhelds.

> Screen sub-pixel simulation for LCD, OLED, and retro handheld displays.
>
> Divides each pixel cell into physical red, green, and blue sub-pixel
> emitters separated by a dark matrix grid.
>
> Supports standard RGB and BGR vertical stripes, staggered RGB Delta triads,
> and 2x2 Bayer grids. When Pixelate is active, the image is quantized to
> physical screen cells so each sub-pixel samples from its parent pixel.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `size` | Pixel Size | float | 1 … 48 (step 0.5) | 6 | ◇ |  |
| `pattern` | Pattern | enum | 0=RGB Stripe, 1=BGR Stripe, 2=RGB Delta, 3=Bayer Grid | 0 (RGB Stripe) | ◇ |  |
| `gap` | Gap | float | 0 … 0.5 (step 0.01) | 0.15 | ◇ |  |
| `bleed` | Bleed | float | 0 … 0.5 (step 0.01) | 0.1 | ◇ |  |
| `boost` | Brightness | float | 1 … 3 (step 0.05) | 1.8 | ◇ |  |
| `pixelate` | Pixelate | bool | on / off | true | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

### Tape & Glitch

#### Block Glitch

id `blockGlitch` · [blockGlitch.ts](src/engine/modules/blockGlitch.ts) · animated when `params.speed !== 0 && params.intensity !== 0`

Summary: Breaks the picture into torn, displaced compression blocks.

> MPEG macroblocking / compression glitch and datamosh tearing.
>
> Quantizes image into compression blocks and displaces random macroblocks
> in discrete frame bursts with chromatic channel separation.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `blockSize` | Block Size | float | 8 … 64 (step 2) | 24 | ◇ |  |
| `intensity` | Intensity | float | 0 … 1 (step 0.01) | 0.4 | ◇ |  |
| `colorShift` | Color Drift | float | 0 … 1 (step 0.01) | 0.3 | ◇ |  |
| `speed` | Speed | float | -2 … 2 (step 0.05) | 0.6 | ○ | phased: integrated over time, single value only |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Chroma Bleed

id `chromaBleed` · [chromaBleed.ts](src/engine/modules/chromaBleed.ts) · static

Summary: Smears the colour sideways while keeping detail sharp, like VHS tape.

> Luma sharp, chroma smeared sideways -- the single most recognisable thing
> about tape.
>
> It is not a blur of the picture: the format gave colour far less
> bandwidth than brightness, so edges stay crisp while the colour runs past
> them. This reconstructs that directly -- brightness is taken from the
> untouched pixel, colour from a horizontally blurred one.
>
> Offset slides the colour relative to the brightness, which is the other
> half of the look: the red of a jacket arriving a few pixels late.
>
> How it works:
>
> Single pass, since the bleed only ever runs along the scan direction.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `width` | Width | float | 0 … 64 (step 0.5) | 12 | ◇ |  |
| `offset` | Offset | float | -32 … 32 (step 0.5) | 0 | ◇ |  |
| `saturation` | Saturation | float | 0 … 2 (step 0.01) | 1 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Compression

id `compression` · [compression.ts](src/engine/modules/compression.ts) · static · 5 passes

Summary: Adds real JPEG or MPEG compression blocks and artifacts.

> Block compression, done the way a JPEG or an MPEG intra frame does it
> rather than faked with blocky noise.
>
> The picture goes to YCbCr, the colour is shared between neighbouring
> samples (Chroma: 4:2:0 gives one colour per 2 x 2), and each 8 x 8 block
> of each channel is taken into frequencies with a DCT. Every frequency is
> then rounded to a step from the standard JPEG tables, scaled by Quality
> with the IJG formula -- which is the whole loss: fine detail and gentle
> gradients round to nothing, leaving flat blocks, banding and ringing
> round edges. The inverse DCT brings the blocks back.
>
> Block Scale is the size of one DCT sample in source pixels, so the
> blocks stay the same size in a preview and in the export -- down to one
> working pixel, below which the transform would skip samples.
>
> How it works:
>
> Five passes, each a sum of eight samples: the DCT is separable, so rows
> then columns, forward then back, with the quantising on the way through.
> Intermediate passes hand coefficients to each other in float targets.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `quality` | Quality | float | 1 … 100 (step 1) | 20 | ◇ |  |
| `scale` | Block Scale | float | 1 … 8 (step 0.5) | 1 | ◇ |  |
| `chroma` | Chroma | enum | 0=4:4:4, 1=4:2:2, 2=4:2:0, 3=4:1:1 | 2 (4:2:0) | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Dropouts

id `dropouts` · [dropouts.ts](src/engine/modules/dropouts.ts) · animated when `params.rate !== 0`

Summary: Adds white streaks where the tape lost contact.

> Streaks where the tape lost contact with the head.
>
> A dropout is a line of picture the deck never read: it flares white the
> moment the signal goes, then trails off as the demodulator recovers, so
> each streak is a comet with a hard head and a ragged, fading tail -- not
> a flat bar. Most are short and a few are long, so lengths are drawn from
> an exponential spread around Length rather than all alike. Flaking oxide
> tends to hit a few neighbouring lines at once, slightly skewed, which is
> what Clumping gives.
>
> Decks hide dropouts by repeating the line above (drop-out compensation);
> Compensation blends from a raw white streak toward that repeated line.
>
> Sized against the picture, not in pixels: Lines is how many rows the
> height is cut into and Length is a fraction of the width, so a streak is
> the same shape on any photo and in any viewer.
>
> How it works:
>
> A dash can start anywhere along its line. Each line is cut into cells four
> mean lengths wide, each holding at most one dash that may run on into the
> next cell, so a pixel only has to look at its own cell and the one before.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `density` | Density | float | 0 … 0.25 (step 0.001) | 0.008 | ◇ |  |
| `dash` | Length | float | 0.002 … 0.25 (step 0.001) | 0.03 | ◇ |  |
| `tail` | Tail | float | 0 … 1 (step 0.01) | 0.6 | ◇ |  |
| `clump` | Clumping | float | 0 … 1 (step 0.01) | 0.35 | ◇ |  |
| `compensation` | Compensation | float | 0 … 1 (step 0.01) | 0 | ◇ |  |
| `lines` | Lines | float | 20 … 1080 (step 1) | 360 | ◇ |  |
| `rate` | Rate | float | 0 … 60 (step 1) | 30 | ○ | phased: integrated over time, single value only |
| `color` | Color | color | RGB 0…1 | [1, 1, 1] | ◇ |  |

#### Glitch Machine

id `glitchMachine` · [glitchMachine.ts](src/engine/modules/glitchMachine.ts) · animated when `params.rate !== 0 && params.intensity !== 0`

Summary: Throws random digital and datamosh glitches at the picture.

> Digital and Datamosh Glitch Synthesizer.
>
> Rhythmic burst engine driving macroblock compression shearing, predictive motion
> tearing, channel permutation / solarization, and bitcrush downsampling.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `rate` | Burst Rate | float | 0 … 5 (step 0.05) | 1.5 | ○ | phased: integrated over time, single value only |
| `intensity` | Intensity | float | 0 … 1 (step 0.01) | 0.6 | ◇ |  |
| `blockSize` | Block Size | float | 4 … 64 (step 2) | 16 | ◇ |  |
| `shearing` | Shearing | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `colorCorrupt` | Color Corrupt | float | 0 … 1 (step 0.01) | 0.4 | ◇ |  |
| `bitcrush` | Bitcrush | float | 0 … 1 (step 0.01) | 0.3 | ◇ |  |
| `pattern` | Pattern | float | 0 … 1 (step 0.01) | 0 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Head Switch

id `headSwitch` · [headSwitch.ts](src/engine/modules/headSwitch.ts) · animated when `params.rate !== 0`

Summary: Adds the torn band at the bottom of a VHS frame.

> The torn band along the bottom of the frame where a helical-scan deck
> changes heads mid-picture.
>
> It sits at the bottom because that is where the switch happens.
>
> What a capture actually shows: a clean tear line, under it the picture
> pushed sideways line by line -- timing error that builds toward the
> bottom, so the last lines hook hardest (Bend) -- and the blanking pulled
> into view as a black edge where the picture has slid away. The colour
> there comes out wrong or not at all, and the noise runs in horizontal
> streaks along the lines, as anything carried on a scanline does.
>
> The band is cut into tape lines, counted at a field's 480 whatever the
> picture's size, and everything in it -- the switch point, the shift,
> each line's jitter -- is drawn afresh every field, at Rate.
>
> How it works:
>
> In the code, `v_uv.y` is 0 there -- the bitmap is uploaded in GL
> orientation, so the band is low values, not high.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `height` | Height | float | 0.005 … 0.3 (step 0.005) | 0.04 | ◇ |  |
| `amount` | Shift | float | 0 … 0.5 (step 0.005) | 0.06 | ◇ |  |
| `bend` | Bend | float | 0 … 1 (step 0.01) | 0.6 | ◇ |  |
| `jitter` | Jitter | float | 0 … 1 (step 0.01) | 0.3 | ◇ |  |
| `colorLoss` | Color Loss | float | 0 … 1 (step 0.01) | 0.6 | ◇ |  |
| `noise` | Noise | float | 0 … 1 (step 0.01) | 0.4 | ◇ |  |
| `rate` | Rate | float | 0 … 60 (step 1) | 30 | ○ | phased: integrated over time, single value only |
| `edge` | Edge | enum | 0=Clamp, 1=Wrap, 2=Black, 3=Mirror, 4=Color | 2 (Black) | ◇ | section Advanced |
| `background` | Background | color | RGB 0…1 | [0, 0, 0] | ◇ | active when `params.edge === 4`; section Advanced |

#### Hum Bar

id `humBar` · [humBar.ts](src/engine/modules/humBar.ts) · animated when `params.speed !== 0`

Summary: Rolls a soft brightness band up the picture, like mains hum.

> A soft brightness band drifting up the picture -- mains hum beating
> against the frame rate.
>
> Intensity is bipolar because both exist: a dark bar is interference in
> the signal, a bright one is interference in the supply.
>
> The band is measured on a wrapped coordinate, so it leaves the top and
> re-enters at the bottom in one continuous move with no jump at the seam.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `width` | Width | float | 0.01 … 0.5 (step 0.005) | 0.15 | ◇ |  |
| `speed` | Speed | float | -1 … 1 (step 0.005) | 0.06 | ○ | phased: integrated over time, single value only |
| `intensity` | Intensity | float | -1 … 1 (step 0.01) | 0.2 | ◇ |  |

#### Line Jitter

id `lineJitter` · [lineJitter.ts](src/engine/modules/lineJitter.ts) · animated when `params.rate !== 0`

Summary: Shifts lines sideways at random, like a tape losing tracking.

> Per-line horizontal displacement -- tape tracking that has lost its grip.
>
> The distinguishing feature of tracking error against a smooth wobble is
> that it is discontinuous: whole scanlines tear sideways independently of
> the lines either side of them, and only some lines go at once. Density is
> that "only some" -- at 1.0 every line tears, which reads as static rather
> than as a tape fault.
>
> Lines is how many bands the height is cut into, rather than a band
> height in pixels, for the reason Scanlines gives.
>
> Held for whole steps at Rate rather than redrawn per frame, because tape
> damage is a property of the tape and should persist for a beat, not boil
> at the monitor's refresh.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `amount` | Amount | float | 0 … 0.2 (step 0.001) | 0.02 | ◇ |  |
| `lines` | Lines | float | 10 … 1080 (step 1) | 240 | ◇ |  |
| `density` | Density | float | 0 … 1 (step 0.01) | 0.3 | ◇ |  |
| `rate` | Rate | float | 0 … 60 (step 1) | 12 | ○ | phased: integrated over time, single value only |
| `edge` | Edge | enum | 0=Clamp, 1=Wrap, 2=Black, 3=Mirror | 0 (Clamp) | ◇ |  |

#### Pixel Sort

id `pixelSort` · [pixelSort.ts](src/engine/modules/pixelSort.ts) · static · 92 passes

Summary: Sorts runs of pixels by brightness into long streaks.

> Pixel sorting: runs of pixels whose value falls in a range are sorted
> along the row (or column), the rest left where they are.
>
> How it works:
>
> Done exactly, on the GPU, in one frame, as a chain of passes over a float
> scratch picture holding (segment start, original index, key, in range)
> per pixel:
>
>  1. Init -- each pixel's key, and whether it starts a run: its own index
>     where its in-range state differs from the pixel before, else -1.
>  2. Scan -- a running max with doubling steps, after which every pixel
>     holds the start of its run. The last step cuts runs into Max Length
>     pieces, and gives each pixel outside the range a segment of its own.
>  3. Sort -- a bitonic network over the whole row, ordering by (segment
>     start, key, original index). Segments are contiguous and already in
>     order, so sorting by their start first keeps every pixel inside its
>     own run. It is the all-ascending variant, where a position past the
>     end of the row counts as +infinity and so never has to be stored --
>     which is what lets a width that is not a power of two sort.
>  4. Resolve -- each pixel fetches the colour its sorted entry came from.
>
> The network is sized for rows up to 4096 pixels; longer rows sort in
> 4096-pixel pieces. Every pass reads its step from `u_pass`, so all of
> them are the same text and the pipeline compiles it once. Indices are
> exact in full float; on a GPU with only half-float targets they are exact
> up to 2048, beyond which long rows sort slightly out of place.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `direction` | Direction | enum | 0=Horizontal, 1=Vertical | 0 (Horizontal) | ◇ |  |
| `sortBy` | Sort By | enum | 0=Brightness, 1=Hue, 2=Saturation, 3=Red, 4=Green, 5=Blue | 0 (Brightness) | ◇ |  |
| `order` | Order | enum | 0=Ascending, 1=Descending | 0 (Ascending) | ◇ |  |
| `lower` | Lower | float | 0 … 1 (step 0.01) | 0.25 | ◇ |  |
| `upper` | Upper | float | 0 … 1 (step 0.01) | 0.8 | ◇ |  |
| `invert` | Invert Range | bool | on / off | false | ◇ |  |
| `maxLength` | Max Length | float | 1 … 4096 (step 1) | 4096 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Signal Rot

id `signalRot` · [signalRot.ts](src/engine/modules/signalRot.ts) · animated when `params.decay !== 0 && (params.noise !== 0 || params.syncLoss !== 0 || params.rate !== 0)`

Summary: Decays the picture like a weak analog signal or a tape copied too many times.

> Analog RF signal rot and multi-generation composite tape decay.
>
> Models RF multipath ghosting reflections, high-frequency smear & overshoot ringing,
> NTSC subcarrier hue drift, horizontal scanline sync slippage, and carrier noise.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `decay` | Decay | float | 0 … 1 (step 0.01) | 0.4 | ◇ |  |
| `ghosting` | Ghosting | float | 0 … 1 (step 0.01) | 0.3 | ◇ |  |
| `smear` | HF Smear | float | 0 … 1 (step 0.01) | 0.35 | ◇ |  |
| `colorDrift` | Hue Drift | float | -1 … 1 (step 0.02) | 0.2 | ◇ |  |
| `syncLoss` | Sync Loss | float | 0 … 1 (step 0.01) | 0.25 | ◇ |  |
| `noise` | Carrier Noise | float | 0 … 1 (step 0.01) | 0.2 | ◇ |  |
| `rate` | Rate | float | 0 … 3 (step 0.05) | 1 | ○ | phased: integrated over time, single value only |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

### Noise & Grain

#### Film Damage

id `filmDamage` · [filmDamage.ts](src/engine/modules/filmDamage.ts) · animated when `params.rate !== 0`

Summary: Makes the picture an old film print: weave, flicker, dust and scratches.

> The picture as a worn film print running through a projector: the frame
> weaving in the gate, the exposure flickering, and dust, hairs and
> scratches riding along on the film.
>
> Everything that belongs to one frame of film is held for that frame, at
> Frame Rate, as Grain is: dust and hairs are new every frame, so they
> flash past rather than crawl. Scratches are different -- they are cut
> along the length of the reel -- so each stays put for a run of frames,
> drifting a little sideways and breaking up along its length, before
> the reel moves past it.
>
> Gate weave is the film never sitting in exactly the same place: a slow
> wander plus a small jolt every frame. Flicker is the exposure of each
> frame differing a little, and a little across the frame too.
>
> Dust on the print shows dark; dust on the negative it was printed from
> shows light, because there it blocked the light that would have
> exposed the print. Polarity picks either or a mix. Base-side scratches
> are light, emulsion scratches dark. Sizes are in source pixels.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `rate` | Frame Rate | float | 0 … 60 (step 1) | 24 | ○ | phased: integrated over time, single value only |
| `weave` | Gate Weave | float | 0 … 10 (step 0.1) | 1.5 | ◇ |  |
| `flicker` | Flicker | float | 0 … 1 (step 0.01) | 0.3 | ◇ |  |
| `dust` | Dust | float | 0 … 1 (step 0.01) | 0.4 | ◇ |  |
| `hairs` | Hairs | float | 0 … 1 (step 0.01) | 0.2 | ◇ |  |
| `scratches` | Scratches | float | 0 … 1 (step 0.01) | 0.3 | ◇ |  |
| `polarity` | Dust Polarity | enum | 0=Dark (on the print), 1=Light (on the negative), 2=Mixed | 2 (Mixed) | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Grain

id `grain` · [grain.ts](src/engine/modules/grain.ts) · animated when `params.rate !== 0`

Summary: Adds film or sensor grain.

> Additive film/sensor grain.
>
> Quantised to cells so Size is a real grain size rather than a blur of
> per-pixel noise, and held for whole frames at Rate so the grain reads as
> film running at a frame rate instead of boiling at the monitor's refresh.
>
> How it works:
>
> `u_seed` is mixed in so two grain modules in one chain -- one coarse, one
> fine -- do not lay down the identical dirt on top of itself.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `amount` | Amount | float | 0 … 0.5 (step 0.005) | 0.08 | ◇ |  |
| `size` | Size | float | 1 … 8 (step 0.5) | 1 | ◇ |  |
| `rate` | Rate | float | 0 … 60 (step 1) | 24 | ○ | phased: integrated over time, single value only |
| `mono` | Monochrome | bool | on / off | true | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Sensor Noise

id `sensorNoise` · [sensorNoise.ts](src/engine/modules/sensorNoise.ts) · animated when `params.rate !== 0`

Summary: Adds the noise of a digital camera in the dark: phones at night, webcams, CCTV.

> A digital camera pushed into the dark: phone footage at night, a webcam,
> a security camera. Grain is film's noise; this is a sensor's.
>
> - Noise is added in linear light and grows with the square root of the
>   signal (photon noise) on top of a floor (read noise). Taken back to
>   the screen's gamma, that makes it heaviest in the shadows, as it is.
> - Chroma noise comes in blotches a few pixels across, left by the
>   sensor's colour filter and the camera's demosaicing.
> - Banding is fixed-pattern noise: rows and columns a touch off from
>   each other, and the rows wandering frame to frame. Only visible where
>   it is dark, as on a real sensor.
> - Hot pixels are the stuck ones: single pixels lit in one colour,
>   always in the same place.
>
> The noise changes Rate times a second; 0 freezes it. Sizes are in
> source pixels.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `amount` | Amount | float | 0 … 1 (step 0.01) | 0.35 | ◇ |  |
| `chromaNoise` | Chroma Noise | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `size` | Grain Size | float | 1 … 4 (step 0.5) | 1 | ◇ |  |
| `banding` | Banding | float | 0 … 1 (step 0.01) | 0.15 | ◇ |  |
| `hotPixels` | Hot Pixels | float | 0 … 1 (step 0.01) | 0.1 | ◇ |  |
| `rate` | Rate | float | 0 … 60 (step 1) | 30 | ○ | phased: integrated over time, single value only |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

### Temporal

#### Datamosh

id `datamosh` · [datamosh.ts](src/engine/modules/datamosh.ts) · animated · feedback (reads its own last frame)

Summary: Drags old pixels along with new motion, like a video with missing keyframes.

> Datamosh, approximated: the last frame's pixels dragged along with the
> movement in the new one, in square blocks, instead of the new frame
> being shown -- the smear a video gets when its keyframes are cut out and
> motion is applied to a picture it was never meant for.
>
> Leak lets the live picture seep back in, per second. Keyframe snaps back
> to the live picture on a timer, as a codec's I-frame does; 0 never does.
> With the clock stopped every redraw shows the live picture, so an edit
> upstream is never lost under a held smear.
>
> How it works:
>
> A real datamosh replays the codec's own motion vectors, which a live
> picture does not have. Here each block estimates its own: one step of
> gradient optical flow at the block's centre, v = -It grad I / (|grad I|^2
> + Smoothing). And it estimates it against this node's previous output,
> not a clean previous frame -- so once the picture has started to drift,
> its errors feed the next estimate and compound, which is where the
> melting look comes from.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `blockSize` | Block Size | float | 4 … 64 (step 1) | 16 | ◇ |  |
| `strength` | Strength | float | 0 … 4 (step 0.01) | 1.5 | ◇ |  |
| `leak` | Leak | float | 0 … 1 (step 0.01) | 0.05 | ◇ |  |
| `keyframe` | Keyframe (s) | float | 0 … 10 (step 0.1) | 4 | ◇ |  |
| `smoothing` | Smoothing | float | 0.01 … 10 (step 0.01) | 1 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Echo

id `echo` · [echo.ts](src/engine/modules/echo.ts) · animated · feedback (reads its own last frame)

Summary: Lays a shifted ghost of the last frame over the picture.

> A displaced copy of the previous frame, laid back over this one -- the
> multipath ghost of an aerial picking the same signal up twice.
>
> Because the ghost is taken from this node's own output, each frame's copy
> is offset again from the last. One offset knob gives a receding stack of
> ghosts rather than a single duplicate, which is what the real artefact
> looks like.
>
> Persistence is a time -- how long until a ghost has faded to a tenth -- so
> the slider is linear in how far the stack reaches.
>
> Keeping the brighter of the two rather than crossfading leaves the live
> picture crisp with the ghosts trailing off it, which is what multipath
> looks like; a crossfade would instead fade the picture itself out behind
> its own history.
>
> How it works:
>
> Expressed as a per-frame multiplier instead, every useful value sits in
> the last few hundredths of the travel.
>
> There is deliberately no separate strength: the ghost is fed back through
> this same node, so anything scaling it compounds frame after frame and
> becomes another decay control. Two knobs that both set the decay rate is
> one knob and a lie.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `offset` | Offset | vec2 | x,y ∈ -64 … 64 | [8, 0] | ◇ |  |
| `persistence` | Persistence (s) | float | 0.05 … 4 (step 0.05) | 0.5 | ◇ |  |

#### Feedback

id `feedbackLoop` · [feedbackLoop.ts](src/engine/modules/feedbackLoop.ts) · animated · extra picture inputs: `loop` (Target: a loop input, wired from downstream, read as last frame's picture)

Summary: Closes a loop through the graph: a module further down wired back into Target comes out here a frame later.

> A loop through the graph, as TouchDesigner's Feedback TOP makes one: wire
> a module further down back into Target, and this puts out what that module
> made last frame. Everything between runs once a frame on its own result,
> so a Displace, an Edge Detect and a Levels in the loop grow into a
> reaction rather than a still.
>
> The main input is the seed: what the loop starts from on the first frame
> and after a seek or a loop of the comp, while nothing has come back yet.
> Seed Mix pours some of it back in every frame (per second at 60 fps, so
> the same at any frame rate), which keeps a loop that drifts tied to it.
> Seed Mode is how it goes back in: Cross fades between the two, as
> TouchDesigner's Cross TOP; Over fades what came back by Seed Mix and lays
> it over the seed, as a Level's Opacity into an Over TOP does, so the seed
> shows wherever the loop is transparent (the same as Cross while both are
> opaque); Add adds the seed on top, as an Add TOP feeding a loop does, so
> something else in the loop has to fade it or it climbs to white.
>
> Reset, as TouchDesigner's: while it is above 0.5 the seed goes out instead
> of what came back, so the loop starts over from it. A number rather than a
> toggle so a Pulse, an Onset, a Beat or keys can drive it, which sets the
> rhythm the loop restarts to. Read once a frame, so a pulse shorter than a
> frame can be missed.
>
> How it works:
>
> It breaks the loop in time, which is what lets the graph allow it: the
> picture coming back is last frame's, kept by the pipeline (`Step.loop`),
> so each frame is still drawn front to back.
>
> The picture kept is clamped to 0..1 as every feedback history is, and kept
> in half float where the GPU has it.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `seedMix` | Seed Mix | float | 0 … 1 (step 0.001) | 0 | ◇ | share of the seed mixed back in per 1/60 s |
| `seedMode` | Seed Mode | enum | 0=Cross, 1=Over, 2=Add | 0 (Cross) | ◇ | how the seed goes back in: crossfade, the loop faded over it, or added on top |
| `reset` | Reset | float | 0 … 1 (step 1) | 0 | ◇ | above 0.5 the loop starts over from the seed; wire a Pulse for a rhythm |

#### Flames

id `flames` · [flames.ts](src/engine/modules/flames.ts) · animated · 2 passes · feedback (reads its own last frame)

Summary: Makes the picture's bright parts rise and burn like flames.

> Rising thermal feedback: the frame before this one buoyed upward by heat,
> whipped into licking tongues by convective turbulence, and cooled through
> a blackbody thermal gradient.
>
> Like Echo, it reads its own previous flame field (not the composite) to
> build a receding stack of ghost frames. Frame Step sets the pixel spacing
> between successive flame frames: a small step stacks frames densely into a
> continuous fluid plume, while a large step separates them into distinct,
> stepped flame echoes.
>
> Steps samples the last frame at that many points along this frame's rise,
> drift and turbulence and averages them, as in Tunnel: at 1 each flame
> ghost keeps crisp contours; more steps smear the ghosts along their own
> motion into a soft, continuous plume.
>
> Cooling is differential across channels rather than a flat dimming: as
> heat radiates away, blue drops first (white-hot core to golden yellow),
> green drops next (yellow to burning orange, then crimson), and red lingers
> longest as dark smoky embers before extinguishing.
>
> How it works:
>
> The step is measured per 1/60 s rather than per frame, so the rise speed
> does not depend on the frame rate, and a paused redraw does not move it.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `intensity` | Intensity | float | 0.2 … 3 (step 0.05) | 1 | ◇ |  |
| `palette` | Palette | enum | 0=Inferno, 1=Blue, 2=Acid, 3=Ghost | 0 (Inferno) | ◇ |  |
| `turbulence` | Turbulence | float | 0 … 2 (step 0.02) | 0.5 | ◇ |  |
| `wind` | Wind | float | -1 … 1 (step 0.02) | 0 | ◇ |  |
| `persistence` | Persistence (s) | float | 0.05 … 4 (step 0.05) | 0.8 | ◇ |  |
| `speed` | Speed | float | 0.05 … 2 (step 0.01) | 0.4 | ○ | phased: integrated over time, single value only |
| `blend` | Blend | enum | 0=Max, 1=Add, 2=Flame Only | 0 (Max) | ◇ |  |
| `step` | Frame Step | float | 1 … 64 (step 0.5) | 4 | ◇ | section Advanced |
| `steps` | Steps | int | 1 … 16 | 4 | ◇ | section Advanced |

#### Frame Hold

id `frameHold` · [frameHold.ts](src/engine/modules/frameHold.ts) · animated · 2 passes · feedback (reads its own last frame)

Summary: Lowers the frame rate so motion steps: stop motion, choppy webcams.

> Holds each frame for a while before taking the next, so motion steps at
> Hold FPS instead of running smooth: stop-motion, a choppy webcam, a
> low-frame-rate music video. Strobe adds flashes on a beat of its own.
>
> The strobe is drawn after the hold, so a flash is never the frame that
> gets held. Strobe Rate is phased -- changing it mid flash never jumps
> the beat.
>
> With the clock stopped -- paused, or scrubbing -- every redraw takes a
> fresh frame, so an edit upstream shows instead of a stale held picture.
>
> How it works:
>
> Two passes, and the first is the one kept as history: it takes a fresh
> frame when the clock crosses a hold boundary and otherwise hands back the
> one it kept.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `holdFps` | Hold FPS | float | 1 … 30 (step 0.5) | 6 | ◇ |  |
| `strobe` | Strobe | enum | 0=Off, 1=Black, 2=White, 3=Invert | 0 (Off) | ◇ |  |
| `rate` | Strobe Rate (Hz) | float | 0.1 … 30 (step 0.1) | 2 | ○ | phased: integrated over time, single value only; active when `params.strobe !== 0` |
| `duty` | Duty | float | 0 … 1 (step 0.01) | 0.15 | ◇ | active when `params.strobe !== 0` |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Freeze Frame

id `freezeFrame` · [freezeFrame.ts](src/engine/modules/freezeFrame.ts) · changes time for its branch · a **Playhead** button on the card sets At to the frame under the playhead

Summary: Freezes everything before it at one moment.

> Freeze Frame: its branch holds one moment. Everything upstream sees the
> time At, whatever the comp is doing, so a video stops on that frame and
> an LFO on the value it had then. Keys or a wire on At move the moment.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `at` | At (s) | float | 0 … 600 (step 0.01) | 0 | ◇ | typed as a number; read at the time reaching the module |

#### Ink Flow

id `inkFlow` · [inkFlow.ts](src/engine/modules/inkFlow.ts) · animated · 2 passes · feedback (reads its own last frame) · extra picture inputs: `pourMask` (Pour)

Summary: Carries the picture along curling currents like dye in water: swirls, marbling, ink plumes.

> The picture as dye in moving water: carried along curling currents frame
> after frame, so it winds into swirls, marbling and rolling plumes.
>
> The currents never pile up or thin out: like water, what flows into a
> place flows out of it, and the dye rolls into vortices instead of
> smearing outward. Each octave of Detail drifts its own way at
> Evolution's speed, so the field changes shape rather than sliding. Drift
> adds a steady current on top, for ink that sinks or rises.
>
> Persistence is how long the swirled dye lasts before the incoming
> picture has replaced it, as in Tunnel. A long one lets it dissolve into
> pure marbling. The Pour input pours the picture in faster where it is
> white (at Pour Rate): a matte, a shape, a moving spot -- ink dripping
> off a subject while the rest of the frame keeps swirling. A cut-out's
> ink spreads into its transparent background.
>
> How it works:
>
> The currents are curl noise -- the curl of a drifting noise field --
> which is why they never pile up or thin out. Each frame the last one is
> traced back along the current and the incoming picture is mixed back in.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `flow` | Flow | float | 0 … 2 (step 0.01) | 0.3 | ◇ | how fast the currents carry the dye |
| `scale` | Swirl Scale | float | 0.5 … 12 (step 0.1) | 3 | ◇ | higher, smaller swirls |
| `detail` | Detail | int | 1 … 4 | 2 | ◇ | octaves of smaller eddies |
| `speed` | Evolution | float | 0 … 2 (step 0.01) | 0.2 | ○ | phased: integrated over time, single value only; how fast the currents change shape |
| `drift` | Drift (/s) | vec2 | x,y ∈ -0.5 … 0.5 | [0, 0] | ◇ | a steady current, frames per second |
| `persistence` | Persistence (s) | float | 0.1 … 20 (step 0.1) | 4 | ◇ | time for the picture to replace the swirled dye |
| `pourRate` | Pour Rate | float | 0 … 20 (step 0.1) | 4 | ◇ | how fast Pour's white areas take the picture in; active when Pour is wired |

#### Motion Detect

id `motionDetect` · [motionDetect.ts](src/engine/modules/motionDetect.ts) · animated · 2 passes · feedback (reads its own last frame)

Summary: Shows only what moved since the last frame.

> What moved since the last frame: the difference between this frame and
> the one before, as a picture, a mask, a highlight over the picture, or
> the picture cut out to only what moves. Wired into a diamond port it is
> a field, so motion can drive any knob -- grain where things move, blur
> where they do not.
>
> How it works:
>
> Two passes, the first kept as history. It stores this frame's input in
> rgb, for the next frame to compare against, and the mask in alpha,
> faded by Fade the way Trails fades, so movement leaves a tail. The
> second draws the chosen output; every pass sees last frame's history as
> `u_prev`, so it can still work out the raw difference itself.
>
> Alpha holds the mask lifted off zero by one step, so an alpha of 0 only
> ever means the history is empty -- the very first frame, which would
> otherwise compare against black and read as all movement.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `threshold` | Threshold | float | 0 … 0.5 (step 0.005) | 0.06 | ◇ |  |
| `softness` | Softness | float | 0 … 0.5 (step 0.005) | 0.06 | ◇ |  |
| `gain` | Gain | float | 0.5 … 10 (step 0.1) | 2 | ◇ |  |
| `fade` | Fade (s) | float | 0 … 4 (step 0.05) | 0.4 | ◇ |  |
| `output` | Output | enum | 0=Difference, 1=Mask, 2=Highlight, 3=Cutout | 1 (Mask) | ◇ |  |
| `color` | Color | color | RGB 0…1 | [1, 0.2, 0.3] | ◇ | active when `params.output === 2` |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Motion Blur

id `motionBlur` · [motionBlur.ts](src/engine/modules/motionBlur.ts) · static · extra picture inputs: `vectors` (Motion Vectors)

Summary: Blurs the picture along per-pixel motion vectors from Optical Flow, controlled by Shutter Angle.

> Directional blur driven per-pixel by Optical Flow's Vectors output (0.5
> still, RG encoding velocity in source pixels up to Vector Range). When
> Motion Vectors is unwired, passes the picture through untouched.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `shutterAngle` | Shutter Angle (°) | float | 0 … 360 (step 1) | 180 | ◇ |  |
| `vectorRange` | Vector Range (px) | float | 1 … 64 (step 0.5) | 12 | ◇ | matches Optical Flow's Range (px) |
| `shutterPhase` | Shutter Phase | float | -0.5 … 0.5 (step 0.05) | 0 | ◇ | section Advanced |
| `samples` | Samples | int | 4 … 32 (step 1) | 16 | ◇ | section Advanced |
| `maxBlur` | Max Blur (px) | float | 1 … 256 (step 1) | 64 | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Optical Flow

id `opticalFlow` · [opticalFlow.ts](src/engine/modules/opticalFlow.ts) · animated · 5 passes · feedback (reads its own last frame)

Summary: Shows which way and how fast each part of the picture is moving, as a picture to drive other modules.

> How each part of the picture moved since the last frame, as a picture of
> vectors (TouchDesigner's Optical Flow TOP). Mostly a feeder: into Remap
> (Red / Green Vector) to smear the picture along its own motion,
> or into any diamond port as a field.
>
> The brightness is blurred first, by a fraction of Search Size, so detail
> finer than the solves' samples (leaves, spray) doesn't read as motion.
> Then Lucas-Kanade, twice: a coarse solve on a grid Search Size apart,
> which follows moves of about twice Search Size a frame, then a fine one
> on the last frame shifted by that estimate. Noise Floor damps the solve,
> so flat areas, where motion can't be seen, read still rather than wild.
>
> Smoothing blends each new estimate with the last.
>
> A solve's window is wider than an object's edge, so its motion spreads
> past it. Edge Snap averages each pixel's flow with its neighbours' of a
> like colour in the picture only, as it is drawn, so motion stops at the
> picture's edges; 0 draws the solve as it is.
>
> The flow is in source pixels per frame. Vectors: red right, green up, 0.5
> still, Range pixels to 0 or 1 (blue a flat 0.5). Speed: grey, Range pixels
> to white. Colour Wheel: hue the direction, brightness the speed.
>
> How it works:
>
> The fine solve is kept as history: the flow, and this frame's blurred
> brightness to compare the next against. Where nothing changed since the
> last frame (a video's repeated frame in a faster viewer, a paused clock)
> the last flow holds, fading over a few frames, so the output doesn't
> flicker.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `output` | Output | enum | 0=Vectors, 1=Speed, 2=Colour Wheel | 2 (Colour Wheel) | ◇ |  |
| `range` | Range (px) | float | 1 … 64 (step 0.5) | 12 | ◇ | the speed, in source pixels per frame, drawn at full |
| `searchSize` | Search Size (px) | float | 2 … 32 (step 0.5) | 8 | ◇ | the coarse grid; larger follows faster motion, less finely |
| `smoothing` | Smoothing | float | 0 … 0.95 (step 0.01) | 0.4 | ◇ | how much of the last frame's flow each frame keeps |
| `noiseFloor` | Noise Floor | float | 0 … 1 (step 0.01) | 0.2 | ◇ | damps the solve where the picture is flat |
| `edgeSnap` | Edge Snap | float | 0 … 1 (step 0.01) | 0.6 | ◇ | keeps the motion inside the picture's edges; 0 off |

#### Stable Fluids

id `stableFluids` · [stableFluids.ts](src/engine/modules/stableFluids.ts) · animated · 20 passes · feedback (keeps its velocity as `u_prev` and its dye as `u_prev2`) · extra picture inputs: `force` (Force)

Summary: Turns the picture into dye in a swirling fluid, stirred on its own or pushed by motion.

> The picture as dye in a moving fluid, after the fluid component the
> TouchDesigner community uses. The fluid neither piles up nor thins out,
> so the dye winds into swirls.
>
> The fluid keeps moving by itself and fades by Momentum. It is pushed by
> the Force input (vectors with 0.5 still, as Optical Flow's Vectors give,
> so a video's own motion stirs it) and by Stir, a slowly changing curl
> noise, so it moves with nothing wired. Vorticity puts back the small
> swirls that would otherwise be smoothed away.
>
> The dye is carried along by the fluid and fades by Dye Persistence, and
> the picture coming in pours in at Pour per second, by its alpha. The
> first frame is the picture itself; a seek starts again from it.
>
> Velocity is in frame heights per second. Output: the dye alone
> (transparent where there is none), the dye over the picture, or the
> velocity as vectors (red right, green up, 0.5 still, one frame height a
> second to full; last frame's).
>
> How it works:
>
> This is Jos Stam's Stable Fluids, run on the GPU. Its state is two
> pictures kept from frame to frame, the velocity and the dye.
>
> Each frame the velocity is carried along by itself, fades by Momentum
> and is pushed. The pressure is then solved so the fluid neither piles up
> nor thins out (Jacobi steps on coarse grids first, single pixels last)
> and its slope taken off the velocity. The dye is then carried along by
> that velocity.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `output` | Output | enum | 0=Dye, 1=Over Picture, 2=Velocity | 0 (Dye) | ◇ |  |
| `pour` | Pour (/s) | float | 0 … 5 (step 0.01) | 0.3 | ◇ | how fast the picture coming in tops the dye up; 0 only the first frame |
| `persistence` | Dye Persistence (s) | float | 0.5 … 60 (step 0.5) | 12 | ◇ | the dye's half-life |
| `vorticity` | Vorticity | float | 0 … 1 (step 0.01) | 0.3 | ◇ | small swirls kept alive |
| `stir` | Stir | float | 0 … 2 (step 0.01) | 0.5 | ◇ | a curl noise stirring it on its own |
| `forceAmount` | Force | float | 0 … 4 (step 0.01) | 1 | ◇ | how hard the Force input pushes; dimmed while it has no wire |
| `momentum` | Momentum (s) | float | 0.1 … 10 (step 0.05) | 2 | ◇ | the velocity's half-life; section Advanced |
| `stirSize` | Stir Size | float | 0.5 … 10 (step 0.1) | 3 | ◇ | the stir's swirls per frame height; section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Time Machine

id `timeMachine` · [timeMachine.ts](src/engine/modules/timeMachine.ts) · animated · keeps a ring of past input frames · extra picture inputs: `timeMap` (Time)

Summary: Shows each pixel as it was a moment ago, with another picture saying how long ago.

> Time Machine, after TouchDesigner's: every pixel shows its input as it
> was some time ago, and a second picture says how long ago.
>
> The node keeps its recent input in a cache . The Time
> input's brightness picks each pixel's delay: black reads Black Offset
> seconds back, white reads White Offset, grey in between. A ramp gives
> the slit-scan smear, a noise gives melting time, the picture's own luma
> makes bright things lag. With nothing wired every pixel is Black Offset
> behind -- a plain delay.
>
> Offsets are seconds of clock time, not frames, so a preview and an
> export agree. How far back the node can reach is (Cache Frames - 1) /
> Cache FPS; anything asked for further back gets the oldest frame held.
> Frame Blend crossfades between the two cached frames either side of the
> moment asked for, so a smooth ramp gives a smooth smear rather than
> bands one cache frame wide.
>
> The cache is memory -- Cache Frames copies of the picture -- so it is
> held at Half size by default, and shrunk further past a budget. A delay
> of zero reads the live input at full size.
>
> How it works:
>
> The cache is kept by timeCache.ts.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `blackOffset` | Black Offset | float | 0 … 8 (step 0.01) | 0 | ◇ |  |
| `whiteOffset` | White Offset | float | 0 … 8 (step 0.01) | 1 | ◇ |  |
| `blend` | Frame Blend | bool | on / off | true | ◇ |  |
| `frames` | Cache Frames | int | 2 … 240 | 60 | ○ | read on the CPU |
| `cacheFps` | Cache FPS | float | 1 … 60 (step 1) | 30 | ○ | read on the CPU |
| `cacheSize` | Cache Size | enum | 0=Full, 1=Half, 2=Quarter | 1 (Half) | ○ | read on the CPU |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Time Offset

id `timeOffset` · [timeOffset.ts](src/engine/modules/timeOffset.ts) · changes time for its branch

Summary: Delays or advances everything before it in time.

> Time Offset: its branch runs late (or early). Everything upstream -- a
> video, keys, an LFO, feedback -- sees the comp's time minus Offset, so
> at +1 s the branch shows what it did a second ago. The picture itself
> passes through untouched.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `offset` | Offset (s) | float | -60 … 60 (step 0.01) | 1 | ◇ | read at the time reaching the module |

#### Time Range

id `timeRange` · [timeRange.ts](src/engine/modules/timeRange.ts) · animated when Outside is Hide · changes time for its branch

Summary: Plays everything before it only between two times, and holds, hides or loops outside them.

> Time Range: its branch plays only from In to Out. Outside the range it is
> hidden (transparent), held on its first or last frame, looped, or played
> there and back. In and Out are comp seconds.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `start` | In (s) | float | 0 … 600 (step 0.01) | 0 | ◇ | typed as a number; either way round with Out |
| `end` | Out (s) | float | 0 … 600 (step 0.01) | 5 | ◇ | typed as a number |
| `outside` | Outside | enum | 0=Hide, 1=Hold, 2=Loop, 3=Ping-pong | 0 (Hide) | ◇ |  |

#### Time Remap

id `timeRemap` · [timeRemap.ts](src/engine/modules/timeRemap.ts) · changes time for its branch · starts keyed

Summary: Drives the time of everything before it with a curve: slow motion, speed ramps, reverse.

> Time Remap: its branch runs at whatever time Time says. Key Time and
> the curve is the branch's clock: a straight line from the comp's start
> to its end plays as normal (a new one starts with those two keys), a
> steeper stretch is fast, a flat one holds, a falling one plays backwards.
> With no keys, it holds at Time.
>
> A video behind a Time Remap is sought to every frame of a falling or
> steep curve, which plays choppily live; a render is exact.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `timeAt` | Time (s) | float | 0 … 600 (step 0.01) | 0 | ◇ | typed as a number; a new one has Linear keys comp start → start, comp end → end |

#### Trails

id `trails` · [trails.ts](src/engine/modules/trails.ts) · animated · feedback (reads its own last frame)

Summary: Leaves fading trails behind anything that moves.

> Phosphor persistence: the frame before this one, faded, still showing.
>
> Persistence is how long the trail takes to fall to a tenth, in seconds,
> rather than a per-frame multiplier.
>
> Deriving the per-frame factor from the frame's own delta also means a
> trail lasts the same wall-clock time at 30fps as at 120, instead of being
> a function of the machine it is running on.
>
> Both modes are bounded, which for feedback is not a detail: Decay keeps
> the brighter of the two, Blur is a leaky integrator. Adding the frames
> together instead would compound every frame and go white in about a
> second.
>
> How it works:
>
> Those are the same control expressed two ways, but only one of them is
> usable: as a multiplier, half the slider covers under ten frames and
> everything worth having is squeezed into the last few hundredths.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `persistence` | Persistence (s) | float | 0.05 … 4 (step 0.05) | 0.6 | ◇ |  |
| `mode` | Mode | enum | 0=Decay, 1=Blur | 0 (Decay) | ◇ |  |
| `tint` | Tint | color | RGB 0…1 | [1, 1, 1] | ◇ |  |

#### Tunnel

id `feedback` · [feedback.ts](src/engine/modules/feedback.ts) · animated · feedback (reads its own last frame)

Summary: Feeds the last frame back under the new one, zoomed and turned: tunnels and spirals.

> Video feedback: this node's last frame, moved and recoloured, mixed back
> under the new one -- the camera pointed at its own monitor.
>
> Where Trails only fades the frame before, this also zooms, turns, drifts
> and hue-shifts it on every pass, which compounds into tunnels, spirals
> and colour cycles.
>
> Every motion is a rate per second, so a tunnel spins at the same speed
> at 30fps as at 120. Persistence is how long the echo takes to fall to a
> tenth, as in Trails, and it is what keeps every mode bounded. There is
> deliberately no Add: a still picture added to its own echo turns white
> within the second at any useful persistence.
>
> Steps blends the echo from that many points along the frame's motion, so
> a fast zoom or turn smears smoothly instead of stacking sharp copies.
> One step is the plain transform.
>
> How it works:
>
> Called Feedback before; the id stays `feedback`, so documents keep it.
>
> Each rate is applied over the frame's own delta. A still picture added
> to its own echo settles at 1/(1 - k) times itself. Steps samples the
> echo at that many points along the frame's motion and averages them.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `persistence` | Persistence (s) | float | 0.05 … 8 (step 0.05) | 1 | ◇ |  |
| `zoom` | Zoom (×/s) | float | 0.25 … 4 (step 0.01) | 1.5 | ◇ |  |
| `rotate` | Rotate (°/s) | float | -360 … 360 (step 1) | 20 | ◇ |  |
| `drift` | Drift (/s) | vec2 | x,y ∈ -1 … 1 | [0, 0] | ◇ |  |
| `hueShift` | Hue Shift (°/s) | float | -360 … 360 (step 1) | 60 | ◇ |  |
| `center` | Center | vec2 | x,y ∈ -0.5 … 1.5 | [0.5, 0.5] | ◇ |  |
| `mode` | Mode | enum | 0=Over, 1=Screen, 2=Mix, 3=Difference | 0 (Over) | ◇ |  |
| `steps` | Steps | int | 1 … 16 | 1 | ◇ | section Advanced |
| `edge` | Edge | enum | 0=Clamp, 1=Wrap, 2=Black, 3=Mirror | 2 (Black) | ◇ | section Advanced |

### Composite

#### Layers

id `blend` · [blend.ts](src/engine/modules/blend.ts) · static · extra picture inputs: `layer` (Layer), `layer2` … `layer8` (Layer 2 … 8), shown as wired; read at their own size unless their Fit is Canvas · makes its own frame with Canvas: Custom

Summary: Stacks up to eight pictures on a base, each with its own blend mode, opacity and position.

> Pictures into one: the main input is the base, and up to eight layers go
> on top of it, each over the ones before.
>
> The canvas is the base's size, or a size of its own (Canvas: Custom),
> with a background colour under everything. Either way the base is placed
> like a layer: from the base, it only gives the canvas its size, and at rest
> lies exactly over it.
>
> Each layer is placed on the canvas: sized by its Fit, then scaled,
> turned about its anchor and put at its position. Fit Canvas is how Layers
> always took its layers -- made at the canvas's size, so a generator or
> Text fills it, and a picture of another shape is cropped to cover it.
> Every other Fit reads the layer at its own size and fits it here: Fill
> (cover, cropped), Fit (contain, all of it), Stretch, or Original size
> (one source pixel of the layer to one of the canvas). Outside a layer is
> nothing.
>
> The modes are the usual formulas, chosen for what they are for in this
> tool: Screen and Add to lay glow or light
> leaks over a picture, Multiply for dirt and burn, Overlay and Soft light
> for texture, Difference for lining two versions up.
>
> Each layer has its own mode and opacity; its alpha times its opacity is
> how much of it goes on, and Mix sits on top of all of them. A layer with
> nothing wired, or turned off (Visible), changes nothing.
>
> On the base's canvas the result keeps the base's alpha by default, so
> where the base is transparent so is the result, and the layers don't show
> there. Stack Alpha composites them as layers instead: a mode applies where there is something under the
> layer, the layer alone shows where there is nothing, and the alphas add
> up. A Custom canvas always stacks: its layers show wherever they land. So
> do arranged layers, since the base then fills only its own cell.
>
> Arrange lays the layers out instead of leaving each where it is put:
> Stack (all in the canvas, inside the padding), Row (side by side),
> Column (one above the other) or Grid (Columns across), with a Gap between
> cells and Padding round them. Row, Column and Grid cells have the base's
> shape, as big as fits inside the padding, the block of them centred: the
> Gap is the only space between pictures, and any room left over goes round
> the block. The base takes the first cell, then the
> layers from the bottom up, read left to right and top to bottom; hidden or
> unwired ones take none. Each layer is fitted into its cell by its Fit
> (Canvas fills it), centred in it and cut to it; its own Position, Scale,
> Rotation and Anchor wait for Free (Bake to Free writes the cells into them).
>
> How it works:
>
> The modes work on straight RGB. Stack Alpha is the W3C
> blend-then-over.

Placement: Position is where the layer's anchor goes, from the canvas's
centre, in canvas widths and heights, y up (Transform's Offset). Anchor is
the point of the layer put there, from its centre, in layer widths and
heights ((0.5, 0.5) is its top-right corner). Rotation is in turns,
clockwise, about the anchor. Sizes are source pixels, so a preview and an
export place a layer alike.

The card lists the layers top first, each a row that takes its picture's
wire: the base at the bottom (its row is the main input), an empty "Add a
layer" row at the top (wire it and the next appears; unwire the last and
the spare ones go, their settings kept). A row has an eye (Visible), what is
wired in, its mode and opacity; click it to pick it, drag it up or down to
restack (or Alt+↑ ↓). Moving a layer moves its wire, settings, keys and
wired settings with it, as one undo step. Settings are folded away until a
row's chevron opens them, with their sockets; a wired setting of a folded
group has its wire drawn to the group's row (an amber dot says so). The
canvas settings are on the card under the layers: Canvas, Width and Height
(Custom), Arrange and Columns (Grid), Stack Alpha, then Mix; Background and
Background Opacity (Custom), Gap and Padding (arranged) fold under Advanced,
which a card with neither doesn't show. In an open
group, a setting drops the layer from its name ("Base Fit" reads "Fit",
"Mode 2" reads "Mode"); a picture named by a long hash reads "Image".
With the layers arranged, they can't be moved by hand (no handles on the
preview), and **Bake to Free** there writes where each layer is into its own
settings (Fit Original size, Position, Scale; Rotation and Anchor back to
none) and sets Arrange back to Free, so the picture stays and each layer can be moved on;
a baked layer is no longer cut to its cell, and a Stretch one keeps its
width, not its squash. Its preview is a Large column beside the card's
controls (On by default; the title's toggle turns it off), kept in this
browser, not the document: the picture with room round it and handles on
the picked layer: drag to move (snapping to the
edges, the middle and the thirds; Alt for none), a corner to scale about the
anchor, the dot above to turn (Shift: 15° steps). Only the layer picked on
the card moves: a drag anywhere on the picture moves it. Layer 1 keeps the keys Layers
had with one layer, and a Fit missing from a document reads as Canvas, so
older documents load and draw as they were. A new Layers module starts its layers
on Fit.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `layers` | Layers | int | 1 … 8 | 1 | none | hidden: how many layer ports show, kept in step with the wires |
| `canvas` | Canvas | enum | 0=From base, 1=Custom | 0 (From base) | none | Custom: the frame below, the base placed on it; the card's menu also lists the generators' resolution presets, each a Custom canvas at that size |
| `canvasWidth` | Width | float | 1 … 16384 (step 1) | 1920 | none | shown with Custom; number field |
| `canvasHeight` | Height | float | 1 … 16384 (step 1) | 1080 | none | shown with Custom; number field |
| `background` | Background | color | RGB 0…1 | [0, 0, 0] | ◇ | shown with Custom; section Advanced |
| `backgroundOpacity` | Background Opacity | float | 0 … 1 (step 0.01) | 0 | ◇ | shown with Custom; transparent by default; section Advanced |
| `baseFit` | Base Fit | enum | 0=Canvas, 1=Fill, 2=Fit, 3=Stretch, 4=Original size | 2 (Fit) | none | the base's placement |
| `basePosition` | Base Position | vec2 | -1 … 1 (step 0.001) | [0, 0] | ◇ | the base's placement |
| `baseScale` | Base Scale | float | 0.01 … 4 (step 0.01) | 1 | ◇ | the base's placement |
| `baseRotation` | Base Rotation | float | -0.5 … 0.5 (step 0.001) | 0 | ◇ | the base's placement; turns, clockwise |
| `baseAnchor` | Base Anchor | vec2 | -1 … 1 (step 0.001) | [0, 0] | ◇ | the base's placement |
| `visible` | Visible | bool | on / off | true | ◇ | layer 1 |
| `mode` | Mode | enum | 0=Normal, 1=Add, 2=Subtract, 3=Multiply, 4=Screen, 5=Overlay, 6=Soft light, 7=Difference, 8=Lighten, 9=Darken | 4 (Screen) | ◇ | layer 1 |
| `opacity` | Opacity | float | 0 … 1 (step 0.01) | 1 | ◇ | layer 1 |
| `fit` | Fit | enum | 0=Canvas, 1=Fill, 2=Fit, 3=Stretch, 4=Original size | 0 (Canvas) | none | layer 1; a new Layers module starts on 2 (Fit) |
| `position` | Position | vec2 | -1 … 1 (step 0.001) | [0, 0] | ◇ | layer 1 |
| `scale` | Scale | float | 0.01 … 4 (step 0.01) | 1 | ◇ | layer 1 |
| `rotation` | Rotation | float | -0.5 … 0.5 (step 0.001) | 0 | ◇ | layer 1; turns, clockwise |
| `anchor` | Anchor | vec2 | -1 … 1 (step 0.001) | [0, 0] | ◇ | layer 1 |
| `visible2` … `anchor8` | Visible 2 … Anchor 8 | as layer 1 | as layer 1 | as layer 1, but Mode 0 (Normal) | as layer 1 | layers 2 … 8, shown with their layer |
| `arrange` | Arrange | enum | 0=Free, 1=Stack, 2=Row, 3=Column, 4=Grid | 0 (Free) | none | lays the base and layers out in cells; Position, Scale, Rotation and Anchor are then inactive |
| `columns` | Columns | int | 1 … 8 | 2 | none | shown with Grid |
| `gap` | Gap | float | 0 … 400 (step 1) | 0 | ◇ | source pixels between cells; shown when arranged; section Advanced |
| `padding` | Padding | float | 0 … 400 (step 1) | 0 | ◇ | source pixels round the cells; shown when arranged; section Advanced |
| `stack` | Stack Alpha | bool | on / off | false | ◇ | composite as layers: they show where the base is transparent; always on with Custom or when arranged |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input (with Custom, the canvas before the layers) |

#### Matte Tools

id `matteTools` · [matteTools.ts](src/engine/modules/matteTools.ts) · static · 3 passes

Summary: Shrinks, grows, feathers, clips and despills a cut-out or keyed matte.

> Refines an alpha matte after Cut Out or Chroma Key: Choke / Grow erodes
> or dilates the alpha with round corners, Feather softens the edge, Clip
> Black / White tightens the matte, and Despill neutralises green or blue
> fringe on RGB.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `choke` | Choke / Grow | float | -50 … 50 (step 0.5) | 0 | ◇ | negative erodes, positive dilates |
| `feather` | Feather | float | 0 … 64 (step 0.5) | 0 | ◇ |  |
| `clipBlack` | Clip Black | float | 0 … 1 (step 0.01) | 0 | ◇ |  |
| `clipWhite` | Clip White | float | 0 … 1 (step 0.01) | 1 | ◇ |  |
| `despill` | Despill | float | 0 … 1 (step 0.01) | 0 | ◇ |  |
| `despillScreen` | Despill Screen | enum | `0=Green`, `1=Blue` | 0 | ◇ | section Advanced; active when `despill > 0` |
| `invert` | Invert | bool | true / false | false | ◇ | section Advanced |
| `output` | Output | enum | `0=Result`, `1=Matte` | 0 | ◇ | section Advanced |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Light Wrap

id `lightWrap` · [lightWrap.ts](src/engine/modules/lightWrap.ts) · static · 2 passes · extra picture inputs: `background` (Background)

Summary: Bleeds the background's light inward over a cut-out foreground's edges.

> Blurs the background and wraps its light over the foreground's alpha edge
> so composited subjects sit naturally in bright environments. When
> Background is unwired, passes the foreground through untouched.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `intensity` | Intensity | float | 0 … 2 (step 0.01) | 0.6 | ◇ |  |
| `radius` | Radius | float | 0 … 64 (step 0.5) | 16 | ◇ |  |
| `mode` | Mode | enum | `0=Screen`, `1=Add` | 0 | ◇ |  |
| `threshold` | Threshold | float | 0 … 1 (step 0.01) | 0 | ◇ |  |
| `output` | Output | enum | `0=Composite`, `1=Foreground Only`, `2=Wrap Only` | 0 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Chroma Key

id `chromaKey` · [chromaKey.ts](src/engine/modules/chromaKey.ts) · static · 3 passes

Summary: Removes a green or blue screen.

> Chroma keyer / green & blue screen extractor with edge spill suppression.
>
> Keys out a selected background color by calculating color distance, feathering
> the edge, and neutralizing unwanted colored light bounce on hair and edges.
> Fill Holes and Remove Specks (despot) let the neighbourhood outvote a pixel.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `keyColor` | Key Color | color | RGB 0…1 | [0, 1, 0] | ◇ |  |
| `tolerance` | Tolerance | float | 0.01 … 1 (step 0.01) | 0.35 | ◇ |  |
| `softness` | Softness | float | 0.001 … 0.5 (step 0.005) | 0.1 | ◇ |  |
| `spill` | Spill Suppression | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `fillHoles` | Fill Holes | float | 0 … 40 (step 0.5) | 0 | ◇ | source pixels: key-coloured patches on the subject smaller than about this are kept (a reflection on skin); Keylight's Despot White, Resolve's Clean White |
| `removeSpecks` | Remove Specks | float | 0 … 40 (step 0.5) | 0 | ◇ | source pixels: opaque specks in the screen smaller than about this are keyed out; Keylight's Despot Black, Resolve's Clean Black |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Mask

id `mask` · [mask.ts](src/engine/modules/mask.ts) · static · extra picture inputs: `matte` (Matte)

Summary: Cuts the picture out using another picture as a mask.

> Cut the picture away using another node's output as an alpha or luma matte.
>
> The counterpart to Layers: where Layers lays one picture on top of another,
> Mask carves one picture out with another. An unplugged Matte input passes
> the picture through untouched so the node does not blank out while wiring.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `source` | Source | enum | 0=Luma, 1=Alpha, 2=Red, 3=Green, 4=Blue | 0 (Luma) | ◇ |  |
| `invert` | Invert | bool | on / off | false | ◇ |  |
| `blackPoint` | Black Point | float | 0 … 1 (step 0.01) | 0 | ◇ |  |
| `whitePoint` | White Point | float | 0 … 1 (step 0.01) | 1 | ◇ |  |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Collect

id `collect` · [collect.ts](src/engine/modules/collect.ts) · static · draws nothing · extra picture inputs: `picture2` … `picture32` (Picture 2 … 32)

Summary: Gathers several pictures onto one wire as a batch.

> Several pictures, wired in one per port, put out on one wire as a batch
> (see *Batches*): what an Image Set does for files, for anything -- a video,
> a generator, two branches of the graph. A port that is itself a batch adds
> all its pictures, in turn. Ports grow as they are wired, as the Layers module's layers
> do: up to the last one wired, and one empty one. Draws nothing itself: each
> picture of the batch is its input's.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `count` | Pictures | int | 1 … 32 | 2 | none | hidden: the ports shown, the last wired one and one more, kept in step with the wires |

#### Pick

id `pick` · [pick.ts](src/engine/modules/pick.ts) · static

Summary: Takes one picture out of a batch.

> One picture out of the batch on its input, by its place: 1 is the first,
> and past the last it goes round again. Chosen on every frame, so Index can
> be keyed or wired (a Time modulator in frames makes a slideshow), and the
> pictures not chosen are not drawn. What comes out is one picture, not a
> batch. On a single picture it passes it through.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `index` | Index | int | 1 … 32 | 1 | ◇ | rounded, from 1, going round past the last picture; the card's slider runs to the number of pictures coming in |

### Generators (Input menu)

Generators are `generator` nodes, not `effect` nodes: no picture input, plus a `width` and `height` on the node.

#### Cellular

id `cellular` · [cellular.ts](src/engine/modules/cellular.ts) · animated when `params.speed !== 0`

Summary: Draws cells: flat random colours, distances, borders or cracked earth.

> Cells of a Voronoi diagram, drawn four ways: each cell one flat random
> value (or colour), the distance to the nearest seed, lines along the
> borders, or crackle -- the gap between the nearest two seeds, which
> reads as cracked earth or scales.
>
> Flat is the one to wire into a diamond port: every pixel of a cell holds
> the same value, so a knob takes one setting per cell. Seeds are
> jittered from a grid by Randomness and orbit their spot at Speed, which
> is phased. The borders are measured exactly, as Crystal Mosaic's are,
> so Edges draws lines of one width all round.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `mode` | Mode | enum | 0=Flat, 1=Distance, 2=Edges, 3=Crackle | 0 (Flat) | ◇ |  |
| `cellSize` | Cell Size | float | 1 … 50 (step 0.5) | 8 | ◇ |  |
| `randomness` | Randomness | float | 0 … 1 (step 0.01) | 1 | ◇ |  |
| `colour` | Colour | bool | on / off | false | ◇ | active when `params.mode === 0` |
| `edgeWidth` | Edge Width | float | 0.01 … 0.5 (step 0.005) | 0.05 | ◇ | active when `params.mode === 2` |
| `speed` | Speed | float | -4 … 4 (step 0.01) | 0 | ○ | phased: integrated over time, single value only |

#### Noise

id `noise` · [noiseGenerator.ts](src/engine/modules/noiseGenerator.ts) · animated when `{ const speed = params.speed; return typeof speed === "number" && Math.abs(speed) > 1e-4; }`

Summary: Draws noise: smooth clouds, blocky values or cells.

> Fills the frame with noise: clouds, grain, textures or a moving
> backdrop. Type picks the look (smooth Perlin or Simplex clouds, blocky
> Value, cells with Worley, or a separate value per pixel with Random);
> Period and Scale set the size of the features, and Harmonics adds finer
> detail on top. It stays still until Speed is above 0, and Motion then
> chooses between sliding the field (Drift) and changing it in place
> (Evolve). Wire a picture into Translate to bend where each pixel reads
> the noise.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `noiseType` | Type | enum | 0=Perlin, 1=Value, 2=Worley, 3=Simplex, 4=Random | 0 (Perlin) | ◇ | Simplex: no lattice in its slope, for Slope / normal maps; Random: a value per pixel |
| `period` | Period | float | 0.01 … 10 (step 0.01) | 1 | ◇ | Random: cell width in source pixels (at least 1), each harmonic twice as coarse |
| `scale` | Scale | vec2 | x,y ∈ 0.1 … 10 | [1, 1] | ◇ | section Transform; stretches the field: 2 across makes every feature twice as wide |
| `harmonics` | Harmonics | int | 1 … 8 | 3 | ◇ |  |
| `contrast` | Contrast | float | 0 … 3 (step 0.05) | 1 | ◇ |  |
| `monochrome` | Monochrome | bool | on / off | true | ◇ |  |
| `speed` | Speed | float | 0 … 4 (step 0.05) | 0.5 | ○ | phased: integrated over time, single value only |
| `motion` | Motion | enum | 0=Drift, 1=Evolve | 0 (Drift) | ◇ | a new module starts on Evolve; Drift slides the field, Evolve changes its shape in place (3D noise, time as depth; Worley's points wander) |
| `translateMode` | Mode | enum | 0=Offset, 1=Replace | 0 (Offset) | ◇ | section Input; Offset adds Translate to where each pixel reads the noise; Replace reads it at Translate alone, as TouchDesigner's Noise Coordinate Map (its second input): the same colour gets the same noise anywhere in the frame, 0..1 spanning what the frame's height does through Period and Scale, blue as depth even on Drift (Random: a cell per 8-bit level); unwired, the whole frame is one value |
| `translate` | Translate | color | RGB 0…1 | [0, 0, 0] | ◇ | section Input; TouchDesigner's Noise TOP input: wire a picture and its red, green, blue move where each pixel reads the noise along x, y, z (z only on Evolve or Replace), one unit a noise feature (a cell for Random); a grey picture bends the noise into bands along its levels |
| `translateAmount` | Amount | float | 0 … 20 (step 0.05) | 1 | ◇ | section Input; scales Translate |
| `spread` | Harmonic Spread | float | 1.1 … 4 (step 0.01) | 2.02 | ◇ | section Advanced; how much finer each harmonic is than the last (lacunarity); active when `params.noiseType !== 4` |
| `roughness` | Harmonic Gain | float | 0 … 1.5 (step 0.05) | 0.5 | ◇ | section Advanced; how strong each harmonic is against the last, as TouchDesigner's Harmonic Gain |
| `offset` | Offset | float | -1 … 1 (step 0.02) | 0 | ◇ | section Advanced |
| `exponent` | Exponent | float | 0.2 … 4 (step 0.05) | 1 | ◇ | section Advanced |
| `aspect` | Aspect Correct | bool | on / off | true | ◇ | section Advanced; off, the field stretches with the frame's shape; active when `params.translateMode !== 1` |
| `noiseSeed` | Seed | int | 0 … 100 | 0 | ◇ | section Advanced; another field of the same kind, as TouchDesigner's Seed; added to the module's own seed |
| `direction` | Direction (°) | float | -180 … 180 (step 1) | 30 | ◇ | section Advanced; Drift direction in degrees; active when `params.motion !== 1` |

#### Pattern

id `pattern` · [pattern.ts](src/engine/modules/pattern.ts) · static

Summary: Draws two-colour patterns: checkers, stripes, grids, dots or rings.

> Geometric patterns in two colours: checkerboard, stripes, a grid of
> lines, a grid of dots, or rings round the centre. For masks, test cards,
> and fields that switch a knob on and off across the frame.
>
> Size is the pattern's period, in hundredths of the frame's height, so a
> pattern keeps its look at any resolution. Width is the share of each
> period the line, stripe or dot takes. Every edge is antialiased over one
> pixel, so the pattern stays clean however small or turned.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `type` | Type | enum | 0=Checker, 1=Stripes, 2=Grid, 3=Dots, 4=Rings | 0 (Checker) | ◇ |  |
| `size` | Size | float | 1 … 100 (step 0.5) | 10 | ◇ |  |
| `width` | Width | float | 0 … 1 (step 0.01) | 0.5 | ◇ | active when `params.type !== 0` |
| `rotation` | Rotation (°) | float | -180 … 180 (step 1) | 0 | ◇ |  |
| `offset` | Offset | vec2 | x,y ∈ -1 … 1 | [0, 0] | ◇ |  |
| `colorA` | Color A | color | RGB 0…1 | [1, 1, 1] | ◇ |  |
| `colorB` | Color B | color | RGB 0…1 | [0, 0, 0] | ◇ |  |

#### Plasma

id `plasma` · [plasma.ts](src/engine/modules/plasma.ts) · animated when `params.speed !== 0`

Summary: Draws a moving plasma of colour, the demoscene classic.

> Plasma: sine waves across, down, diagonally and round a wandering
> centre, summed and sent through a palette -- the demoscene classic.
>
> Complexity is how many of the four fields are summed; Warp bends each
> field's coordinates by the ones before it, which turns straight bands
> into liquid. Palettes are cosine palettes (a + b cos(TAU (c t + d))),
> so they cycle without a seam and Shift slides along them.
>
> How it works:
>
> Every time term turns a whole number of times per unit of phase, so the
> animation carries on seamlessly when the phase wraps.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `scale` | Scale | float | 0.1 … 10 (step 0.05) | 1.5 | ◇ |  |
| `speed` | Speed | float | -2 … 2 (step 0.01) | 0.1 | ○ | phased: integrated over time, single value only |
| `complexity` | Complexity | int | 1 … 4 | 4 | ◇ |  |
| `warp` | Warp | float | 0 … 2 (step 0.01) | 0.4 | ◇ |  |
| `palette` | Palette | enum | 0=Rainbow, 1=Fire, 2=Ocean, 3=Neon, 4=Mono | 0 (Rainbow) | ◇ |  |
| `shift` | Shift | float | 0 … 1 (step 0.01) | 0 | ◇ |  |

#### Gradient

id `ramp` · [ramp.ts](src/engine/modules/ramp.ts) · static

Summary: Draws a gradient: linear, radial, angular or diamond.

> Draws a colour gradient across the frame: linear, radial, angular
> (round a point) or diamond. Stops sets how many colours it blends (2 to
> 8), each with its own position along the gradient, colour and opacity.
> Interpolation chooses a straight, smooth or stepped blend, and Extend
> what happens beyond the first and last stop: hold the end colour, repeat
> or mirror. Angle turns the gradient.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `type` | Type | enum | 0=Linear, 1=Radial, 2=Angle, 3=Diamond | 0 (Linear) | ◇ |  |
| `angle` | Angle | float | 0 … 360 (step 1) | 0 | ◇ |  |
| `interpolation` | Interpolation | enum | 0=Linear, 1=Smooth, 2=Step | 1 (Smooth) | ◇ |  |
| `extend` | Extend | enum | 0=Clamp, 1=Repeat, 2=Mirror | 0 (Clamp) | ◇ |  |
| `stopCount` | Stops | int | 2 … 8 | 3 | ◇ |  |
| `pos0` | Pos 1 | float | 0 … 1 (step 0.01) | 0 | ◇ |  |
| `color0` | Color 1 | color | RGB 0…1 | [0.06, 0.05, 0.18] | ◇ |  |
| `pos1` | Pos 2 | float | 0 … 1 (step 0.01) | 0.5 | ◇ |  |
| `color1` | Color 2 | color | RGB 0…1 | [0.92, 0.22, 0.54] | ◇ |  |
| `pos2` | Pos 3 | float | 0 … 1 (step 0.01) | 1 | ◇ |  |
| `color2` | Color 3 | color | RGB 0…1 | [0.98, 0.78, 0.25] | ◇ |  |
| `pos3` | Pos 4 | float | 0 … 1 (step 0.01) | 1 | ◇ |  |
| `color3` | Color 4 | color | RGB 0…1 | [0.2, 0.8, 0.9] | ◇ |  |
| `pos4` | Pos 5 | float | 0 … 1 (step 0.01) | 1 | ◇ |  |
| `color4` | Color 5 | color | RGB 0…1 | [1, 1, 1] | ◇ |  |
| `pos5` | Pos 6 | float | 0 … 1 (step 0.01) | 1 | ◇ |  |
| `color5` | Color 6 | color | RGB 0…1 | [0.5, 0.5, 0.5] | ◇ |  |
| `pos6` | Pos 7 | float | 0 … 1 (step 0.01) | 1 | ◇ |  |
| `color6` | Color 7 | color | RGB 0…1 | [0.3, 0.3, 0.3] | ◇ |  |
| `pos7` | Pos 8 | float | 0 … 1 (step 0.01) | 1 | ◇ |  |
| `color7` | Color 8 | color | RGB 0…1 | [0.1, 0.1, 0.1] | ◇ |  |
| `alpha0` … `alpha7` | Opacity 1 … 8 | float | 0 … 1 (step 0.01) | 1 | ◇ | gradient editor (in percent); the Gradient's alpha; colours blend premultiplied |

#### Shape

id `shape` · [shape.ts](src/engine/modules/shape.ts) · static

Summary: Draws one flat shape: circle, rectangle, polygon, star, cross or heart.

> One flat shape on a background: circle, rectangle, triangle, regular
> polygon, star, cross or heart. For mattes, masks, light sources to blur
> and warp, and anything a composite needs a plain form for.
>
> The edge is smooth at any size or angle, Softness feathers it evenly,
> and Outline turns any shape into its own ring, drawn inside the edge so
> the shape keeps its size. Width and Height are fractions of the frame's
> height: equal, a circle is a circle and a rectangle a square on any
> frame. Rectangle and Triangle fill that box exactly; the others are
> drawn round a circle and stretched to it.
>
> Roundness rounds the corners without growing the shape. Transparent
> Background leaves only the shape in the alpha, for Layers and Mask.
>
> How it works:
>
> Every shape is drawn from its signed distance, so the edge is
> antialiased over one pixel. Roundness is cut in first and the rounding
> added back.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `shape` | Shape | enum | 0=Circle, 1=Rectangle, 2=Triangle, 3=Polygon, 4=Star, 5=Cross, 6=Heart | 0 (Circle) | ◇ |  |
| `sides` | Sides / Points | int | 3 … 16 | 5 | ◇ | active when `params.shape === POLYGON \|\| params.shape === STAR` |
| `shapeWidth` | Width | float | 0 … 2 (step 0.01) | 0.5 | ◇ |  |
| `shapeHeight` | Height | float | 0 … 2 (step 0.01) | 0.5 | ◇ |  |
| `center` | Position | vec2 | x,y ∈ -0.5 … 1.5 | [0.5, 0.5] | ◇ |  |
| `rotation` | Rotation (°) | float | -180 … 180 (step 1) | 0 | ◇ |  |
| `fill` | Fill | color | RGB 0…1 | [1, 1, 1] | ◇ |  |
| `outline` | Outline | float | 0 … 0.5 (step 0.001) | 0 | ◇ |  |
| `inner` | Inner Radius | float | 0.05 … 1 (step 0.01) | 0.45 | ◇ | section Form; active when `params.shape === STAR` |
| `armWidth` | Arm Width | float | 0.02 … 1 (step 0.01) | 0.33 | ◇ | section Form; active when `params.shape === CROSS` |
| `roundness` | Roundness | float | 0 … 1 (step 0.01) | 0 | ◇ | section Form; active when Shape is Rectangle, Triangle, Polygon or Cross |
| `softness` | Softness | float | 0 … 0.5 (step 0.001) | 0 | ◇ | section Advanced |
| `background` | Background | color | RGB 0…1 | [0, 0, 0] | ◇ | section Advanced |
| `transparent` | Transparent Background | bool | on / off | false | ◇ | section Advanced |

#### 3D Shape

id `shape3d` · [shape3d.ts](src/engine/modules/shape3d.ts) · animated when Turntable ≠ 0 · Input → 3D → 3D Shape · puts out `depth`, `normal`, `matte` too (its `outputs`, `u_output` 1, 2, 3)

Summary: Draws one simple 3D shape (cube, sphere, cylinder, cone, torus, pyramid, capsule, octahedron), lit and turned.

> One simple 3D shape as a picture, on transparent ground so it goes onto
> a picture through Layers. No file and no mesh, so every setting is live
> and keyable. Size is a fraction of the frame's height at Field of View
> 35°. The light is set against the camera (Light Angle 0 shines from
> where the camera is).
>
> Handled on its preview as a Model is: drag turns it about the screen's
> own axes, Alt-drag is a free arcball (both write Rotate X / Y / Z),
> Shift-drag or right-drag moves it (Position), the wheel changes Size.
> Depth (white near, black far and where there is no shape), Normals (view
> space, packed 0..1) and Matte (white where the shape is) are on ports of
> their own.
>
> How it works:
>
> The shape is a signed distance marched along each pixel's ray. The
> silhouette is antialiased from how near the ray passed.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `shape` | Shape | enum | 0=Cube, 1=Sphere, 2=Cylinder, 3=Cone, 4=Torus, 5=Pyramid, 6=Capsule, 7=Octahedron | 0 (Cube) | ◇ |  |
| `size` | Size | float | 0.05 … 2 (step 0.01) | 0.6 | ◇ |  |
| `rotateX` | Rotate X (°) | float | -180 … 180 (step 0.5) | 25 | ◇ |  |
| `rotateY` | Rotate Y (°) | float | -180 … 180 (step 0.5) | 35 | ◇ |  |
| `rotateZ` | Rotate Z (°) | float | -180 … 180 (step 0.5) | 0 | ◇ |  |
| `speed` | Turntable (turns/s) | float | -2 … 2 (step 0.01) | 0 | ◇ |  |
| `roundness` | Roundness | float | 0 … 1 (step 0.01) | 0 | ◇ | active when Shape is Cube or Cylinder |
| `thickness` | Thickness | float | 0.02 … 0.5 (step 0.01) | 0.18 | ◇ | active when Shape is Torus |
| `shading` | Shading | enum | 0=Lit, 1=Unlit, 2=Clay, 3=Normals, 4=Depth | 0 (Lit) | ◇ |  |
| `fill` | Colour | color | RGB 0…1 | [0.9, 0.35, 0.25] | ◇ |  |
| `fov` | Field of View (°) | float | 5 … 120 (step 0.5) | 35 | ◇ | section Camera |
| `position` | Position | vec2 | x,y ∈ -0.5 … 1.5 | [0.5, 0.5] | ◇ | section Camera |
| `clayColor` | Clay Colour | color | RGB 0…1 | [0.82, 0.8, 0.76] | ◇ | section Light; active when Shading is Clay |
| `lightAngle` | Light Angle (°) | float | -180 … 180 (step 0.5) | -40 | ◇ | section Light; active when Shading is Lit or Clay |
| `lightHeight` | Light Height (°) | float | -90 … 90 (step 0.5) | 35 | ◇ | section Light; active when Shading is Lit or Clay |
| `intensity` | Light | float | 0 … 3 (step 0.01) | 1 | ◇ | section Light; active when Shading is Lit or Clay |
| `lightColor` | Light Colour | color | RGB 0…1 | [1, 1, 1] | ◇ | section Light; active when Shading is Lit or Clay |
| `ambient` | Ambient | float | 0 … 1 (step 0.01) | 0.35 | ◇ | section Light; active when Shading is Lit or Clay |
| `rim` | Rim | float | 0 … 1 (step 0.01) | 0 | ◇ | section Light; active when Shading is Lit or Clay |
| `background` | Background | enum | 0=Transparent, 1=Colour | 0 (Transparent) | ◇ | section Background |
| `backgroundColor` | Background Colour | color | RGB 0…1 | [0.08, 0.08, 0.09] | ◇ | section Background; active when Background is Colour |

#### Solid Color

id `solid` · [solid.ts](src/engine/modules/solid.ts) · static

Summary: Fills the frame with one colour, or nothing: a plate to build on.

> Solid Color (once called Null): one flat colour over the whole frame, or
> nothing at all. A plate to composite onto: its Width and Height set the
> frame a Layers module or Mask works at, Color fills it, and Opacity goes into the alpha (straight, as
> every module reads it), so at 0 it is a fully transparent frame of that
> size -- a base layer that adds nothing but its size.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `color` | Color | color | RGB 0…1 | [0, 0, 0] | ◇ |  |
| `opacity` | Opacity | float | 0 … 1 (step 0.01) | 1 | ◇ |  |

#### Spectrum

id `spectrum` · [spectrum.ts](src/engine/modules/spectrum.ts) · animated · reads sound on its `sound` port

Summary: Draws the music as bars, lines, rings or a scrolling spectrogram.

> The music as a picture: an Audio node's spectrum drawn as bars, a line,
> a scrolling spectrogram, a ring and more -- a picture like any other, so
> it can be shown as it is, or plugged into a knob as a field and make a
> Remap or a Gradient Map move to the music.
>
> It follows the Audio node's Offset, Loop and trim, and is dimmed by its
> fades. Levels are in decibels against the loudest moment in the file,
> over Range; Tilt lifts the highs, which carry far less energy than the
> lows. Source draws the whole sound, only its percussive part (hits,
> noise) or only its harmonic part (steady tones), each against the same
> loudest moment as the whole, so each is as quiet as it is in the sound.
> Smooth averages the last few readings, so bars settle rather than
> flicker. With no sound wired, or until the file is analysed, it draws
> the background.
>
> The modes, as the menu groups them:
>
> - Across, low frequencies at the left: Bars; LED Meter, bars cut into
>   Segments with the unlit ones faintly shown; Line.
> - Over time: Spectrogram, time across (newest at the right) and frequency
>   up; Waterfall, the last readings as a stack of ridge lines, newest in
>   front, each hiding the ones behind it, Depth narrowing them toward the
>   back; Tunnel, the spectrogram wrapped round the centre, newest in the
>   middle and flowing outward.
> - Round, low frequencies at the top, mirrored left and right: Radial,
>   bars round a ring; Ring, one closed line whose radius follows the
>   spectrum; Rings, a band per concentric ring, lit by its level.
>
> Peak Hold leaves a cap at each bar's recent highest, which falls back as
> if dropped. Line Width is in pixels across the line, however steep; Glow
> adds a soft halo round it.
>
> How it works:
>
> It reads the file's analysis: the 40 bands, 20 Hz up, and the last 1.28
> s of readings. Peak Hold's caps come from the readings themselves, so an
> export draws the same caps.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `mode` | Mode | enum | 0=Bars, 1=Line, 2=Spectrogram, 3=Radial, 4=LED Meter, 5=Waterfall, 6=Ring, 7=Tunnel, 8=Rings; menu headings Across (Bars, LED Meter, Line), Over time (Spectrogram, Waterfall, Tunnel), Round (Radial, Ring, Rings) | 0 (Bars) | ◇ |  |
| `source` | Source | enum | 0=Full, 1=Percussive, 2=Harmonic | 0 (Full) | ◇ |  |
| `bars` | Count | int | 4 … 128 | 32 | ◇ | active when Bars, Radial, LED Meter or Rings |
| `low` | Low | color | RGB 0…1 | [0.12, 0.5, 1] | ◇ |  |
| `high` | High | color | RGB 0…1 | [1, 0.3, 0.6] | ◇ |  |
| `smoothing` | Smooth | float | 0 … 1 (step 0.01) | 0.4 | ◇ | active unless Spectrogram, Waterfall or Tunnel |
| `range` | Range (dB) | float | 12 … 96 (step 1) | 48 | ◇ |  |
| `tilt` | Tilt (dB/oct) | float | 0 … 12 (step 0.5) | 3 | ◇ |  |
| `lineWidth` | Line Width (px) | float | 0.5 … 12 (step 0.1) | 1.5 | ◇ | section Style; active when Line, Waterfall or Ring |
| `glow` | Glow | float | 0 … 2 (step 0.01) | 0 | ◇ | section Style; active when Line, Waterfall or Ring |
| `gap` | Gap | float | 0 … 0.9 (step 0.01) | 0.25 | ◇ | section Style; active when Bars, Radial, LED Meter or Rings |
| `peakHold` | Peak Hold | bool | — | false | ◇ | section Style; active when Bars, Radial or LED Meter |
| `mirror` | Mirror | bool | — | false | ◇ | section Style; active when Bars, Line or LED Meter |
| `segments` | Segments | int | 4 … 48 | 16 | ◇ | section Advanced; active when LED Meter |
| `lines` | Lines | int | 4 … 64 | 32 | ◇ | section Advanced; active when Waterfall |
| `depth` | Depth | float | 0 … 1 (step 0.01) | 0.5 | ◇ | section Advanced; active when Waterfall |
| `background` | Background | color | RGB 0…1 | [0.02, 0.02, 0.04] | ◇ | section Advanced |

#### Wave Field

id `waveField` · [waveField.ts](src/engine/modules/waveField.ts) · animated when `params.speed !== 0`

Summary: Draws a greyscale field of interfering waves: ripples, vortex, tunnel, plasma, rings, moiré or starfield.

> Wave Field: the parametric wave synth of the ASCII studio
> (ascii.pantoine.com), ported as it is: a greyscale field summed from
> radial ripples, directional swells, a spiral vortex, a tunnel warp, a
> breathing ring, two interfering emitters and a twinkling starfield.
> Colour it with Gradient Map.
>
> Each Look is one of the studio's presets, so it draws what the studio
> drew. Speed scales the studio's time. Channels scales the ingredients
> the chosen look uses, and shows only those; Twist adds to the spiral's
> own twist.
>
> How it works:
>
> Each Look has its own amplitude, frequency and speed for every channel,
> on the studio's defaults. Lengths are in the studio's character cells,
> 90 to the frame's height at Scale 1, positions square. Each channel's
> own speed is rounded to whole turns per phase wrap (within 1%), so the
> loop carries on seamlessly.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `mode` | Look | enum | 0=Ripple, 1=Vortex, 2=Tunnel, 3=Interference, 4=Plasma, 5=Pulsing Rings, 6=Orbits, 7=Cells, 8=Grid Swell, 9=Moiré, 10=Starfield | 0 (Ripple) | ◇ | the studio's presets, by their own numbers |
| `speed` | Speed | float | -3 … 3 (step 0.01) | 1 | ○ | phased: integrated over time, single value only |
| `scale` | Scale | float | 0.25 … 4 (step 0.01) | 1 | ◇ | above 1 the field is larger |
| `twist` | Twist | float | -0.5 … 0.5 (step 0.005) | 0 | ◇ | added to the spiral's twist (radians per cell out) |
| `contrast` | Contrast | float | 0 … 3 (step 0.01) | 1 | ◇ | times the look's own |
| `bias` | Brightness | float | -1 … 1 (step 0.01) | 0 | ◇ | added to the look's own |
| `invert` | Invert | bool | — | false | ◇ |  |
| `wRadial` | Radial | float | 0 … 2 (step 0.01) | 1 | ◇ | section Channels; shown when the look uses it |
| `wSwell` | Swells | float | 0 … 2 (step 0.01) | 1 | ◇ | section Channels; shown when the look uses it |
| `wSpiral` | Spiral | float | 0 … 2 (step 0.01) | 1 | ◇ | section Channels; shown when the look uses it |
| `wTunnel` | Tunnel | float | 0 … 2 (step 0.01) | 1 | ◇ | section Channels; shown when the look uses it |
| `wRings` | Rings | float | 0 … 2 (step 0.01) | 1 | ◇ | section Channels; shown when the look uses it |
| `wEmit` | Emitters | float | 0 … 2 (step 0.01) | 1 | ◇ | section Channels; shown when the look uses it |
| `wStars` | Stars | float | 0 … 2 (step 0.01) | 1 | ◇ | section Channels; shown when the look uses it |

#### Text

id `textLayer` · [textLayer.ts](src/engine/modules/textLayer.ts) · static · Input → Text → Text · takes words on `text:prompt`

Summary: Sets words on the picture in any font, placed, styled and animated.

> Words on a picture: typed on the card, set in a font, placed, sized,
> turned, coloured, outlined, shadowed and revealed.
>
> Size is the font size against the frame's height; outline and shadow
> measure in ems (the font size), so they keep with the words as they
> scale. Reveal shows the letters one after another, in reading order, each
> fading in over its own share. The words come out on transparent ground:
> onto a picture through Layers (Normal, or Stack Alpha).
>
> How it works:
>
> Two halves. The page draws the words once, at a fixed size, with the
> distance to their edge and each letter's order (textRaster.ts,
> glyphField.ts): that is the part that needs the font, and it only changes
> when the words or their type do. The shader places that picture, so
> everything in the table below can be keyed or modulated without drawing
> again.

The card, above the params:

- **Placement**, in its preview (a Large column beside the card, On by default): the
  picture the words go onto -- the output of the module the Text is wired
  into (a Layers module that fills with it, say), or the words alone on a
  checkerboard -- with the words' box over it. Drag anywhere to move them
  (snapping to the middle and the thirds; Alt for none), the square corner
  to size them, the round dot above to turn them (Shift: 15° steps). Keyed
  params take a key at the playhead; wired ones cannot be dragged.
- **Words**: typed in the box, or the words of a Prompt or Describe wired
  into its Words port (`text:prompt`), which then stand in for them.
- **Font**: every Google Fonts family (searchable, by category, each name
  in itself), a few installed everywhere, a font file brought in (.ttf,
  .otf, .woff, .woff2; kept in this browser and carried in project files),
  and, where the browser allows, the fonts on this computer. **Weight** and
  **Italic** offer what the family has, and **Width** (Condensed, Expanded,
  …) shows for the families with a width axis.
- **Align** (left, centre, right: of the lines, and of the words on
  Position), **Letter Spacing** (-0.2..1 em), **Line Height** (0.5..3 em).

These are `typeset` on the node (section 2), not params: they change the
letters' shapes, so they cannot be keyed or wired.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `position` | Position | vec2 | -0.5 … 1.5 (step 0.001) | [0.5, 0.5] | ◇ | the aligned edge (or middle) of the words, half way down their lines; 0..1 from the bottom left |
| `size` | Size | float | 0.01 … 1 (step 0.001) | 0.15 | ◇ | the font size, against the frame's height |
| `rotation` | Rotation (°) | float | -180 … 180 (step 0.5) | 0 | ◇ | round Position, anticlockwise |
| `color` | Colour | color | RGB 0…1 | [1, 1, 1] | ◇ |  |
| `opacity` | Opacity | float | 0 … 1 (step 0.01) | 1 | ◇ | of everything: letters, outline, shadow |
| `reveal` | Reveal | float | 0 … 1 (step 0.001) | 1 | ◇ | 0 none, 1 all; the letters in reading order |
| `outline` | Outline | float | 0 … 0.25 (step 0.001) | 0 | ◇ | section Outline & Shadow; in ems |
| `outlineColor` | Outline Colour | color | RGB 0…1 | [0, 0, 0] | ◇ | section Outline & Shadow; active when Outline > 0 |
| `shadow` | Shadow | float | 0 … 1 (step 0.01) | 0 | ◇ | section Outline & Shadow; its opacity |
| `shadowColor` | Shadow Colour | color | RGB 0…1 | [0, 0, 0] | ◇ | section Outline & Shadow; active when Shadow > 0 |
| `shadowOffset` | Shadow Offset | vec2 | -0.5 … 0.5 (step 0.001) | [0.04, -0.06] | ◇ | section Outline & Shadow; in ems, on the frame (not turned with the words); active when Shadow > 0 |
| `shadowSoftness` | Shadow Softness | float | 0 … 0.3 (step 0.001) | 0.06 | ◇ | section Outline & Shadow; in ems; active when Shadow > 0 |

#### Model

id `model3d` · [model3d.ts](src/engine/modules/model3d.ts) · animated when Turntable ≠ 0 · Input → 3D → Model · a `.glb` / `.gltf` / `.obj` file on its card · puts out `depth`, `normal`, `matte` too

Summary: Turns a 3D model (glTF, GLB or OBJ) into a picture, with its depth, normals and matte.

> A 3D model as a picture: lit, from a camera you orbit, on transparent
> ground so it goes onto a picture through Layers.
>
> Everything below can be keyed or modulated. The light is set against the
> camera (Light Angle 0 shines from where the camera is), so it stays put
> while the model turns on the turntable.
>
> How it works:
>
> The mesh is drawn first, 4× multisampled where the GPU allows, into its
> base colour and coverage, and its normals and depth (meshRender.ts); this
> module shades from those.

The card, above the params:

- **File**: click or drop a glTF 2.0 model, a `.glb` or a `.gltf` with
  everything inside it (up to 64 MB and 2 million triangles). Dropping one
  on the canvas makes a Model for it. The file is kept in this browser and
  carried in project files, like an imported picture. Compressed models
  (Draco, meshopt, Basis textures) and `.gltf` files that point at other
  files are refused with a message that says so. The default scene is drawn
  at its rest pose: base colour, its texture and vertex colours, cut-out
  alpha, double-sided materials. Animation is not played yet. An `.obj`
  is read too, as geometry: its parts, normals (flat where it has none),
  texture coordinates and vertex colours, but not its `.mtl` materials,
  so it comes in white (Clay shading suits it).
- **Outputs**: besides its picture (the title's port), **Depth** (`depth`:
  white near, black far and where there is no model, opaque, like the Depth
  module's), **Normals** (`normal`: view-space, packed 0..1, the empty
  ground facing the camera) and **Matte** (`matte`: white where the model
  is), each on a port of its own. The model is drawn once a frame for all
  of them; each read output is one more cheap pass.
- **Settings**: Orbit, Tilt, Distance, Turntable, Up Axis and Shading show;
  the rest fold under **Camera** (Field of View, Position), **Object**
  (Rotate X / Y / Z, Scale), **Light** (Clay Colour and the light) and
  **Background**, each opened by its row (for this visit). A folded
  setting that is wired keeps its wire, ending on the row, with a dot.
- **Handling**, in the preview (Auto by default: shown while the Model is
  selected): drag to turn the model about the screen's own axes (across
  spins it left and right, up and down tips it, 0.4° per pixel), however
  it is turned already, so there are no poles (as Blender's trackball). The
  light is set against the camera, so this looks just as if the camera went
  round it. Alt-drag turns it freely, as an arcball (the point grabbed
  stays under the pointer; near the edge and past it, it rolls). Both set
  Rotate X / Y / Z as seen through the camera; Orbit and Tilt are the
  camera, on their sliders. Shift-drag or right-drag pans (Position, also
  its dot), scrolling zooms (Distance). Keyed params take a key at the
  playhead; wired ones are left alone.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `orbit` | Orbit (°) | float | -180 … 180 (step 0.5) | 30 | ◇ | round the model; 0 looks at its front |
| `tilt` | Tilt (°) | float | -180 … 180 (step 0.5) | 15 | ◇ | above (+) or below (−) it; past ±90 over the top, upside down |
| `distance` | Distance | float | 0.2 … 6 (step 0.01) | 1 | ◇ | 1 frames the whole model in the narrower side of the picture |
| `fov` | Field of View (°) | float | 5 … 120 (step 0.5) | 35 | ◇ | vertical |
| `position` | Position | vec2 | -0.5 … 1.5 (step 0.001) | [0.5, 0.5] | ◇ | where the model's centre lands, 0..1 from the bottom left; a lens shift, so the perspective stays |
| `speed` | Turntable (turns/s) | float | -2 … 2 (step 0.01) | 0 | ◇ | added to Orbit; integrated, so changing it never jumps |
| `rotateX` | Rotate X (°) | float | -180 … 180 (step 0.5) | 0 | ◇ | the object about its centre, X then Y then Z |
| `rotateY` | Rotate Y (°) | float | -180 … 180 (step 0.5) | 0 | ◇ |  |
| `rotateZ` | Rotate Z (°) | float | -180 … 180 (step 0.5) | 0 | ◇ |  |
| `scale` | Scale | float | 0.05 … 4 (step 0.01) | 1 | ◇ |  |
| `upAxis` | Up Axis | enum | +Y, +Z, −Z, +X, −X, −Y | +Y | ◇ | the file's axis that is up, stood upright before anything else: glTF's own is +Y, but many models are made Z-up and lie on their back |
| `shading` | Shading | enum | Lit, Unlit, Clay, Normals, Depth | Lit | ◇ | Unlit: the base colour alone; Clay: one colour, lit; Normals: view-space normals; Depth: white near, black far |
| `clayColor` | Clay Colour | color | RGB 0…1 | [0.82, 0.8, 0.76] | ◇ | active when Clay |
| `lightAngle` | Light Angle (°) | float | -180 … 180 (step 0.5) | -40 | ◇ | round the camera; active when Lit or Clay |
| `lightHeight` | Light Height (°) | float | -90 … 90 (step 0.5) | 35 | ◇ | active when Lit or Clay |
| `intensity` | Light | float | 0 … 3 (step 0.01) | 1 | ◇ | active when Lit or Clay |
| `lightColor` | Light Colour | color | RGB 0…1 | [1, 1, 1] | ◇ | active when Lit or Clay |
| `ambient` | Ambient | float | 0 … 1 (step 0.01) | 0.35 | ◇ | active when Lit or Clay |
| `rim` | Rim | float | 0 … 1 (step 0.01) | 0 | ◇ | light along the edges facing away; active when Lit or Clay |
| `background` | Background | enum | Transparent, Colour | Transparent | ◇ |  |
| `backgroundColor` | Background Colour | color | RGB 0…1 | [0.08, 0.08, 0.09] | ◇ | active when Colour |

### Custom

#### Code

menu entry `code` · node type `effect` with `code.source` · Module → Custom · [codeModule.ts](src/engine/codeModule.ts), [codeHeader.ts](src/engine/codeHeader.ts), [codePixel.ts](src/engine/codePixel.ts), [CodeCard.tsx](src/components/CodeCard.tsx)

Summary: Your own GLSL on the card, run on every pixel, with its own sliders, inputs and sound.

> Write your own GLSL on the card and it runs on every pixel as an
> effect. Comment lines at the top of the code (`// @param`, `// @input`
> and so on) add the sliders, toggles, menus and extra picture or sound
> inputs the card shows. A change applies a moment after you stop typing
> (or at Ctrl+Enter); a mistake is listed under the code with its line, and
> the picture passes through unchanged until it is fixed. The **?** on the
> card lists the names you can use and offers examples to start from.

The code is written on the card and is the module: its `effectId` is `code:`
and a hash of the code, made again from `code.source` wherever it is loaded,
pasted or edited (codeModule.ts). It is applied a moment after typing stops,
at Ctrl+Enter, or when the editor loses focus; each change is one undo step,
and params, keys and wires the new code still has are kept. A shader error
is listed under the code with its line (the line number turns red), and the
picture passes through unchanged meanwhile. The preview starts on Auto.

Once written, the code folds away to one line (the chevron; remembered in this browser, not in the project), its rows and errors still showing. Export saves it as a `.glsl` file named after its `@name`; Import replaces it with one (`.glsl`, `.frag`, `.txt`, up to 20 000 characters), one undo step.

**Header lines** (comments, anywhere; each declares what the card has):

| Line | Makes |
| :-- | :-- |
| `// @param float key min .. max = default` (`step n`, `field`) | a slider (`int` alike; no range: 0 … 1, 0 … 10 for an int; no default: the minimum) |
| `// @param bool key = true` | a toggle |
| `// @param enum key [A, B, C] = 1` (or `= B`) | a menu |
| `// @param color key = #rrggbb` | a swatch |
| `// @param vec2 key min .. max = x, y` (`point`) | a point (a dot on the preview with `point`) |
| … `"Label"` anywhere on a line | the row's label (else from the key: `edgeWidth` → Edge Width) |
| `// @input key picture "Label"` (up to 4) | another picture port |
| `// @input key sound` (one) | a sound port, from an Audio node |
| `// @output key "Label"` (up to 4) | another picture out, on a port of its own (below the rows); each one wired is the body run again for it (`u_output`: 0 the main picture, 1, 2, … in order), and Mix touches only the main picture |
| `// @name Name` · `// @category stylize` · `// @nomix` | the title · its group (display only) · no Mix |
| `// @mode shader` | Shader mode (Pixel is the default) |

Up to 16 params. A key must be a GLSL name, not a GLSL word, not a built-in
(`time`, `src`, …), not `mix` (unless `@nomix`), not any name below. A line
that cannot be read is an error on its line, and is left out. Mix is on
unless `@nomix`. Whether it animates is worked out: the clock, a sound, or a
`speed` / `rate` / `roll` param's `u_phase_<key>` while it is not 0.

**Pixel mode** runs the body once per pixel with these names (only those the
body uses are made); whole numbers are floats (`1 - r`), except where GLSL
wants an int:

| Name | What |
| :-- | :-- |
| `r g b a`, `rgb`, `color` | the channels: they start as the input and what they hold at the end is the pixel (unless the body writes `fragColor` itself) |
| `src` | the input as it came |
| `luma`, `hue`, `sat`, `val` | of `src`, 0 … 1 |
| `uv`, `px`, `size`, `aspect`, `centered` | this pixel (0 … 1, pixels), the frame, its width / height, uv centred and square |
| `time`, `delta`, `frame`, `seed` | the clock (the branch's), and a number per module |
| each param by its key | ints and menus as floats |
| `<input>`, `<input>_wired` | that picture at this pixel; whether a wire comes in |
| `<output>` | what that output puts out here (vec4), transparent until the body writes it; `out_<output>` in Shader mode |
| `level`, `bass`, `mid`, `high`, `onset` | with a sound: 0 … 1 now (40 bands; bass 20–160 Hz, mid to 2.5 kHz, high above; onset a rise against 40 ms ago) |
| `perc`, `harm` | with a sound: the percussive part's level and the harmonic part's, 0 … 1 now, on the same scale as `level` (so each is as quiet as it is in the sound) |
| `bright` | with a sound: how bright the sound is now, 0 … 1 (Audio Level's Brightness) |

**Both modes** get `at(dx, dy)` (a neighbour, in pixels), `read(p)` (the
input anywhere, uv), `<input>_at`, `<input>_read`, `hsv(h, s, v)`, and with
a sound `band(i)` (0 … 39) and `spectrum(f, age)` (the whole sound; f 0 … 1 low to high, age
0 now … 1 = 1.28 s ago). **Shader mode** is the body of a built-in module as
it is: `u_src`, `v_uv`, `u_<key>`, writing `fragColor`; `<input>_wired()`.

The card's **?** lists these for its own ports, and offers examples
(codeExamples.ts) to start from. No params of its own beyond its header and
Mix.

---

## 5. Modulators

Sources make a signal from the clock alone. Operators combine or reshape
signals. Every numeric param on a modulator is a round `param:<key>` port (so
an LFO can drive another LFO's rate); modes and toggles are not wirable.
Output handle: `mod`.

Sources share **Amplitude** and **Offset** (output = wave × amplitude +
offset) and a **Seed** knob for random ones.

### Sources (Input menu)

#### LFO

id `lfo`

Summary: A wave that swings up and down to move a parameter: sine, triangle, saw, square, random.

> The oscillator: a -1..1 wave, times Amplitude, plus Offset.
>
> Random holds a new value each cycle -- sample and hold, the stepped
> wander of a failing tracking servo. Drift eases between the same values
> instead, which is the slow, unsteady swim of a tape transport and
> usually the one to reach for on anything analog.
>
> Rate is in hertz of wall-clock time, from the same wrapped clock the
> shaders see, so at the wrap (every ~17 minutes) the phase jumps once.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `shape` | Shape | enum | 0=Sine, 1=Triangle, 2=Saw, 3=Square, 4=Random, 5=Drift | 0 (Sine) | none |  |
| `rate` | Rate (Hz) | float | 0 … 5 (step 0.01) | 0.5 | ○ |  |
| `phase` | Phase | float | 0 … 1 (step 0.01) | 0 | ○ |  |
| `seed` | Seed | int | 0 … 999 | 0 | ○ |  |
| `amplitude` | Amplitude | float | free number (typed) | 1 | ○ |  |
| `offset` | Offset | float | free number (typed) | 0 | ○ |  |

#### Noise

id `noise`

Summary: A value that wanders at random, from slow drift to nervous jitter.

> Wander with detail, -1..1: several octaves of the Drift curve stacked,
> each twice as fast and half as strong as the last. One octave is a slow
> swim; four is the nervous, never-quite-repeating jitter of a worn
> mechanism.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `rate` | Rate (Hz) | float | 0 … 5 (step 0.01) | 0.5 | ○ |  |
| `octaves` | Octaves | int | 1 … 6 | 3 | ○ |  |
| `seed` | Seed | int | 0 … 999 | 0 | ○ |  |
| `amplitude` | Amplitude | float | free number (typed) | 1 | ○ |  |
| `offset` | Offset | float | free number (typed) | 0 | ○ |  |

#### Pulse

id `pulse`

Summary: Switches between 0 and 1 in time, on for part of each beat.

> A gate, 0 or 1: on for part of each beat, off for the rest.
>
> Chance is the probability any one beat fires, so below 1 it stops being
> a metronome and becomes flicker -- a lamp on a bad circuit, frames
> dropping out. Softness ramps the edges instead of switching, as a
> fraction of the beat, capped at half the width so a soft pulse still
> reaches the top.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `rate` | Rate (Hz) | float | 0 … 5 (step 0.01) | 2 | ○ |  |
| `width` | Width | float | 0 … 1 (step 0.01) | 0.5 | ○ |  |
| `chance` | Chance | float | 0 … 1 (step 0.01) | 1 | ○ |  |
| `softness` | Softness | float | 0 … 0.5 (step 0.01) | 0 | ○ |  |
| `seed` | Seed | int | 0 … 999 | 0 | ○ |  |
| `amplitude` | Amplitude | float | free number (typed) | 1 | ○ |  |
| `offset` | Offset | float | free number (typed) | 0 | ○ |  |

#### Value

id `value` · no input ports

Summary: One number that can drive several parameters at once.

> A number, standing still -- for driving several knobs from one place.
>
> No port on its field: a signal wired into it would come straight back
> out, so the node would be a length of wire with a card on it.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `value` | Value | float | free number (typed) | 1 | ○ |  |

#### Time

id `time` · no input ports · always moving

Summary: The current time, in seconds, frames or 0 to 1 across the comp.

> Time: the time where it is read. Outside any time module that is the
> comp's; wired into a module behind a Time Offset or a Freeze Frame, it
> is that branch's time, so it reads out what the branch sees. In seconds,
> in frames of the comp, or 0 to 1 from the comp's start to its end.
>
> How it works:
>
> The one modulator that reads the comp: from the clock, which carries it
> on the page and on the render thread alike.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `unit` | Unit | enum | 0=Seconds, 1=Frames, 2=0–1 across the comp | 0 (Seconds) | ○ | 0–1 holds at 0 before the comp and 1 after |

#### Step Sequencer

id `stepSequencer`

Summary: Plays a row of values in turn, round and round.

> A row of values played in turn, Rate steps a second, round and round --
> a melody for a knob. Glide is the share of each step spent sliding
> into the next, eased, rather than jumping on the beat.
>
> How it works:
>
> The steps are set on the card as bars, so they are params the card
> edits itself: no rows, no ports.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `s0`, `s1`, `s2`, `s3`, … | (editor data) | float | edited by the card's own editor | — | none | 16 hidden params; no row, no port, not exposable |
| `steps` | Steps | int | 2 … 16 | 8 | ○ |  |
| `rate` | Rate (steps/s) | float | 0 … 16 (step 0.05) | 4 | ○ |  |
| `glide` | Glide | float | 0 … 1 (step 0.01) | 0 | ○ |  |
| `amplitude` | Amplitude | float | free number (typed) | 1 | ○ |  |
| `offset` | Offset | float | free number (typed) | 0 | ○ |  |

#### Bézier

id `bezier`

Summary: Goes from one value to another over time, along an eased curve.

> From one value to another over a time, along a curve: 1 to 10 in five
> seconds, straight; 0 to 500 in a minute, easing in, there and back.
>
> The curve is a cubic Bézier, as CSS eases with: Linear, Ease In, Ease Out,
> Ease In-Out and Overshoot are set ones, and dragging either handle on the
> card's graph makes it Custom. A handle can go above or below the box, so
> the value can run past To and settle back.
>
> It reads the comp clock, so it starts over when the transport goes back
> to the start, and a render replays it exactly. Once holds To at the end;
> Loop starts again from From; Ping-pong comes back down the same curve.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `x1`, `y1`, `x2`, `y2` | (editor data) | float | x 0 … 1, y -0.6 … 1.6; dragged on the card's graph | 0.42, 0, 0.58, 1 | none | Custom's handles; 4 hidden params; no row, no port, not exposable; read only when Easing is Custom |
| `from` | From | float | free number (typed) | 0 | ○ |  |
| `to` | To | float | free number (typed) | 1 | ○ |  |
| `duration` | Duration (s) | float | 0 … 120 (step 0.1) | 5 | ○ | 0 jumps straight to To |
| `delay` | Delay (s) | float | 0 … 60 (step 0.1) | 0 | ○ | holds From until it is over |
| `easing` | Easing | enum | 0=Linear, 1=Ease In, 2=Ease Out, 3=Ease In-Out, 4=Overshoot, 5=Custom | 0 (Linear) | none | presets are CSS's handles (Overshoot 0.34, 1.56, 0.64, 1) |
| `repeat` | Repeat | enum | 0=Once, 1=Loop, 2=Ping-pong | 0 (Once) | none |  |

### Operators (Module menu)

#### Math

id `math` · goes per-pixel (outputs a field) when a picture reaches a port

Summary: Combines or reshapes numbers: add, multiply, power, sine, logarithm and more.

> Blender's Math node, trimmed to what a modulation chain reaches for.
> Absolute, Round and the functions after them read A only. Sine and
> Cosine take A in radians (multiply by 6.2832 for a turn per unit);
> Logarithm is the natural one, Exponent e to the A; Fraction is what is
> left after Floor, so it saws from 0 to 1. With a picture on A they are
> TouchDesigner's Function TOP, a channel at a time.
>
> Division by zero, a negative number to a fractional power, the square
> root of a negative number and the logarithm of zero or less all give 0,
> a flat zero that is easy to diagnose. Exponent holds A at 11.
>
> How it works:
>
> Those cases return 0 rather than Infinity or NaN: a param that received
> either would hand the shader garbage. Exponent stops at 11 because a
> half-float picture would overflow beyond it.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `op` | Operation | enum | 0=Add, 1=Subtract, 2=Multiply, 3=Divide, 4=Minimum, 5=Maximum, 6=Power, 7=Modulo, 8=Absolute, 9=Round, 10=Square Root, 11=Sine, 12=Cosine, 13=Logarithm, 14=Exponent, 15=Floor, 16=Fraction | 0 (Add) | none |  |
| `a` | A | float | free number (typed) | 0 | ○ |  |
| `b` | B | float | free number (typed) | 0 | ○ | unused by Absolute, Round and the operations after them |

#### Formula

menu entry `formula` · node type `modulator` with `formula.expression` · Module → Math · [formula.ts](src/engine/formula.ts)

Summary: A number from an expression you write, like sin(t * 2) * a + b, with four inputs.

> The expression is typed on the card and applied a moment after typing
> stops, at Enter, or when the field loses focus. It is parsed by the app's own small grammar
> and never run as JavaScript, so a shared file can only do arithmetic.
> One that can't be read says where and puts out 0.
>
> It reads `a`, `b`, `c`, `d` (the rows, each a port), `t` (the time it is
> read at, in seconds: the branch's, behind a time module), `pi`, `tau`,
> `e`; numbers; `+ - * / %`, `^` (power, right to left); `< <= > >= ==
> !=` and `&& || !` (1 or 0); `cond ? x : y`; and `sin cos tan asin acos
> atan` (`atan(y, x)` too) `abs sign floor ceil round fract sqrt exp log
> pow mod min max clamp(x, lo, hi) mix(x, y, k) step(edge, x)
> smoothstep(lo, hi, x)`. As in Math, what would be Infinity or NaN is 0.
> It moves on its own when it reads `t`; its range (for Map Range's Auto
> range) is worked out from the expression where it can be.
>
> How it works:
>
> The expression is the module: its `modulatorId` is `formula:` and a hash of the expression, made again from `formula.expression` on load.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `a` | A | float | free number (typed) | 1 | ○ | 0 by default in a document; a new Formula starts at 1 |
| `b` | B | float | free number (typed) | 0 | ○ |  |
| `c` | C | float | free number (typed) | 0 | ○ |  |
| `d` | D | float | free number (typed) | 0 | ○ |  |

#### Map Range

id `map` · goes per-pixel (outputs a field) when a picture reaches a port

Summary: Rescales a value from one range to another.

> Blender's Map Range: take a value from one range to another.
>
> The node that turns a signal into a knob's units -- an LFO's -1..1 into
> 200..400 lines. The output always stays inside the To range: that is
> what the node is asked for, so there is no Clamp toggle to forget. With
> Auto range on, the From range is the input's own, and nothing has to be
> typed but where it should land.
>
> Stepped snaps the way across into Steps + 1 levels; Smooth eases it, so
> a triangle lingers at its ends like a sine.
>
> How it works:
>
> Stepped quantizes the way across; Smooth eases it with an S-curve.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `interpolation` | Interpolation | enum | 0=Linear, 1=Stepped, 2=Smooth | 0 (Linear) | none |  |
| `x` | Value | float | free number (typed) | 0 | ○ |  |
| `auto` | Auto range | bool | on / off | true | none |  |
| `fromMin` | From Min | float | free number (typed) | -1 | ○ |  |
| `fromMax` | From Max | float | free number (typed) | 1 | ○ |  |
| `toMin` | To Min | float | free number (typed) | 0 | ○ |  |
| `toMax` | To Max | float | free number (typed) | 1 | ○ |  |
| `steps` | Steps | int | 1 … 32 | 4 | ○ |  |

#### Image Statistic

id `statistic` · measures a picture on its main input · no input ports

Summary: Reads a number from a picture, like its average brightness.

> A picture back into a number -- Blender's Attribute Statistic, over
> pixels. Wire a video in and its brightness can drive a glitch, so the
> picture itself sets how hard it breaks up.
>
> In an export, a knob it drives follows the picture on the same frame. In
> a viewer it lands a frame or so later, so the page never waits for it.
> The number is the picture's brightness, 0..1 for any ordinary picture.
>
> How it works:
>
> It is measured by the renderer as part of the frame, before anything
> reading it is drawn; a viewer reads it back without making the page
> wait. The value is luminance, as Blender turns a colour into a float.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `statistic` | Statistic | enum | 0=Mean, 1=Minimum, 2=Maximum, 3=Range, 4=Std Dev | 0 (Mean) | none |  |

#### Tracker

id `tracker` · Module menu, under Math · reads a picture on its main input, analysed on a click · outputs `mod:x`, `mod:y` · no input ports

Summary: Follows a point as the picture moves and puts out where it is, as X and Y.

> A point placed on one frame, followed as the picture moves: X and Y out.
> Wire X and Y into a point's axes --
> a Lens's centre, a Text's position -- and it sticks to what was tracked.
>
> Tracking goes frame after frame, which a viewer that can jump anywhere
> can't do as it plays, so the card's Analyse runs through the comp once,
> like a bake, and the path is saved with the project. The outputs play
> the path back: Smoothing, Responsiveness, Offset, Units and Before / After
> apply then, without analysing again. Changing anything else (the
> picture coming in, the point, a tracking setting, the comp) marks the
> path out of date on the card, and keeps it until Analyse runs again.
>
> The point is placed on the card's preview of the picture coming in
> (on Auto: shown while the Tracker is selected): a click puts it there,
> on the frame the playhead is on, and drags it. The boxes show the
> pattern and the search area; once analysed, the path is drawn over the
> picture, and a ring follows it at the playhead.
>
> How it tracks (Pattern Size through On Loss) is folded on the card under
> Matching (Pattern Size through Adapt) and Advanced (the rest); the Point, its frame and how the path plays stay in view.
>
> Under Min Confidence the frame is lost, and On Loss says what happens:
> Stop ends the path there, Hold keeps the point still, Predict carries it
> on at its last speed and searches wider until it finds it again. Adapt
> lets the pattern follow a slow change of look. X and Y are in uv (0..1
> from the bottom left, as a point param), pixels of the picture, or -1..1
> from its centre; before Analyse has run they are the Point.
>
> How it works:
>
> Each frame the pattern (a square of Pattern Size pixels round the point,
> in the picture's own pixels) is searched for within Search Size, from
> where the last move says it went; found by normalised cross-correlation on
> a small copy of the picture, then placed between pixels by Lucas–Kanade.
> Each frame is scored by how much what it landed on looks like what it was
> on the last frame it was sure of (so a slow turn or fade keeps it sure),
> lowered when tracking back one frame doesn't land where it started.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `point` | Point | vec2 | 0 … 1 (step 0.001) | [0.5, 0.5] | none | the point to follow, in uv |
| `at` | On frame at (s) | float | free number (typed) | 0 | none | the comp time the point is placed on |
| `pattern` | Pattern Size | float | 8 … 256 (step 1) | 32 | none | section Matching; pixels of the picture coming in |
| `search` | Search Size | float | 16 … 512 (step 1) | 96 | none | section Matching; pixels; the point may move (Search − Pattern) / 2 a frame |
| `motion` | Motion | enum | 0=Position, 1=Position + Scale, 2=Position + Scale + Rotation | 0 (Position) | none | section Matching |
| `channel` | Channel | enum | 0=Luminance, 1=Red, 2=Green, 3=Blue, 4=Saturation | 0 (Luminance) | none | section Matching |
| `preBlur` | Pre-blur | float | 0 … 4 (step 0.05) | 0.5 | none | section Matching; pixels of the analysed picture |
| `adapt` | Adapt | float | 0 … 1 (step 0.01) | 0.1 | none | section Matching |
| `analysis` | Analysis Size | enum | 0=512, 1=1024, 2=2048, 3=Full | 1 (1024) | none | section Advanced; the long side the picture is analysed at |
| `subpixel` | Subpixel | bool | on / off | true | none | section Advanced |
| `minConfidence` | Min Confidence | float | 0 … 1 (step 0.01) | 0.6 | none | section Advanced |
| `onLoss` | On Loss | enum | 0=Stop, 1=Hold, 2=Predict | 2 (Predict) | none | section Advanced |
| `smoothing` | Smoothing | float | 0 … 1 (step 0.01) | 0.2 | none | One Euro, run both ways over the path |
| `responsiveness` | Responsiveness | float | 0 … 1 (step 0.01) | 0.5 | none | active when `params.smoothing > 0` |
| `offset` | Offset | vec2 | -1 … 1 (step 0.001) | [0, 0] | none | added to the path, in uv |
| `units` | Units | enum | 0=0–1, 1=Pixels, 2=Centred −1..1 | 0 (0–1) | none |  |
| `outside` | Before / After | enum | 0=Hold, 1=Carry on | 0 (Hold) | none | before the first tracked frame and after the last |

#### Sample & Hold

id `sampleHold` · looks at its inputs at other moments in time

Summary: Holds its input and takes a new reading now and then, turning smooth motion into steps.

> Holds its Input still and takes a fresh reading now and then: Rate times
> a second, or each time Trigger switches on. An LFO through it becomes a
> staircase; a Noise becomes random steps.
>
> How it works:
>
> It reads the Input at the moment of the last sample rather than keeping
> one, so it stays a function of time and a render replays it exactly.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `input` | Input | float | free number (typed) | 0 | ○ |  |
| `mode` | Mode | enum | 0=Rate, 1=Trigger | 0 (Rate) | none |  |
| `rate` | Rate (Hz) | float | 0.01 … 30 (step 0.01) | 4 | ○ | active when `params.mode !== 1` |
| `trigger` | Trigger | float | free number (typed) | 0 | ○ | active when `params.mode === 1` |

#### Smooth

id `smooth` · looks at its inputs at other moments in time

Summary: Calms a jittery value into smooth glides.

> Its Input, smoothed over the last Time seconds: jitter calmed, jumps
> turned into glides. Recent moments count most -- the weights fall away
> exponentially -- so it lags behind like a damped needle rather than
> blurring evenly. Nothing before the start: the window is cut at 0.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `input` | Input | float | free number (typed) | 0 | ○ |  |
| `time` | Time (s) | float | 0 … 10 (step 0.01) | 0.5 | ○ |  |

#### Envelope

id `envelope` · looks at its inputs at other moments in time

Summary: Rises and falls each time its gate switches on, like a synth envelope.

> Attack, decay, sustain, release -- a synth envelope, played by a gate.
> When Gate switches on the output rises to 1 over Attack, falls to
> Sustain over Decay and stays there while the gate is held; when it
> switches off it fades to 0 over Release, from wherever it had got to.
> A Pulse into Gate makes a flash on every beat.
>
> How it works:
>
> Worked out from when the gate last switched, read back through its
> input, so it is a function of time like everything else here.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `gate` | Gate | float | free number (typed) | 0 | ○ |  |
| `attack` | Attack (s) | float | 0 … 5 (step 0.01) | 0.05 | ○ |  |
| `decay` | Decay (s) | float | 0 … 5 (step 0.01) | 0.2 | ○ |  |
| `sustain` | Sustain | float | 0 … 1 (step 0.01) | 0.5 | ○ |  |
| `release` | Release (s) | float | 0 … 5 (step 0.01) | 0.3 | ○ |  |
| `amplitude` | Amplitude | float | free number (typed) | 1 | ○ |  |
| `offset` | Offset | float | free number (typed) | 0 | ○ |  |

### Audio (Module menu; Beat in AI → Analyse)

These nodes take an Audio node's sound on a green `sound` port (on the title
row) and put out what they hear, 0..1, then Amplitude and Offset. They read
an analysis of the whole file that runs once, in the background, when the
file loads: 40 log-spaced bands, 100 readings a second. The analysis also
splits each sound into its percussive part (hits, noise bursts) and its
harmonic part (steady tones), and measures each reading's brightness, noisiness
and change. Until it finishes,
and wherever the clip is silent (outside its Offset and trim, unlooped), they
read 0. They follow the audio node's Offset, Loop and trim (In, Out), so what
they read lines up with what is heard, in an export too. Audio Level also
follows the audio node's fades (Loudness and Change; see Measure); Onset and Beat do not. A viewer showing a chain they drive plays
the sound they read. With no sound wired in, they put out 0 and do not keep
the frame loop running.

Audio Level and Onset share the band settings. **Band** picks a frequency range in Hz: 0=Full
(20–20k), 1=Sub (20–60), 2=Bass (60–250), 3=Low Mid (250–500), 4=Mid
(500–2k), 5=High Mid (2k–4k), 6=Presence (4k–6k), 7=Brilliance (6k–20k),
8=Custom. **Low/High (Hz)** are used only with Custom.

#### Audio Level

id `audioLevel` · reads sound on its `sound` port

Summary: How loud a band of the music is, from 0 to 1.

> How loud a band of the music is, 0..1 -- 1 at the loudest the band gets
> in the file. The bass of a track into Bloom's intensity, and the picture
> swells on every kick.
>
> Attack and Release follow it as a meter's needle does, rising and
> falling no faster than they say, so a knob it drives moves rather than
> flickers. Decibels reads it as an ear does: quiet detail counts for
> more, and the top end is compressed (−48 dB reads 0).
>
> **Measure** picks what is followed: Loudness (the band, as above),
> Brightness (the sound's centre of energy on a log scale: 100 Hz reads 0,
> 8 kHz reads 1), Noisiness (0 for a pure tone, 1 for white noise) or
> Change (how fast the sound is changing, 1 at the file's busiest moment).
> **Source** (Loudness only) listens to the whole sound, only its percussive
> part (hits, noise bursts) or only its harmonic part (steady tones). Band,
> Low/High and Scale belong to Loudness only. Loudness and Change follow the
> audio node's fades; Brightness and Noisiness are not scaled by a fade, and
> read 0 only once the sound is silent. Every reading is 0 outside the clip.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `measure` | Measure | enum | 0=Loudness, 1=Brightness, 2=Noisiness, 3=Change | 0 (Loudness) | none |  |
| `source` | Source | enum | 0=Full, 1=Percussive, 2=Harmonic | 0 (Full) | none | Loudness only |
| `band` | Band | enum | see above | 2 (Bass) | none | Loudness only |
| `low` | Low (Hz) | float | free number (typed) | 60 | ○ | Custom only; Loudness only |
| `high` | High (Hz) | float | free number (typed) | 250 | ○ | Custom only; Loudness only |
| `attack` | Attack (s) | float | 0 … 1 (step 0.005) | 0.01 | ○ |  |
| `release` | Release (s) | float | 0 … 2 (step 0.01) | 0.15 | ○ |  |
| `scale` | Scale | enum | 0=Linear, 1=Decibels | 0 (Linear) | none | Loudness only; section Advanced |
| `amplitude` | Amplitude | float | free number (typed) | 1 | ○ | section Advanced |
| `offset` | Offset | float | free number (typed) | 0 | ○ | section Advanced |

#### Onset

id `onset` · reads sound on its `sound` port

Summary: Jumps to 1 on every hit in the music, then back to 0.

> 1 for a moment on every hit in the music -- a drum, a pluck, a new note
> -- and 0 between. Into an Envelope's Gate for a flash on every beat, or
> a Sample & Hold's Trigger for a new random value on each.
>
> Threshold is how far a hit has to stand out from the half second around
> it (spectral flux over the chosen band); Hold, the shortest gap between
> two, so a roll does not fire on every stroke; Length, how long the output
> stays at 1.
>
> **Source** looks for hits in the whole sound, only its percussive part (a
> drum, not a chord change) or only its harmonic part (note changes, not
> drums). Percussive also takes an abrupt note start, but ignores smooth or
> legato changes and sustained chords.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `source` | Source | enum | 0=Full, 1=Percussive, 2=Harmonic | 0 (Full) | none |  |
| `band` | Band | enum | see above | 2 (Bass) | none |  |
| `low` | Low (Hz) | float | free number (typed) | 60 | ○ | Custom only |
| `high` | High (Hz) | float | free number (typed) | 250 | ○ | Custom only |
| `threshold` | Threshold | float | 0 … 1 (step 0.01) | 0.15 | ○ |  |
| `hold` | Hold (s) | float | 0.01 … 2 (step 0.01) | 0.1 | ○ |  |
| `length` | Length (s) | float | 0.01 … 1 (step 0.01) | 0.05 | ○ |  |
| `amplitude` | Amplitude | float | free number (typed) | 1 | ○ | section Advanced |
| `offset` | Offset | float | free number (typed) | 0 | ○ | section Advanced |

#### Beat

id `beat` · reads sound on its `sound` port · [beats.ts](src/engine/beats.ts)

Summary: Follows the music's beat and bars, found by a model running in your browser.

> The music's beat as a signal, from a model that listened to the whole
> file in the browser: a Pulse falling away over Length on every beat, a
> Gate held for Length, the Beat or Bar phase (0..1 from one beat or bar
> to the next, for anything that should move in time), a pulse on each
> bar's first beat, which beat of the bar it is, or the tempo. Unlike
> Onset it knows where the beat is when nothing is hit on it, and which
> beat starts the bar.
>
> The file is listened to once, on the page, the first time a Beat's card
> hears it (a ≈ 120 MB download the first time ever, then a few seconds);
> until then it reads 0. After that it is the same in every viewer and
> exact in an export. Past the last beat, phases carry on at the usual
> gap.
>
> How it works:
>
> The model is Beat This! (MIT). Once the file has been listened to,
> reading it is a lookup; the render thread gets a copy.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `output` | Output | enum | 0=Pulse, 1=Gate, 2=Beat phase, 3=Bar phase, 4=Downbeat pulse, 5=Beat in bar, 6=Tempo (BPM) | 0 (Pulse) | none |  |
| `length` | Length (s) | float | 0.01 … 2 (step 0.01) | 0.2 | ○ | Pulse, Gate and Downbeat pulse only |
| `amplitude` | Amplitude | float | free number (typed) | 1 | ○ |  |
| `offset` | Offset | float | free number (typed) | 0 | ○ |  |

---

## 6. Sound synths (Input menu)

[synth.ts](src/engine/synth.ts) · Input → Sound

A synth is an `audio` node with `synth` set: instead of a file, its sound
is made from the settings on its card, and it works everywhere a file's
Audio node does -- the green `sound` output, Gain, Offset, Loop and Mute,
the analysis that Spectrum, Audio Level and Onset read, and the sound in an
MP4 or WebM. Only the settings are saved; the sound is made again when a
document loads, and again a moment after a setting changes. The same
settings and seed always make the same sound. A synth takes no file and
has no param ports.

Each is made to loop without a seam, peaking at -6 dBFS. Both share the
envelope settings:

| Key | Label | Type | Range / options | Default | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- |
| `envelope` | Envelope | enum | 0=Steady, 1=Hit, 2=Swell | 0 (Steady) | Steady sounds all the time; Hit strikes and dies away every Repeat; Swell fades in and out every Repeat |
| `repeat` | Repeat (s) | float | 0.1 … 8 (step 0.01) | 0.5 | active unless Steady; the sound's length, so how often it repeats when looped |
| `decay` | Decay (s) | float | 0.01 … 4 (step 0.01) | 0.25 | active when Hit; the time to fall 60 dB |

#### Noise Synth

`synth.kind` `noise`

Summary: Makes a looping noise sound, from white to deep rumble.

> Makes a looping noise sound from the settings on its card, with no
> file. Color runs from white noise through pink to brown, a deep rumble
> (and the other way to blue and violet); Low Cut and High Cut remove
> everything below and above. Steady sounds all the time; Hit and Swell
> repeat every Repeat seconds. Its green sound output goes wherever an
> Audio node's does: a Viewer, a Renderer, or a module that reads sound.

Noise of a colour, between two cuts. Made in the frequency domain (a random
phase per frequency, its level set by the colour) and turned back into
samples in one go, so a Steady noise repeats seamlessly every 2^19 samples
(about 11 s). The node's `seed` picks the noise.

| Key | Label | Type | Range / options | Default | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- |
| `color` | Color | enum | 0=White, 1=Pink, 2=Brown, 3=Blue, 4=Violet | 0 (White) | power per Hz flat, falling 3 or 6 dB an octave, or rising 3 or 6 |
| `lowCut` | Low Cut (Hz) | float | 20 … 20000 (typed) | 20 | nothing below |
| `highCut` | High Cut (Hz) | float | 20 … 20000 (typed) | 20000 | nothing above |

#### Tone Synth

`synth.kind` `tone`

Summary: Makes one looping note with its harmonics.

> Makes one looping note from the settings on its card, with no file.
> Note, Octave and Fine pick the pitch (A4 is 440 Hz); Harmonics, Rolloff
> and Even Harmonics shape the tone, from a pure sine at 1 harmonic to
> sawtooth-like, triangle-like or square-like sounds. Steady holds the
> note; Hit and Swell repeat it every Repeat seconds. Its green sound
> output goes wherever an Audio node's does.

One note: a sine and its harmonics. A Steady tone is 4 s long, each
harmonic nudged to a whole number of cycles in it (a few cents at most) so
it loops without a click. Harmonics above half the sample rate are left out.

| Key | Label | Type | Range / options | Default | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- |
| `note` | Note | enum | 0=C … 11=B (sharps between) | 9 (A) |  |
| `octave` | Octave | int | 0 … 8 | 3 | A4 = 440 Hz, equal temperament |
| `fine` | Fine (cents) | float | -100 … 100 (step 1) | 0 |  |
| `harmonics` | Harmonics | int | 1 … 32 | 8 | 1 is a pure sine |
| `rolloff` | Rolloff | float | 0 … 3 (step 0.05) | 1.5 | harmonic k at 1/k^Rolloff: 1 like a sawtooth, 2 like a triangle |
| `even` | Even Harmonics | float | 0 … 1 (step 0.01) | 1 | scales the even ones: 0 leaves the odd ones only, square-like |

---

## 7. AI modules (AI menu)

[openrouter.ts](src/engine/ai/openrouter.ts) · [googleAi.ts](src/engine/ai/googleAi.ts) · [providers.ts](src/engine/ai/providers.ts) · [aiImages.ts](src/state/aiImages.ts) · AI menu

AI modules ask a model for what they put out, straight from the browser:
the site has no server. Two providers, each with the visitor's own account,
set up in Settings → AI (the note under the AI menu's Generate list links
to it):

| Provider | Access | Models | Cost shown |
| :-- | :-- | :-- | :-- |
| [OpenRouter](https://openrouter.ai) | **Sign in with OpenRouter** (OAuth with PKCE), or a pasted API key | its image models (`/api/v1/images/models`) | yes, when it says |
| [Google AI Studio](https://aistudio.google.com/apikey) | a pasted API key (Google has no sign-in a site like this can use) | the Gemini image models ("Nano Banana") the key can use (`models.list`, ids with `image` that `generateContent`), one entry per name (a release id over its preview); the list is kept in this browser for a day (`comp.googleModels`), so reloads make no call. Imagen is shut down in the Gemini API | no |

The keys stay in this browser's settings (`comp.settings`: `openrouterKey`,
`googleAiKey`), never in a document, a preset or the clipboard. Each
generation is billed to the account of the model's provider. One Generate is one request; with Google, the first one on a browser may be two if Google refuses the documented place for size and shape (the other form is then remembered, in `comp.googleImageConfig`). **Cancel** stops waiting, but the provider may still finish the picture and bill it.

Nothing is asked until **Generate** is pressed: changing the prompt, the
picture wired in or a setting does not make a new picture by itself.

#### Prompt

node type `text` · Input → Text → Prompt (called Text before)

Summary: Words to feed into AI modules, Text Mask or a Text module.

> Words in a box, for the modules that take text: an AI Image's Prompt,
> Text Mask's Words or a Text module's Words. Type or paste them on the
> card and wire its pink output to a text port; one Prompt can feed several
> modules. It makes no picture of its own.

Words in a box. Its pink `text` output goes into a `text:` port -- an AI
Image's Prompt, Text Mask's Words, or a Text module's Words. One Prompt can feed several modules. The text is saved with
the document, up to 20 000 characters.

#### AI Image

node type `aiImage`

Summary: Makes a picture from a prompt, a picture, or both, with an online model and your own key.

> Asks an online model for a picture, from a prompt, a picture or both,
> and puts it out like an Image. Wire a Prompt (or a Describe) into
> Prompt, a live picture into Image, or both, choose a model, Aspect and
> Size, and press Generate. Nothing is asked until you press it, and every
> Generate is billed to your own OpenRouter or Google AI Studio account,
> set up in Settings → AI.

A picture from a model, on its blue output like an Image's: every viewer,
export and effect takes it as it would a file.

Inputs, both optional; Generate needs at least one:

| Port | Handle | Takes | Counts when |
| :-- | :-- | :-- | :-- |
| Prompt | `text:prompt` | a Prompt or Describe module | its text is not blank |
| Image | `reference` | a live picture | something upstream makes a picture |

| Wired | What is asked |
| :-- | :-- |
| Prompt only | a picture from the text |
| Image only | a variation: the picture, with the fixed prompt "Create a new variation of this image, keeping its subject, composition and style." (shown greyed on the card) |
| Both | the picture, changed as the prompt says |

The Image input is captured once, at Generate, as the chain upstream looks at
that moment (the current transport time), at most 1536 px on its long side,
as a JPEG. While an image is wired the model menu lists only models that
take a picture.

| Field | Label | Options | Default | Notes |
| :-- | :-- | :-- | :-- | :-- |
| `provider` + `model` | Model | the image models of every provider with a key, one heading per provider | OpenRouter `google/gemini-2.5-flash-image` (Google `gemini-3.1-flash-lite-image`, the cheapest current one, when only Google has a key) | only models the saved keys can use are listed; a saved model that is not among them (its provider has no key, or it cannot work from a wired picture) shows as "Pick a model" and keeps Generate off |
| `aspectRatio` | Aspect | 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3 | 1:1 | |
| `resolution` | Size | 1K, 2K, 4K | 1K | only the sizes the model takes, when known (Gemini Flash Lite Image: 1K) |

No param ports: nothing on it can be wired from a modulator. The card shows
the last picture's size and, when OpenRouter says, what it cost. A failed
generation says why on the card (no credit, a refused key, moderation, a
model that sent nothing back) and keeps the picture it had.

The picture is kept in this browser's IndexedDB (`comp.media`) under the
node's `resultId`, so it comes back after a reload; copies, undo and redo
carry it as they do an Image's picture. A kept picture the open document no
longer uses is forgotten a month after it was made.

#### In-browser models: Depth, Depth Relight, Re-angle, Cut Out, Magic Mask, Text Mask, Describe, Fill, Colorize (and Beat)

AI menu → Analyse · [inference.ts](src/engine/inference.ts) · [inferenceModels.ts](src/engine/inferenceModels.ts)

Effect modules (node type `effect`, category `ai`) that run a model on the
picture wired into them, **in the visitor's browser**: no key, no account,
no cost. Each model downloads once the first time it runs, then comes from
the browser's cache. Settings → AI → **Run models on** picks where:
**Automatic** (each model on its preferred device first, then the usual
fallbacks, as the table below says; GPU through WebGPU, else the CPU --
WebAssembly, slow), **NPU** (through WebNN where the browser offers it, with each
model's input sizes pinned as WebNN needs -- Depth sees a square picture;
else the GPU, else the CPU, and the card says so; slower than the GPU on
these models, but lighter on power), **GPU** (WebGPU, else the CPU) or
**CPU**. A change reloads the models
on the new device when next used. A model that loads on a device but fails
to run there (a GPU past one of its limits, say) moves to the next one
on its own. The card shows the download as it
goes, the device in use, and the time each frame takes.

The model's answer -- one channel, 0..1 -- is read by the module's shader
as `u_model`; the params below shape it, and changing them never runs the
model again. The model runs only when the picture coming in changes (or,
for Magic Mask, a point moves), so a still image runs it once. In a live viewer the answer arrives a frame or
more behind the picture (on video, a matte or depth map trails fast
motion slightly); an export waits for each frame's own answer, so a
rendered file is exact. Until the first answer the module reads a neutral
value (mid depth; a matte that keeps everything).

**Bake model**, at the foot of every card here but Describe's: the comp is
run through once, like an export, each frame waiting for its own answer,
and every frame's answer is kept ([modelBakes.ts](src/engine/modelBakes.ts),
[state/modelBakes.ts](src/state/modelBakes.ts)). Playing, scrubbing and
exporting then read the frame's answer at once, and the model is not
asked: a video plays with its matte or depth exactly in step. The bake is
the model's answers, not the module's picture, so every setting that only
shapes the answer (the params below, Mix, anything after the module) stays
live. What the model is asked -- the picture coming in, the model picked,
Depth's Detail, Magic Mask's points, Text Mask's words, Fill's holes and
Grow -- or the comp's frame rate changing lets the bake go, and the card
says so. A bake covers the work area while there is one, else the whole
comp; times outside it run the model live. A Renderer at another frame
rate reads the nearest baked frame. A bake is kept on this device (the
browser's media cache, never in the document or a project file) and comes
back after a reload while what it was made from still holds -- a picture
this device never kept leaves it to the session. It takes at most 768 MB
(frames asking the same question share one answer). Behind a time module
(Time Offset, Freeze Frame, Time Remap, Time Range) the module reads the
bake at its branch's time, since everything feeding it runs at that time
too; behind an Image Set every picture is baked, each with its own
answers.

| Model | Used by | Download | Licence | Automatic runs it on |
| :-- | :-- | :-- | :-- | :-- |
| Depth Anything V2 Small (`onnx-community/depth-anything-v2-small`) | Depth, Depth Relight, Re-angle | ≈ 50 MB | Apache-2.0 | GPU, then CPU |
| RMBG-1.4 (`briaai/RMBG-1.4`) | Cut Out, Anything | ≈ 45 MB | CC BY-NC 4.0: non-commercial use only | GPU, then CPU |
| MediaPipe Selfie Segmentation (`onnx-community/mediapipe_selfie_segmentation`) | Cut Out, People (fast) | ≈ 0.5 MB | Apache-2.0 | NPU, then GPU, then CPU |
| EdgeTAM (`onnx-community/EdgeTAM-ONNX`) | Magic Mask | ≈ 31 MB | Apache-2.0 | GPU, then CPU (never the NPU) |
| CLIPSeg (`Xenova/clipseg-rd64-refined`) | Text Mask | ≈ 115 MB (≈ 139 MB on the CPU) | Apache-2.0 | GPU, then CPU (never the NPU) |
| Florence-2 base (`onnx-community/Florence-2-base-ft`) | Describe | ≈ 360 MB (≈ 275 MB on the CPU) | MIT | GPU, then CPU (never the NPU) |
| MI-GAN (`anyisalin/migan-onnx`, the whole pipeline) | Fill | ≈ 28 MB | MIT | GPU, then CPU (never the NPU) |
| DDColor Tiny fp16 (`edgetools/ddcolor`) | Colorize (Compact) | ≈ 130 MB | Apache-2.0 | CPU (never the NPU) |
| DDColor Tiny fp32 (`RekluzLabs/MakoKolor`) | Colorize (Full fp32) | ≈ 270 MB | Apache-2.0 | GPU (never the NPU) |
| Beat This! (`musetric/beat-this-onnx`) | Beat (a modulator: section 6) | ≈ 120 MB | MIT | GPU, then CPU (never the NPU) |

#### Depth

id `depth`

Summary: Guesses how far away each part of the picture is: near white, far black.

> How far away each part of the picture is: near is white, far is black.
> The model's depth is relative, nearest to furthest within this picture;
> Near and Far pick the slice of it spread over the output, like Levels.
> Normal map turns that shaped depth into which way each surface faces
> (xyz as rgb, green up), for Remap's Normal Map mode or anything else.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `output` | Output | enum | 0=Depth map, 1=Fog, 2=Depth as alpha, 3=Normal map | 0 (Depth map) | ◇ | Fog fades the far part into Fog Color |
| `near` | Near | float | 0 … 1 (step 0.01) | 1 | ◇ | the model's value that becomes white |
| `far` | Far | float | 0 … 1 (step 0.01) | 0 | ◇ | the model's value that becomes black |
| `gamma` | Gamma | float | 0.2 … 5 (step 0.01) | 1 | ◇ |  |
| `invert` | Invert (far is white) | bool | — | false | ◇ |  |
| `fogColor` | Fog Color | color | — | [0.78, 0.8, 0.84] | ◇ | active when Output is Fog |
| `relief` | Relief | float | 0 … 10 (step 0.05) | 3 | ◇ | exaggerates the shape; active when Output is Normal map |
| `softness` | Softness | float | 0 … 1 (step 0.01) | 0.35 | ◇ | smooths the depth before its shape is read; active when Output is Normal map |
| `detail` | Detail | enum | 0=Standard (518), 1=High (770), 2=Very high (1036) | 0 (Standard (518)) | ◇ | the long side the model sees the picture at: sharper edges, each answer slower (about 2x at 770, 4x or more at 1036); a change runs the model again; 518 on the NPU |

#### Cut Out

id `cutOut`

Summary: Lifts the subject off its background.

> The subject lifted off its background. Anything runs RMBG-1.4: people,
> objects, products, animals. People (fast) runs MediaPipe's selfie model:
> coarser edges, but real time on live video. Shows the cut-out, the
> matte, or the background with the subject taken out.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `subject` | Subject | enum | 0=Anything, 1=People (fast) | 0 (Anything) | none | picks the model |
| `output` | Output | enum | 0=Cut out, 1=Matte, 2=Background | 0 (Cut out) | ◇ | Cut out keeps the subject in alpha; Matte is white on black |
| `edgeLow` | Edge Low | float | 0 … 1 (step 0.01) | 0.05 | ◇ | matte below this is fully out |
| `edgeHigh` | Edge High | float | 0 … 1 (step 0.01) | 0.95 | ◇ | matte above this is fully in |
| `invert` | Invert | bool | — | false | ◇ |  |

#### Magic Mask

id `magicMask`

Summary: Cuts out whatever you click on in the picture.

> Whatever is under the points, lifted off the rest, by EdgeTAM (a small
> Segment Anything model). Up to six points, each on something to keep
> (green, +) or to leave out (red, −), placed on the picture coming in, in
> the module's preview (Auto by default: shown while it is selected): click to add (the
> Keep / Leave out switch on the card picks which, Alt the other), drag to
> move, right-click to swap, double-click or drag off the picture to
> remove. The points are only shown there, never on the output. The picture is encoded once while it doesn't change, so moving a point only runs the
> model's small decoder. Output, edges and Invert work as Cut Out's.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `count`, `point`, `leave0`, `point1`, `leave1`, … | (editor data) | int, vec2, bool | edited by the card's own editor | 1 point, [0.5, 0.5], keep | none | 13 hidden params; no row, no port, not exposable. `point` is the first point (0..1 from the bottom left), as before |
| `output` | Output | enum | 0=Cut out, 1=Matte, 2=Background | 0 (Cut out) | ◇ | as Cut Out |
| `edgeLow` | Edge Low | float | 0 … 1 (step 0.01) | 0.05 | ◇ |  |
| `edgeHigh` | Edge High | float | 0 … 1 (step 0.01) | 0.95 | ◇ |  |
| `invert` | Invert | bool | — | false | ◇ |  |

#### Depth Relight

id `depthRelight`

Summary: Lights the scene again from a new direction, following its 3D shape.

> Light the picture again from a new direction, by its shape: the depth
> Depth's model guesses, turned into which way each surface faces, then
> lit like a 3D surface. Relight (Stylize) reads brightness as height,
> which embosses; this reads the scene's depth, so a face or a building
> turns towards the light. Flat parts facing the camera keep their
> brightness; slopes facing the light brighten and take its colour, slopes
> facing away darken. The model runs only when the picture changes, so
> moving the light is instant.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `output` | Output | enum | 0=Lit, 1=Shading, 2=Normal map | 0 (Lit) | ◇ | Normal map: xyz as rgb, for any module that wants one |
| `lightAngle` | Light Angle (°) | float | -180 … 180 (step 1) | 135 | ◇ | 0° from the right, 90° from the top |
| `lightHeight` | Light Height (°) | float | 5 … 90 (step 1) | 35 | ◇ | low lights carve relief |
| `strength` | Strength | float | 0 … 2 (step 0.01) | 1 | ◇ |  |
| `lightColor` | Light Color | color | — | [1, 0.94, 0.85] | ◇ |  |
| `relief` | Relief | float | 0 … 10 (step 0.05) | 3 | ◇ | exaggerates the shape |
| `softness` | Softness | float | 0 … 1 (step 0.01) | 0.35 | ◇ | smooths the depth before its shape is read |
| `shine` | Shine | float | 0 … 1 (step 0.01) | 0 | ◇ | a glossy highlight |
| `falloff` | Falloff | float | 0 … 1 (step 0.01) | 0 | ◇ | the light reaches near things more than far ones |
| `detail` | Detail | enum | 0=Standard (518), 1=High (770), 2=Very high (1036) | 0 (Standard (518)) | ◇ | as Depth's |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Re-angle

id `reangle` · [reangle.ts](src/engine/modules/reangle.ts) · maths mirrored in [reangle.ts](src/engine/reangle.ts) · extra picture inputs: `height` (Height)

Summary: Turns the view a few degrees by the picture's depth, so a head turns about a pivot; what it uncovers is filled from the background.

> Turn the view of a picture a few degrees, by its depth: the depth a
> model guesses in the browser (Depth Anything V2 Small, as Depth), or a
> Height map of your own. A head turns about the Pivot, near things slide
> over far ones and the frame keeps its scale. Depth Mesh shows the same
> idea as a grid you orbit; this works at full resolution, with the pivot
> you choose, and is steady down to a fraction of a degree, so Turn can be
> keyed or driven for a slow head turn.
>
> Turn moves the view to the right for a positive value (the subject turns
> to its left, as Depth Mesh's Orbit); Tilt looks from above. Depth is how
> far the nearest stands from the furthest, in picture heights. The Pivot
> is the spot that stays put: its own depth is the depth the turn is
> about, and it reads itself at any angle. Smoothing reads the depth
> through a small blur so noise doesn't ripple the warp.
>
> Near, Far and Gamma shape the depth as Depth's do (Far becomes 0, Near
> 1) before anything else reads it: everything behind Far is one flat
> plane and what lies between Far and Near gets the whole Depth range, so
> a far background no longer spends the range the subject needs. Output
> Depth shows it.
>
> What the turn uncovers has no picture, and it lies behind the subject,
> so Holes fills it from the background side of the edge, never the
> subject's. Where Tear says a hit is stretched too far, Holes looks for
> the background's edge nearby and fills from it. How it fills is the
> Holes setting:
>
> - Mirror background (the default) reads the background reflected across
>   its edge, keeping its texture and grain.
> - Extend background reads the edge itself, its colour carried across.
> - Stretch draws the stretched wall as it is.
> - Transparent leaves it empty for Fill to paint.
>
> The filled colour fades in over the wall's as the stretch passes Tear's
> limit, so the seam doesn't step; with no background within reach the
> wall stays. Zoom crops the edges the turn pulled in; Edge says what is
> read past the frame. Output shows where the holes are, or the depth
> used.
>
> Good to about 10 to 15 degrees: a depth guess is one view of the scene,
> so further round it runs out of picture, and flat faces keep a flat
> look. Height wired in is read as the depth (brightest is nearest) where
> it has any alpha, else the model's; the model still runs while Height is
> wired. The model runs when the picture (or Detail) changes.
>
> How it works:
>
> The depth raises the picture into a surface, and each pixel looks back
> along a ray through it.
>
> To find the background's edge, the shader walks on from a hit that Tear
> says is stretched too far, towards where the depth falls (up to 24 depth
> texels) until the surface flattens, then 2 texels more past the edge's
> mixed pixels. The pixel's ray is cut by the flat plane at that depth
> (where the background would be if it went on behind the subject).
> Height's depth is its luma.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `yaw` | Turn (°) | float | -30 … 30 (step 0.1) | 8 | ◇ | positive turns the subject to its left (the view moves right) |
| `pitch` | Tilt (°) | float | -30 … 30 (step 0.1) | 0 | ◇ | positive looks from above |
| `depth` | Depth | float | 0 … 1.5 (step 0.01) | 0.3 | ◇ | how far the nearest stands from the furthest, in picture heights |
| `near` | Near | float | 0 … 1 (step 0.01) | 1 | ◇ | as Depth's: the raw depth that becomes 1 |
| `far` | Far | float | 0 … 1 (step 0.01) | 0 | ◇ | as Depth's: the raw depth that becomes 0; everything behind is flat |
| `gamma` | Gamma | float | 0.2 … 5 (step 0.01) | 1 | ◇ | as Depth's: curves the shaped depth |
| `pivot` | Pivot | vec2 | 0 … 1 (step 0.001) | [0.5, 0.55] | ◇ | the spot that stays put, 0..1 from the bottom left; a dot on the preview |
| `holes` | Holes | enum | 0=Mirror background, 1=Extend background, 2=Stretch, 3=Transparent (for Fill) | 0 (Mirror background) | ◇ | what a torn wall becomes; Mirror and Extend fill it from the background's edge |
| `tear` | Tear | float | 0 … 1 (step 0.01) | 0.5 | ◇ | active unless `params.holes === 2` (Stretch); how stretched the uncovered side may get before it is left as a hole (output pixels per source texel, 1 + 8·(1 − Tear)²): 0 never tears, 1 tears at any stretching; sides turned towards the new view never tear |
| `smoothing` | Smoothing | float | 0 … 1 (step 0.01) | 0.3 | ◇ | the depth read through a small blur |
| `zoom` | Zoom | float | 1 … 1.5 (step 0.01) | 1 | ◇ | under Frame; scales up about the pivot |
| `edge` | Edge | enum | 0=Clamp, 1=Mirror, 2=Transparent | 0 (Clamp) | ◇ | under Frame; what is read past the frame |
| `output` | Output | enum | 0=Picture, 1=Holes, 2=Depth | 0 (Picture) | ◇ | Holes: white where torn or off the frame |
| `detail` | Detail | enum | 0=Standard (518), 1=High (770), 2=Very high (1036) | 0 (Standard (518)) | ◇ | as Depth's |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Text Mask

id `textMask` · Words port `text:prompt` (dashed pink), from a Text or a Describe

Summary: Finds what you describe in words, like sky or hair, and masks it.

> Where in the picture some words apply -- "sky", "the red car", "hair" --
> found by a model in the browser. The words come from the Words port, or,
> with nothing wired, from Find. The mask is soft and coarse: enough to
> grade the sky, tint the water or blur the background, not to cut hair
> out cleanly -- Cut Out and Magic Mask do that. Edge Low and High decide
> how sure the model must be; an answer that never passes 0.1 is nothing
> found. Output and Invert work as Cut Out's. Other words run the model
> again on the same picture.
>
> How it works:
>
> The model is CLIPSeg; it looks at the picture at 352 × 352. Its answer
> is scaled to its own peak, which is why Edge Low and High are relative
> to it.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `find` | Find | enum | 0=Sky, 1=Person, 2=Face, 3=Hair, 4=Clothes, 5=Water, 6=Tree, 7=Grass, 8=Building, 9=Road, 10=Car, 11=Animal, 12=Flower, 13=Food | 0 (Sky) | none | the words while nothing is wired into Words; greyed while words are wired |
| `output` | Output | enum | 0=Cut out, 1=Matte, 2=Background | 0 (Cut out) | ◇ | as Cut Out |
| `edgeLow` | Edge Low | float | 0 … 1 (step 0.01) | 0.35 | ◇ |  |
| `edgeHigh` | Edge High | float | 0 … 1 (step 0.01) | 0.75 | ◇ |  |
| `invert` | Invert | bool | — | false | ◇ |  |

#### Describe

node type `describe` · AI → Analyse · [describe.ts](src/state/describe.ts)

Summary: Writes a caption for a picture, to use as a prompt.

> Turns a picture into words. Wire a picture into Picture, choose how
> much Detail you want and press Describe: a model running in your browser
> writes a caption, which you can edit on the card. It comes out on the
> pink text port, ready for an AI Image's Prompt or Text Mask's Words. It
> runs only on the click, and the model downloads the first time.

A picture into words: Florence-2 in the browser looks at what is wired into
Picture (`reference`, captured as a still when Describe is pressed, as AI
Image's reference is) and writes a caption. Its words come out on its pink
`text` port, as a Prompt module's do -- into an AI Image's Prompt, to make a
picture like this one, or Text Mask's Words -- and can be edited on the card
first. Asked on a click, never per frame: a caption takes a second or more.
Runs in the page's own ML worker.

| Setting | Options | Default |
| :-- | :-- | :-- |
| Detail (`task`) | Caption (one line), Detailed, More detailed | Detailed |

#### Fill

id `fill` · extra input `mask`

Summary: Fills holes in the picture with what could plausibly be there.

> Fill the holes in a picture with what could plausibly be there, by
> MI-GAN in the browser: an object painted out, a gap closed, a clean
> plate made. Holes come from the picture's own transparency, from white
> in the Mask input, or both (Fill From) -- so Cut Out (Background) → Fill
> gives the scene without the person, and Magic Mask's matte into Mask
> removes whatever it picked. Grow widens the holes first (in the model's
> pixels), so outlines and halos go too. Every pixel outside the holes
> stays as it was; filled ones come out opaque. The model reads at most
> 1024 pixels on the long side, and runs only when the picture or the
> holes change.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `fillFrom` | Fill From | enum | 0=Transparent areas, 1=Mask (white), 2=Both | 2 (Both) | none | Mask with nothing wired fills nothing |
| `grow` | Grow | int | 0 … 24 | 4 | none | pixels the holes widen by |
| `output` | Output | enum | 0=Filled, 1=Fill only, 2=Holes | 0 (Filled) | ◇ | Fill only: just what it painted, in alpha; Holes: white where it filled |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

#### Colorize

id `colorize`

Summary: Gives a black-and-white picture plausible colour.

> Adds plausible colour to a black-and-white picture with an in-browser
> model: an old photograph, a flat film still, or a greyscale render. The
> picture keeps its own brightness and detail, while the model predicts
> only the colour.
>
> Model chooses between Compact (CPU · 130 MB) (runs on the CPU at
> 512 × 512) and Full fp32 (GPU · 270 MB) (runs faster on WebGPU at
> 256 × 256, with a larger download). Saturation scales the predicted
> colour from neutral grey to twice as strong. Output switches between
> Colorized and Chroma only, which shows the predicted colour on a
> flat mid grey without picture detail. The model runs only when the
> picture changes.
>
> How it works:
>
> Both models are DDColor Tiny: half-precision on the CPU (Compact, 512 × 512)
> or full-precision on WebGPU (Full fp32, 256 × 256). The worker builds a
> greyscale RGB image from the input's CIE-Lab L channel, predicts the a
> and b chroma channels, and packs them into RGBA around 0.5. The shader
> converts the full-resolution input from sRGB to CIE-Lab, replaces a and b
> with the model's prediction, and converts back to sRGB.

| Key | Label | Type | Range / options | Default | Port | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| `variant` | Model | enum | 0=Compact (CPU · 130 MB), 1=Full fp32 (GPU · 270 MB) | 0 (Compact (CPU · 130 MB)) | none | Compact runs on CPU; Full fp32 runs on WebGPU |
| `saturation` | Saturation | float | 0 … 2 (step 0.01) | 1 | ◇ | 0 is neutral grey, 2 twice the predicted colour |
| `output` | Output | enum | 0=Colorized, 1=Chroma only | 0 (Colorized) | ◇ | Chroma only: the predicted colour on a flat mid grey |
| `mix` | Mix | float | 0 … 1 (step 0.01) | 1 | ◇ | injected Mix: crossfade against the input |

---

## 8. Media and outputs (Input and Output menus)

The modules that are not effects, generators or modulators, with the short
line their menu entry shows on hover. What each one does in full is in the
node table of section 1.

#### Image

node type `image` · Input → Media

Summary: A still picture from a file.

> A still picture from a file: drop one on the card, paste it, or click
> to pick one. Its blue output feeds effects, viewers and exports. The
> file is not in the document; it is kept in this browser and comes back
> on reload, but elsewhere the node comes back empty and names the file it
> wants.

#### Image Set

node type `imageSet` · Input → Media

Summary: Several pictures on one wire, run through the graph one after another as a batch.

> Up to 32 pictures on one wire, run through everything downstream one
> after another as a batch. Drop or pick several files at once on the
> card, drag a thumbnail to change the order, and use its × to take one
> out. A Viewer or Projector gets a bar to step through the pictures or
> see them all in a grid; a Renderer can bake one, each, or a sheet of all
> of them. Files are kept in this browser as an Image's are.

#### Video

node type `video` · Input → Media

Summary: A video file, with its sound.

> A video file: drop one on the card or click to pick it. The card has
> playback controls, a Speed setting (which can be wired) and a Loop
> switch. The picture goes out of the blue port; if the file has a sound
> track, a separate green sound port sends it to a Renderer, a Viewer or a
> module that reads sound. That sound plays at Speed 1 only. The file is
> kept in this browser and comes back on reload.

#### Audio

node type `audio` · Input → Media

Summary: A sound file, to hear in viewers, export with the video or drive parameters.

> A sound file, placed on the timeline by its Gain, Offset and Loop, and
> silenced by Mute. Its folded **Clip** section trims and fades it: In and
> Out are where the heard part of the file starts and ends (seconds into the
> file), and a file position p sounds at Offset + p, so the trim moves with
> the sound. Fade in and Fade out (seconds) ramp it up and down at the ends
> of the heard part; Fade curve is Linear or Equal power (the default).
> Looped, the heard part repeats and every repetition fades.
>
> Gain is keyable like any param, and its `param:gain` port takes a modulator
> in place of the setting.

#### Sound Mix

node type `soundMix` · Module → Audio

Summary: Mixes several sounds into one, each with its own Gain, Pan, Mute and Solo.

> Several sounds mixed into one. Each sound wired into a `sound:<n>` port
> is placed on the comp's timeline as it plays on its own (its Audio node's
> Gain, Offset, Loop, trim, fades and Mute, or a video's sound track). Per
> input: **Gain** (0..2, keyable as `layer<n>.gain` and wirable on its own
> `param:layer<n>.gain` port), **Pan** (-1 left to 1 right), **Mute**, and
> **Solo**. With any input soloed, only the soloed ones play; Mute always
> wins. The ports grow: one empty port stays after the last one in use, up
> to 16. **Limiter** (on by default) compresses hard at -1 dB so a loud mix
> does not clip.
>
> The mix is rendered once, from comp 0 to the comp's end (at most 900 s),
> into one sound on its `sound` output. That sound plays, exports and is
> analysed like an Audio node's file, and it can feed another Sound Mix.
>
> **Ducking** (**Duck under**: Off, or one of the wired inputs) pushes every
> other input down while that one is loud. Its level is measured from its
> own placed sound as the mix renders, 20 ms at a time, so its layer Gain
> and Pan do not change the measurement (its Audio node's Gain, Offset, trim
> and fades do). While the level is above **Threshold** (-80..0 dBFS,
> default -35), the others go down by **Depth** (0..30 dB, default 12).
> **Attack** (0.001..2 s, default 0.05) and **Release** (0.01..5 s, default
> 0.4) set how fast they go down and come back. The ducking input is never
> ducked itself, and a muted input, or one left out by a solo, ducks nothing.

#### Viewer

node type `renderOutput` · Output → Monitor

Summary: A live view of the picture.

> A live preview of the picture wired into it. Drag the corner to
> resize it (double-click resets), and Float lifts the picture over the
> screen until you press Bring back. A sound wired into its sound port is
> heard while it plays, and it passes the picture on through its output.
> Fed a batch, it gets a bar to step through the pictures or see them in a
> grid.

#### Background

node type `backgroundOutput` · Output → Monitor

Summary: Shows the picture full screen behind the canvas.

> Draws the picture full screen behind the canvas and the cards.
> Enabled switches it on and off, Fill covers the whole screen while Fit
> keeps the whole picture in view, and Opacity fades it. The card says
> NO INPUT until a picture is wired in. It passes the picture on through
> its output.

#### Scopes

node type `scope` · Output → Monitor

Summary: Measures the picture: waveform, RGB parade, vectorscope or histogram.

> Measures the picture wired in rather than showing it: pick Waveform,
> Parade, Vectorscope or Histogram on the card. It is for judging
> brightness and colour by number instead of by eye, and it updates live
> as the picture changes. Fed a batch, it shows one picture, stepped
> through on its card.

#### Projector

node type `projector` · Output → Monitor

Summary: Shows the picture alone in its own window, for a second screen or a projector.

> Shows the picture alone in a window of its own, for a second screen, a
> projector or screen capture. Press Open window (it needs a picture wired
> in); if the browser blocks the window, allow pop-ups for the site. A
> toolbar in the window zooms, moves, frames with Fit or Fill and goes full
> screen, and appears only while the pointer is near the bottom.

#### Renderer

node type `render` · Output → Export

Summary: Exports the picture to an image, a GIF, a video or a PNG sequence.

> **Loudness** (Off, -14, -16 or -23 LUFS; a new Renderer starts at -14)
> brings the soundtrack of an MP4 or WebM with sound to that integrated
> loudness (ITU-R BS.1770: K-weighted, gated) before it is encoded, with the
> true peak held under -1 dBTP. Off leaves the mix as it is. After an export
> the card shows what was measured and applied, e.g. "−18.2 LUFS → −14"; that
> readout is for this session only. A browser that cannot encode the video
> gives no readout.

#### Recorder

node type `recorder` · Output → Export

Summary: Records what plays in real time to a video file, and passes the take on to a Viewer.

> Records what plays, in real time, to an MP4 or WebM file. Choose the
> format, Scale, Bitrate and FPS, press the record button and press it
> again to stop and keep the take, then Download it. The sound wired into
> its sound port is recorded with the picture. Takes are not saved, so
> after a reload there is nothing to download until you record again.
