Introduction


Signed Distance Functions (SDFs) are scalar fields which at every point in metric space represent the shortest distance between the surface (boundary points) of an object and that point. If the point is inside the object (enclosed by the surface) the SDF at that point has a negative sign. These features, combined with manipulation of the underlying metric space (coordinate system) allow us to create procedural complex geometry from relatively simple mathematical functions.

SDFs allow us to create complex geometry with:

  • Euclidian Transformations
  • Modifications:
    • to the coordinate system
    • to the surface
  • Boolean Operations between SDFs
  • Changing the metric of the coordinate system

Please see the Tutorials for more information.

SDFs also allow us to create complex procedural Vector Fields based on the gradient and the value of the SDF.

Euclidian Transformations

Euclidian transformations to the SDFs are done by manipulating the coordinate system. For example translating the SDF by a vector is done by subtracting a vector from the position vectors in the coordinate system. To rotate the SDF the position vectors are rotated. To scale the SDF the position vectors are scaled.

where is the position vector, is the translation vector, is the rotation matrix, in the scale factor, is the SDF before the Euclidian transformation, and is the transformed SDF.

Example

Modifications

Geometry defined with SDFs can be modified in a similar fashion to Euclidian transforms - by modifying the underlying vector of position vectors or by applying a transformation to the values of SDF itself. For example the Onion modification, which transforms a volume into a shell with some thickness is written as:

where is the position vector, is the shell thickness, is the SDF before the Onion modification, and is the modified SDF.

Example

Boolean Operations

An arbitrary geometry does not necessarily have an analytical function defining its SDF. The SDF can be computed using Ray Marching or a similar method, which can be computationally expensive. The alternative is to use Boolean or Smooth/Parametric Boolean operations with SDFs to form complex geometries.

Boolean operations between two SDFs such as union, intersection, difference/subtraction can be written as:

where and are the SDFs, and and functions find the minimum/maximum of both SDFs at .

Smooth/Parametric Boolean operations allow us to combine SDFs so that there is a smooth transition between them. For example the functions for smooth union, smooth intersection and smooth subtraction can be written as:

where is a Smooth Minimum Function (others), is the smoothing parameter, and and are the SDFs.

Boolean Example, Boolean and Smooth Boolean Example, Smooth Boolean Example

Vector Fields

SDF is a spatially dependent scalar field but by calculating the gradient of the SDF we can convert it into a spatially dependent vector field where all the vectors are unit length. In this manner we can create vector fields around complex shapes. Additionally, the SDF itself can be used to modify the orientation of the vectors based on the distance from the surface. There are also several built-in vector fields available, which can also be further modified using SDFs.

SDF Vector Fields, Build-in Vector Fields

References