Hubbry Logo
Signed distance functionSigned distance functionMain
Open search
Signed distance function
Community hub
Signed distance function
logo
8 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Signed distance function
Signed distance function
from Wikipedia
The graph (bottom, in red) of the signed distance between the points on the xy plane (in blue) and a fixed disk (also represented on top, in gray)
A more complicated set (top) and the graph of its signed distance function (bottom, in red).

In mathematics and its applications, the signed distance function or signed distance field (SDF) is the orthogonal distance of a given point x to the boundary of a set Ω in a metric space (such as the surface of a geometric shape), with the sign determined by whether or not x is in the interior of Ω. The function has positive values at points x inside Ω, it decreases in value as x approaches the boundary of Ω where the signed distance function is zero, and it takes negative values outside of Ω.[1] However, the alternative convention is also sometimes taken instead (i.e., negative inside Ω and positive outside).[2] The concept also sometimes goes by the name oriented distance function/field.

Definition

[edit]

Let Ω be a subset of a metric space X with metric d, and be its boundary. The distance between a point x of X and the subset of X is defined as usual as

where denotes the infimum.

The signed distance function from a point x of X to is defined by


Properties in Euclidean space

[edit]

If Ω is a subset of the Euclidean space Rn with piecewise smooth boundary, then the signed distance function is differentiable almost everywhere, and its gradient satisfies the eikonal equation

If the boundary of Ω is Ck for k ≥ 2 (see Differentiability classes) then d is Ck on points sufficiently close to the boundary of Ω.[3] In particular, on the boundary f satisfies

where N is the inward normal vector field. The signed distance function is thus a differentiable extension of the normal vector field. In particular, the Hessian of the signed distance function on the boundary of Ω gives the Weingarten map.

If, further, Γ is a region sufficiently close to the boundary of Ω that f is twice continuously differentiable on it, then there is an explicit formula involving the Weingarten map Wx for the Jacobian of changing variables in terms of the signed distance function and nearest boundary point. Specifically, if T(Ω, μ) is the set of points within distance μ of the boundary of Ω (i.e. the tubular neighbourhood of radius μ), and g is an absolutely integrable function on Γ, then

where det denotes the determinant and dSu indicates that we are taking the surface integral.[4]

Algorithms

[edit]

Algorithms for calculating the signed distance function include the efficient fast marching method, fast sweeping method[5] and the more general level-set method.

For voxel rendering, a fast algorithm for calculating the SDF in taxicab geometry uses summed-area tables.[6]

Applications

[edit]
Signed distance fields stored as raster images can be used to represent shapes.

Signed distance functions are applied, for example, in real-time rendering,[7] for instance the method of SDF ray marching, and computer vision.[8][9]

SDF has been used to describe object geometry in real-time rendering, usually in a raymarching context, starting in the mid 2000s. By 2007, Valve is using SDFs to render large pixel-size (or high DPI) smooth fonts with GPU acceleration in its games.[10][non-primary source needed] Valve's method is not perfect as it runs in raster space in order to avoid the computational complexity of solving the problem in the (continuous) vector space. The rendered text often loses sharp corners. In 2014, an improved method was presented by Behdad Esfahbod. Behdad's GLyphy approximates the font's Bézier curves with arc splines, accelerated by grid-based discretization techniques (which culls too-far-away points) to run in real time.[11][non-primary source needed]

A modified version of SDF was introduced as a loss function to minimise the error in interpenetration of pixels while rendering multiple objects.[12] In particular, for any pixel that does not belong to an object, if it lies outside the object in rendition, no penalty is imposed; if it does, a positive value proportional to its distance inside the object is imposed.

In 2020, the FOSS game engine Godot 4.0 received SDF-based real-time global illumination (SDFGI), that became a compromise between more realistic voxel-based GI and baked GI. Its core advantage is that it can be applied to infinite space, which allows developers to use it for open-world games.[13][non-primary source needed]

In 2023, the authors of the Zed text editor announced a GPUI framework that draws all UI elements using the GPU at 120 fps. The work makes use of Inigo Quilez's list of geometric primitives in SDF, Figma co-founder Evan Wallace's Gaussian blur in SDF, and a new rounded rectangle SDF.[14][non-primary source needed]

See also

[edit]

Notes

[edit]

References

[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
The signed distance function (SDF), also known as the signed distance field, is a mathematical function that, for a given point in , computes the shortest (orthogonal) distance to the boundary of a domain or , with the distance value signed to indicate whether the point lies outside (positive), inside (negative), or on the boundary (zero) of the domain. For a domain Ω\Omega with boundary Ω\partial \Omega, the SDF ϕ:RnR\phi: \mathbb{R}^n \to \mathbb{R} is formally defined such that ϕ(x)=dist(x,Ω)sign(x)\phi(\mathbf{x}) = \mathrm{dist}(\mathbf{x}, \partial \Omega) \cdot \mathrm{sign}(\mathbf{x}), where dist(x,Ω)=infyΩxy\mathrm{dist}(\mathbf{x}, \partial \Omega) = \inf_{\mathbf{y} \in \partial \Omega} \|\mathbf{x} - \mathbf{y}\| is the to the boundary, and the sign is determined by the position relative to Ω\Omega. A canonical example in 2D is the SDF to a centered at the origin, given by ϕ(x,y)=x2+y21\phi(x, y) = \sqrt{x^2 + y^2} - 1
Add your contribution
Related Hubs
User Avatar
No comments yet.