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.
- 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.
Offset Offset - Grows the shape (positive) or shrinks it (negative).
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.
Transform Order Xord ⊞ - The order in which scale, rotate and translate are applied.
- 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.
- 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.
Rotate R1 R2 R3 ⊞ - Rotates the shape, in degrees.
Scale Sx Sy Sz ⊞ - Scales the shape along each axis.
Pivot Px Py Pz ⊞ - The point to rotate and scale around. 0 is the centre of the volume.
Uniform Scale Scale - Scales the shape uniformly.
Fill Color Fillcolorr Fillcolorg Fillcolorb ⊞ - The colour inside the shape.
Fill Alpha Fillalpha - The alpha inside the shape.
Background Color Bgcolorr Bgcolorg Bgcolorb ⊞ - The colour outside the shape.
Background Alpha Bgalpha - The alpha outside the shape. Keep it at 0 to combine shapes cleanly.
Pre-Multiply RGB by Alpha Premultrgbbyalpha - Multiplies the colours by their alpha, as TOPs usually expect.
Softness Softness - How soft the shape's edge is. 0 gives a hard edge; larger values fade it out gradually.
Parameters - Output Page¶
Combine with Input Combineinput ⊞ - What the generator does with the volume connected to its input.
- 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.
Swap Order Swaporder - Swaps the two sides of Operation, so the input comes first.
Parameters - Vectors Page¶
Vector Vec - Values for your code: each block becomes a uniform with that name. Declare it as uniform vec4 Name;.
Name Vec0name - The uniform's name.
Value Vec0valuex Vec0valuey Vec0valuez Vec0valuew ⊞ - The uniform's value.
Parameters - Arrays Page¶
Array Array - CHOP channels for your code, as arrays.
Name Array0name - The array's name.
Type Array0type ⊞ - The type of each element.
- float
float - vec2
vec2 - vec3
vec3 - vec4
vec4
CHOP Array0chop - The CHOP that fills the array.
Array Type Array0arraytype ⊞ - Uniform Array works everywhere; Texture Buffer holds much larger arrays.
- Uniform Array
uniformarray - Texture Buffer
texturebuffer
Parameters - Matrices Page¶
Matrix Matrix - Matrices for your code, for example a transform from a COMP.
Name Matrix0name - The matrix's name.
Matrix Matrix0value - Where the matrix comes from.
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.
- 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.
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.
- Nearest Pixel
nearest - Interpolate Pixels
linear - Mipmap Pixels
mipmap
Passes Npasses - Has no visible effect on this operator. Leave it at 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.
Bypass Bypass - Passes the first input through unchanged.
Version Version - The T3D version of this operator. Mention it when reporting a problem.
Help Help - Opens this operator's page in the T3D documentation.
Copyright Copyright - Author and licence.
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.