Skip to content

Sdf T3D

Summary

The SDF T3D fills the volume with a shape described by a signed distance function you write in GLSL: a function float SDF(vec3 p) that returns how far the point p is from the surface, negative inside. Placing the operator creates an example to edit next to it. Distance functions from Inigo Quilez's collection work as they are.

uniform vec4 uSize;                       // from the Vectors page, Name uSize

float SDF(vec3 p){                        // p: position, centre of the volume at 0
    vec3 q = abs(p) - uSize.xyz;
    return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);   // a box
}

Values from TouchDesigner reach the code through the Vectors, Arrays and Matrices pages. Set Mode to Distance to output the distance itself instead of a filled shape. Compile errors show in the Info DAT placed beside it.

Shapes are centred in the volume and placed with the transform parameters. Softness fades the edge, and the Fill and Background colours set what is inside and outside. Connect another volume to the input to set the size, and to combine the shape with it: chaining generators builds a scene without extra operators. See Combining volumes.

Parameters - SDF Page

Mode Mode ⊞ - What the output holds. Menu · default Inside

  • Distance Distance - The distance to the surface, negative inside. Use a float Pixel Format.
  • Inside Inside - The filled shape.

SDF Sdf - The Text DAT with your SDF function. DAT · default SDF

Offset Offset - Grows the shape (positive) or shrinks it (negative). Float · default 0

Aspect Correction Aspectcorrection - Keeps the shape's proportions when the volume is not a cube, so a sphere stays round. Off, the shape stretches with the volume. Toggle · default On

Transform Order Xord ⊞ - The order in which scale, rotate and translate are applied. Menu · default Scale Rotate Translate

  • Scale Rotate Translate srt
  • Scale Translate Rotate str
  • Rotate Scale Translate rst
  • Rotate Translate Scale rts
  • Translate Scale Rotate tsr
  • Translate Rotate Scale trs

Rotate Order Rord ⊞ - The order of the rotations. Menu · default Rx Ry Rz

  • Rx Ry Rz xyz
  • Rx Rz Ry xzy
  • Ry Rx Rz yxz
  • Ry Rz Rx yzx
  • Rz Rx Ry zxy
  • Rz Ry Rx zyx

Translate Tx Ty Tz ⊞ - Moves the shape. 0 is the centre of the volume; 0.5 moves the shape's centre to a face. Float × 3 · default 0

Rotate R1 R2 R3 ⊞ - Rotates the shape, in degrees. Float × 3 · default 0

Scale Sx Sy Sz ⊞ - Scales the shape along each axis. Float × 3 · default 1

Pivot Px Py Pz ⊞ - The point to rotate and scale around. 0 is the centre of the volume. Float × 3 · default 0

Uniform Scale Scale - Scales the shape uniformly. Float · default 1

Fill Color Fillcolorr Fillcolorg Fillcolorb ⊞ - The colour inside the shape. RGBA × 3 · default 1

Fill Alpha Fillalpha - The alpha inside the shape. Float · default 1

Background Color Bgcolorr Bgcolorg Bgcolorb ⊞ - The colour outside the shape. RGBA × 3 · default 0

Background Alpha Bgalpha - The alpha outside the shape. Keep it at 0 to combine shapes cleanly. Float · default 0

Pre-Multiply RGB by Alpha Premultrgbbyalpha - Multiplies the colours by their alpha, as TOPs usually expect. Toggle · default On

Softness Softness - How soft the shape's edge is. 0 gives a hard edge; larger values fade it out gradually. Float · default 0.1 · min 0

Parameters - Output Page

Combine with Input Combineinput ⊞ - What the generator does with the volume connected to its input. Menu · default Composite and Set Resolution

  • Set Resolution Only res - The input only sets the size; its content is ignored.
  • Composite and Set Resolution compres - The generated shape is combined with the input using Operation, so generators can be chained.

Operation Operand ⊞ - How the generated volume is combined with the input: Over, Add, Multiply, Maximum and the other operations of the Composite TOP. With Over, the new shape sits on top of the input. Menu · default Over

Swap Order Swaporder - Swaps the two sides of Operation, so the input comes first. Toggle · default Off

Parameters - Vectors Page

Vector Vec - Values for your code: each block becomes a uniform with that name. Declare it as uniform vec4 Name;. Sequence · default 0

Name Vec0name - The uniform's name. Str

Value Vec0valuex Vec0valuey Vec0valuez Vec0valuew ⊞ - The uniform's value. Float × 4 · default 0.5, 0, 0, 0

Parameters - Arrays Page

Array Array - CHOP channels for your code, as arrays. Sequence · default 0

Name Array0name - The array's name. Str

Type Array0type ⊞ - The type of each element. Menu · default float

  • float float
  • vec2 vec2
  • vec3 vec3
  • vec4 vec4

CHOP Array0chop - The CHOP that fills the array. CHOP

Array Type Array0arraytype ⊞ - Uniform Array works everywhere; Texture Buffer holds much larger arrays. Menu · default Uniform Array

  • Uniform Array uniformarray
  • Texture Buffer texturebuffer

Parameters - Matrices Page

Matrix Matrix - Matrices for your code, for example a transform from a COMP. Sequence · default 0

Name Matrix0name - The matrix's name. Str

Matrix Matrix0value - Where the matrix comes from. CHOP

Parameters - Common Page

Output Resolution Outputresolution ⊞ - Whether the output takes its size from the first input or from Resolution. With nothing connected, Resolution is always used. Menu · default Use Input

  • Use Input useinput - The same width, height and depth as the first input.
  • Custom custom - The size set in Resolution.

Resolution Resolution1 Resolution2 Resolution3 ⊞ - Width, height and depth of the output in voxels, when Output Resolution is Custom or nothing is connected. Memory grows quickly: 256 × 256 × 256 at 16-bit float is 128 MB. Int × 3 · default 64 · min 1

Input Smoothness Inputfiltertype ⊞ - How the inputs are sampled when their size differs from the output. Interpolate Pixels is smooth; Nearest Pixel keeps hard, blocky voxels. Menu · default Interpolate Pixels

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

Passes Npasses - Has no visible effect on this operator. Leave it at 1. Int · default 1

Pixel Format Format ⊞ - The output's pixel format. Use Input copies the first input's. Choose a float format for values outside 0–1: negative numbers, distances, velocities, or densities above 1. With nothing connected, Use Input gives 8-bit. Menu · default Use Input

Bypass Bypass - Passes the first input through unchanged. Toggle · default Off

Version Version - The T3D version of this operator. Mention it when reporting a problem. Str

Help Help - Opens this operator's page in the T3D documentation. Pulse

Operator Inputs

  • Input 0: Input T3D_in1 - Optional. Sets the output size and, with Combine with Input, is combined with the shape, so shapes can be chained into a scene.

Operator Outputs

  • Output 0: Output T3D_output - The shape as a volume.