Skip to content

Optical Flow T3D

Summary

The Optical Flow T3D estimates how the content of an animated volume moves from one frame to the next, a 3D adaptation of the optical flow shader of ofxFlowTools. It converts the input to luminance, keeps the previous frame, and at every voxel divides the change over time by the spatial gradient:

flow = −(Inow − Iprev) · ∇I / √(|∇I|² + λ)

with the gradient taken Offset voxels apart in both frames. The result is the normal flow: the component of the motion along the local gradient, computed voxel by voxel. It responds where the volume has structure and is zero on flat regions; it has no absolute unit, so scale it with Force for what it drives. Threshold removes small, noisy flows.

Typical uses are to push fluid or particles (advect) with the motion of a live volume, or to visualise motion.

Parameters - Optical Flow Page

Force Force - Multiplies the flow. Float · default 1

Offset Offset - Distance, in voxels, between the samples of the spatial gradient. Larger values follow coarser structure and larger motion, smaller ones finer detail. Int · default 3

Lambda Lambda - Regularisation added to the squared gradient before dividing by it. It keeps the flow finite where the volume is flat, and damps it there; larger values give a calmer, weaker field. Float · default 0.1

Threshold Threshold - Flows shorter than this are set to 0; longer ones are shortened by it and rescaled by 1 / (1 − Threshold), so the field starts smoothly at the threshold. 0 turns it off. Float · default 0

Inverse X Inversex - Flips the X component. Toggle · default Off

Inverse Y Inversey - Flips the Y component. Toggle · default Off

Inverse Z Inversez - Flips the Z component. Toggle · default Off

Parameters - Common Page

Output Resolution Outputresolution ⊞ - Where the output's width, height and depth come from. With nothing connected to the first input the operator always uses Resolution, whichever option is set. Menu · default Use Input

  • Use Input useinput - The first input's width, height and depth.
  • Custom custom - The Resolution parameter.

Resolution Resolution1 Resolution2 Resolution3 ⊞ - Width, height and depth of the output in voxels. Used when Output Resolution is Custom, or when the first input is not connected. Memory is width × height × depth × bytes per voxel of the Pixel Format: 256³ at 16-bit float RGBA is 128 MiB. Int × 3 · default 64 · min 1

Input Smoothness Inputfiltertype ⊞ - Filtering of the internal GLSL TOPs' input samplers, as TouchDesigner's Input Smoothness. Inputs are read at normalised coordinates, so this matters whenever the input and output resolutions differ or an input is transformed. Nearest Pixel returns voxels unblended; Interpolate Pixels is trilinear. Menu · default Interpolate Pixels

  • Nearest Pixel nearest
  • Interpolate Pixels linear
  • Mipmap Pixels mipmap

Passes Npasses - Runs the operation this many times, each pass taking the previous pass's result in place of the first input. Cost scales linearly with the number of passes. Int · default 1

Pixel Format Format ⊞ - Pixel format of the output. Use Input takes the first input's format. With nothing connected, Use Input resolves to 8-bit fixed (RGBA), which clamps values to 0–1 and quantises them to 1/255: set a float format for signed distances, densities above 1, velocities or anything else outside 0–1. Menu · default Use Input

Bypass Bypass - Passes the first input through unchanged and skips the operator's work. With nothing connected the output is a single black voxel. Toggle · default Off

Version Version - T3D version of this operator. Read-only information; include it when reporting a problem. Str

Operator Inputs

  • Input 0: Input T3D_in1 - The animated volume. Each cook compares its luminance with that of the previous frame.

Operator Outputs

  • Output 0: Output T3D_output - The flow: X / Y / Z in RGB, alpha 1. Signed: use a float Pixel Format.

Performance

GPU time when the operator recooks: 0.034 ms at 64³, 0.070 ms at 128³, all of its passes summed (GeForce RTX 4090, TouchDesigner 2025.33230). An operator whose inputs and parameters are unchanged does not recook and costs nothing.