SDFs

TD COMPs / TOPs / 2023 – Present

Signed Distance Functions (SDFs) are a versatile mathematical framework for representing shapes, regions, and boundaries within images. At their core, SDFs encode the distance of each pixel to the nearest boundary, with the sign indicating whether the pixel lies inside or outside a region. This dual encoding of geometry and space makes SDFs exceptionally powerful for both analysis and generative design.

Within image processing, SDFs open the door to precise shape manipulation, blending, and correction. They enable operations such as smooth combination of forms, accurate distance approximations, and efficient algorithms for constructing fields like Jump Flooding. These methods are essential not only in computational geometry and graphics but also in practical workflows such as segmentation, collision detection, and pattern generation.

By incorporating SDF‐based operators into TouchDesigner, this collection bridges robust geometric concepts with real‐time, creative visual workflows. Whether used for refining masks, smoothing transitions, or building entirely new structures, SDFs provide a flexible foundation for both analytical and artistic exploration.

Index:
JFA SDF, SDF Chamfer, SDF Chamfer Smooth, SDF Combiner, SDF Combiner Smooth, SDF Corrector, VP SDF

JFA SDF

Signed Distance Field Generation

Within this component, the Jump Flood Algorithm (JFA) is used to rapidly propagate distance information across the image in order to efficiently construct a Signed Distance Field of the given input. By spreading distance values in successive “jumps,” JFA makes it possible to approximate an SDF in only a few passes, balancing speed and accuracy in a way that is ideal for real‐time workflows in TouchDesigner.

The Signed Distance Field ( ) encodes the distance of each pixel ( ι ) to the nearest boundary ( Ω ) of a subset ( Ω ). If the pixel ( ι ) lies inside the region, the distance is negative; if the pixel ( ι ) lies outside, the distance is positive:

Ι = d (ι, Ω) = { d (ι, Ω) , ι Ω d (ι, Ω) , ιΩ

Since a Signed Distance Field is fundamentally a construct of single floating‐point values, this calculation disregards any color information present in the source image. Instead, the component relies on a thresholded interpretation of the provided image’s alpha channel to define the borders of shapes, ensuring a clear inside‐outside distinction for distance encoding.

Resources:

Download the .tox files
JFA Solidy COMP
SDFs on Wikipedia
JFA explanation by Benjamin Douglas

Parameters

Alpha Threshold:

Defines the cutoff value used to interpret the alpha channel as a binary mask. Pixels above the threshold are considered foreground, while those below are background. This determines the boundaries from which the Signed Distance Field is calculated.

Metric:

Specifies the distance metric used in the calculation. Options include:
Euclidian, Manhattan, Chebyshev, & Minkowski.

Exponent:

Controls the shape of the distance measurement when the Metric is set to Minkowski. Lower or higher values warp the contribution of distances along different axes.

Scale Space:

An X/Y scaling factor applied to the SDF calculation. Allows distances to be warped, stretching the field horizontally or vertically.


Clamp Negatives:

Restricts the SDF to only encode distances outside of shapes. When enabled, interior distances are clamped to zero.

Normalize:

Rescales the SDF values to fit between 0 and 1.

Invert:

Flips the sign of the SDF so that areas considered inside become outside, and vice versa.


reCalculate:

Forces the component to re-cook the Jump Flood Algorithm. Useful for clearing or correcting the output if visual errors appear during calculation.

In‐ / Outputs

Input 0TOP image used to generate the Signed Distance Field (alpha channel is evaluated).

Output 0TOP computed SDF of the input image.

Updated30/8/2025


SDF Chamfer

Beveled Shape Combinations

These components extend the standard SDF Combiner by introducing a chamfered finish to the combination of two fields. Instead of producing sharp boolean transitions, chamfering creates a beveled edge where shapes meet, giving the resulting form a softened, diagonal‐like transition.

Chamfering works by first generating a new field through the addition of the two input SDFs ( ). This creates a diagonal transition at the meeting point of the shapes, after normalization to ensure correct distance scaling. This chamfer field is then offset by the chamfer size ( c ) and merged back into the result.

The provided union calculation methods are:

  1. Union Chamfer:

    Expands the combined field with a beveled transition between shapes.

    Ι 1 Ι 2 = min ( min ( Ι 1 , Ι 2 ) , ( Ι 1 + Ι 2 ) 0.5 c )


  2. Intersection Chamfer:

    Shrinks the overlap between shapes while adding the beveled transition.

    Ι 1 Ι 2 = max ( max ( Ι 1 , Ι 2 ) , ( Ι 1 + Ι 2 ) 0.5 + c )


  3. Subtraction Chamfer:

    Produces a beveled edge where one field is cut away from another.

    Ι 1 Ι 2 = max ( max ( Ι 1 , Ι 2 ) , ( Ι 1 Ι 2 ) 0.5 + c )

The SDF Chamfer Smooth further refines this by applying a smooth blending operation to the chamfer, allowing for more gradual, rounded transitions in place of sharp diagonal bevels.

These operators are particularly useful for creating stylized geometry, smooth-shaded masks, or transitions that feel more tactile and constructed than simple boolean logic.

Resources:

Download the .tox files
SDFs on Wikipedia
2D SDF Combinations

Parameters

Method:

Defines the combination method used to merge the two input SDFs.

Chamfer Size:

Defines the width of the beveled transition between the two input SDFs. Larger values produce broader chamfers, softening the meeting point of shapes more dramatically, while smaller values result in a tighter, sharper bevel.

Smoothness:

Controls the degree of blending applied to the selected method. Higher values produce softer transitions and more gradual merging of boundaries, while lower values retain sharper boolean edges.

In‐ / Outputs

Input 0TOP first SDF to be combined.

Input 1TOP second SDF to be combined.

Output 0TOP chamfer combined SDF.

Updated30/8/2025


SDF Combiner

Boolean & Smooth Shape Composition

These components provide methods for combining two Signed Distance Fields (SDF) into a single output. By leveraging the properties of distance fields, combinations can be calculated with simple mathematical functions, producing new shapes through operations such as:

  1. Union (Merge):

    Takes the minimum of the two SDF ( ) values, combining both shapes into one. Any point inside either shape remains inside the result.

    Ι 1 Ι 2 = min ( Ι 1 , Ι 2 )


  2. Intersection:

    Takes the maximum of the two SDF ( ) values, preserving only the overlapping regions of the shapes.

    Ι 1 Ι 2 = max ( Ι 1 , Ι 2 )


  3. Subtraction:

    Inverts one SDF ( ) and intersects it with the other, effectively carving one shape out of another.

    Ι 1 Ι 2 = max ( Ι 1 , Ι 2 )

The SDF Combiner Smooth extends these operations by adding smoothing controls, allowing for gradual blending of boundaries ( Ω ) rather than abrupt transitions. This makes it possible to create soft unions, rounded intersections, and morph‐like subtractions where shapes appear to flow into one another.

Together, these tools provide a flexible foundation for constructing complex forms from simple primitives, enabling both precise boolean logic and more organic, continuous blends depending on the workflow.

Resources:

Download the .tox files
SDFs on Wikipedia
2D SDF Combinations

Parameters

Method:

Defines the combination method used to merge the two input SDFs.

Smoothness:

Controls the degree of blending applied to the selected method. Higher values produce softer transitions and more gradual merging of boundaries, while lower values retain sharper Boolean edges.

In‐ / Outputs

Input 0TOP first SDF to be combined.

Input 1TOP second SDF to be combined.

Output 0TOP combined SDF.

Updated30/8/2025


SDF Corrector

Interior Distance Field Repair

When Signed Distance Fields are constructed through boolean combinations such as union, intersection, or subtraction, the resulting field often breaks down in the interior of shapes. While these operations preserve correct surface boundaries, they don’t always produce valid distances inside negative regions of the SDF. In practice, this means the “inside” of the shape can collapse into incorrect values, causing artifacts in raymarching, physics simulations, or any process that depends on the integrity of the distance field.

The SDF Corrector addresses this problem by recalculating the internal (negative) regions of an input SDF. By selectively re‐evaluating the distances inside shapes, it restores a consistent representation of interior volumes while leaving the exterior distances unchanged. This ensures the corrected SDF behaves reliably across workflows, whether you’re raymarching solids, modeling negative spaces like rooms, or passing distance fields into downstream operators.

This component is especially useful after combining multiple SDFs with unifying logic, where the output may look visually correct but the underlying distance values are mathematically invalid. By repairing these broken fields, the SDF Corrector provides a more robust foundation for both visual rendering and computational uses of SDFs.

Resources:

Download the .tox files
SDFs on Wikipedia
Interior SDFs

Parameters

Correction:

Smoothly interpolates between the original input SDF and the corrected version.


Alpha Threshold:

Defines the cutoff value used to interpret the alpha channel as a binary mask. Pixels above the threshold are considered foreground, while those below are background. This determines the boundaries from which the Signed Distance Field is calculated.

Metric:

Specifies the distance metric used in the calculation. Options include:
Euclidian, Manhattan, Chebyshev, & Minkowski.

Exponent:

Controls the shape of the distance measurement when the Metric is set to Minkowski. Lower or higher values warp the contribution of distances along different axes.

Scale Space:

An X/Y scaling factor applied to the SDF calculation. Allows distances to be warped, stretching the field horizontally or vertically.


Invert:

Flips the sign of the SDF so that areas considered inside become outside, and vice versa.


reCalculate:

Forces the component to re-cook the Jump Flood Algorithm. Useful for clearing or correcting the output if visual errors appear during calculation.

In‐ / Outputs

Input 0TOP SDF to be corrected.

Output 0TOP corrected SDF.

Updated30/8/2025


VP SDF

Value‐Propagated Signed Distance Field

This component is a variation on the traditional SDF that extends distance calculations with additional information from the input image. Instead of discarding color values, this component accepts monochrome + alpha input and propagates pixel values from the boundary of shapes into the distance field as it is constructed.

As with a standard SDF ( ), the alpha channel defines the interior and exterior regions of the input. However, in a VP SDF the boundary ( Ω ) is not fixed at zero. Instead, each boundary pixel ( ιβ ) carries its own value from the input image ( Ι ), and this value is added to the propagated distance.

Formally, the VP SDF at pixel ( ι ) is defined as:

Ι = Ι(ιβ) + d (ι, Ω)

This means a pixel five units away from the nearest boundary will inherit the boundary’s value plus its distance, producing a richer, value‐aware distance field.

With this adjustment to how SDFs are calculated, the VP SDF makes it possible to generate entirely new classes of distance fields — producing complex geometries and evolving surfaces that would be impossible to construct with traditional SDF operations alone.

Resources:

Download the .tox files
SDFs on Wikipedia
JFA Solidy COMP
JFA explanation by Benjamin Douglas

Parameters

Alpha threshold:

Defines the cutoff value used to interpret the alpha channel as a binary mask. Pixels above the threshold are considered foreground, while those below are background. This determines the boundaries from which the Signed Distance Field is calculated.

Method:

Determines how propagated boundary values are applied to the Signed Distance Field. Options include:
Internal Negatives (adds the propagated values to the SDF) or
External Negatives (subtracts the propagated values to the SDF)


Metric:

Specifies the distance metric used in the calculation. Options include:
Euclidian, Manhattan, Chebyshev, & Minkowski.

Exponent:

Controls the shape of the distance measurement when the Metric is set to Minkowski. Lower or higher values warp the contribution of distances along different axes.

Scale Space:

An X/Y scaling factor applied to the SDF calculation. Allows distances to be warped, stretching the field horizontally or vertically.


reCalculate:

Forces the component to re-cook the Jump Flood Algorithm. Useful for clearing or correcting the output if visual errors appear during calculation.

In‐ / Outputs

Input 0TOP image used to generate the VP SDF.

Output 0TOP calculated VP SDF.

Updated30/8/2025