In
mathematics and its applications, the signed distance function (or oriented distance function) is the
orthogonal distance of a given point ''x'' to the
boundary
Boundary or Boundaries may refer to:
* Border, in political geography
Entertainment
* ''Boundaries'' (2016 film), a 2016 Canadian film
* ''Boundaries'' (2018 film), a 2018 American-Canadian road trip film
*Boundary (cricket), the edge of the pla ...
of a
set Ω in a
metric space
In mathematics, a metric space is a set together with a notion of '' distance'' between its elements, usually called points. The distance is measured by a function called a metric or distance function. Metric spaces are the most general sett ...
, with the
sign
A sign is an Physical object, object, quality (philosophy), quality, event, or Non-physical entity, entity whose presence or occurrence indicates the probable presence or occurrence of something else. A natural sign bears a causal relation to ...
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 Ω. However, the alternative convention is also sometimes taken instead (i.e., negative inside Ω and positive outside).
Definition
If Ω is a
subset
In mathematics, set ''A'' is a subset of a set ''B'' if all elements of ''A'' are also elements of ''B''; ''B'' is then a superset of ''A''. It is possible for ''A'' and ''B'' to be equal; if they are unequal, then ''A'' is a proper subset o ...
of a
metric space
In mathematics, a metric space is a set together with a notion of '' distance'' between its elements, usually called points. The distance is measured by a function called a metric or distance function. Metric spaces are the most general sett ...
''X'' with
metric
Metric or metrical may refer to:
* Metric system, an internationally adopted decimal system of measurement
* An adjective indicating relation to measurement in general, or a noun describing a specific type of measurement
Mathematics
In mathem ...
''d'', then the ''signed distance function'' ''f'' is defined by
:
where
denotes the
boundary
Boundary or Boundaries may refer to:
* Border, in political geography
Entertainment
* ''Boundaries'' (2016 film), a 2016 Canadian film
* ''Boundaries'' (2018 film), a 2018 American-Canadian road trip film
*Boundary (cricket), the edge of the pla ...
of For any
:
where denotes the
infimum
In mathematics, the infimum (abbreviated inf; plural infima) of a subset S of a partially ordered set P is a greatest element in P that is less than or equal to each element of S, if such an element exists. Consequently, the term ''greatest ...
.
Properties in Euclidean space
If Ω is a subset of the
Euclidean space
Euclidean space is the fundamental space of geometry, intended to represent physical space. Originally, that is, in Euclid's ''Elements'', it was the three-dimensional space of Euclidean geometry, but in modern mathematics there are Euclidean sp ...
R
''n'' with
piecewise
In mathematics, a piecewise-defined function (also called a piecewise function, a hybrid function, or definition by cases) is a function defined by multiple sub-functions, where each sub-function applies to a different interval in the domain. P ...
smooth boundary, then the signed distance function is differentiable
almost everywhere
In measure theory (a branch of mathematical analysis), a property holds almost everywhere if, in a technical sense, the set for which the property holds takes up nearly all possibilities. The notion of "almost everywhere" is a companion notion t ...
, and its
gradient
In vector calculus, the gradient of a scalar-valued differentiable function of several variables is the vector field (or vector-valued function) \nabla f whose value at a point p is the "direction and rate of fastest increase". If the gr ...
satisfies the
eikonal equation
An eikonal equation (from Greek εἰκών, image) is a non-linear first-order partial differential equation that is encountered in problems of wave propagation.
The classical eikonal equation in geometric optics is a differential equation of t ...
:
If the boundary of Ω is ''C''
''k'' for ''k'' ≥ 2 (see
Differentiability classes
In mathematical analysis, the smoothness of a function is a property measured by the number of continuous derivatives it has over some domain, called ''differentiability class''. At the very minimum, a function could be considered smooth if i ...
) then ''d'' is ''C''
''k'' on points sufficiently close to the boundary of Ω. 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 ''W''
''x'' 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 denotes the
determinant
In mathematics, the determinant is a scalar value that is a function of the entries of a square matrix. It characterizes some properties of the matrix and the linear map represented by the matrix. In particular, the determinant is nonzero if ...
and ''dS''
''u'' indicates that we are taking the
surface integral
In mathematics, particularly multivariable calculus, a surface integral is a generalization of multiple integrals to integration over surfaces. It can be thought of as the double integral analogue of the line integral. Given a surface, on ...
.
Algorithms
Algorithm
In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
s for calculating the signed distance function include the efficient
fast marching method
The fast marching methodJ.A. Sethian. A Fast Marching Level Set Method for Monotonically Advancing Fronts, Proc. Natl. Acad. Sci., 93, 4, pp.1591--1595, 1996/ref> is a numerical method created by James Sethian for solving boundary value problems o ...
,
fast sweeping method In applied mathematics, the fast sweeping method is a numerical method for solving boundary value problems of the Eikonal equation.
: , \nabla u(\mathbf), = \frac 1 \text \mathbf \in \Omega
: u(\mathbf) = 0 \text \mathbf \in \partial \Omega ...
and the more general
level-set method
Level-set methods (LSM) are a conceptual framework for using level sets as a tool for numerical analysis of surfaces and shapes. The advantage of the level-set model is that one can perform numerical computations involving curves and surfaces on a ...
.
For
voxel
In 3D computer graphics, a voxel represents a value on a regular grid in three-dimensional space. As with pixels in a 2D bitmap, voxels themselves do not typically have their position (i.e. coordinates) explicitly encoded with their values. ...
rendering, a fast algorithm for calculating the SDF in
taxicab geometry
A taxicab geometry or a Manhattan geometry is a geometry whose usual distance function or metric of Euclidean geometry is replaced by a new metric in which the distance between two points is the sum of the absolute differences of their Cartesian ...
uses
summed-area tables.
Applications
Signed distance functions are applied, for example, in
real-time rendering
Real-time computer graphics or real-time rendering is the sub-field of computer graphics focused on producing and analyzing images in real time. The term can refer to anything from rendering an application's graphical user interface ( GUI) to ...
,
for instance the method of
SDF ray marching, and
computer vision
Computer vision is an Interdisciplinarity, interdisciplinary scientific field that deals with how computers can gain high-level understanding from digital images or videos. From the perspective of engineering, it seeks to understand and automate t ...
.
A modified version of SDF was introduced as a
loss function
In mathematical optimization and decision theory, a loss function or cost function (sometimes also called an error function) is a function that maps an event or values of one or more variables onto a real number intuitively representing some "co ...
to minimise the error in interpenetration of pixels while rendering multiple objects. 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.
They have also been used in a method (advanced by
Valve
A valve is a device or natural object that regulates, directs or controls the flow of a fluid (gases, liquids, fluidized solids, or slurries) by opening, closing, or partially obstructing various passageways. Valves are technically fitting ...
) to render
smooth font
Font rasterization is the process of converting text from a vector description (as found in scalable fonts such as TrueType fonts) to a raster or bitmap description. This often involves some anti-aliasing on screen text to make it smoother ...
s at large sizes (or alternatively at
high DPI) using
GPU acceleration. Valve's method computed signed
distance field
A distance transform, also known as distance map or distance field, is a derived representation of a digital image. The choice of the term depends on the point of view on the object in question: whether the initial image is transformed into anothe ...
s in
raster space in order to avoid the computational complexity of solving the problem in the (continuous) vector space. More recently piece-wise approximation solutions have been proposed (which for example approximate a Bézier with arc splines), but even this way the computation can be too slow for
real-time rendering
Real-time computer graphics or real-time rendering is the sub-field of computer graphics focused on producing and analyzing images in real time. The term can refer to anything from rendering an application's graphical user interface ( GUI) to ...
, and it has to be assisted by grid-based
discretization
In applied mathematics, discretization is the process of transferring continuous functions, models, variables, and equations into discrete counterparts. This process is usually carried out as a first step toward making them suitable for numeri ...
techniques to approximate (and cull from the computation) the distance to points that are too far away.
In 2020, the
FOSS
Fos or FOSS may refer to:
Companies
* Foss A/S, a Danish analytical instrument company
*Foss Brewery, a former brewery in Oslo, Norway
* Foss Maritime, a tugboat and shipping company
Historic houses
*Foss House (New Brighton, Minnesota), United ...
game engine
Godot 4.0 received SDF-based real-time
global illumination
Global illumination (GI), or indirect illumination, is a group of algorithms used in 3D computer graphics that are meant to add more realistic lighting to 3D scenes. Such algorithms take into account not only the light that comes directly from ...
(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.
See also
*
Distance function
*
Level-set method
Level-set methods (LSM) are a conceptual framework for using level sets as a tool for numerical analysis of surfaces and shapes. The advantage of the level-set model is that one can perform numerical computations involving curves and surfaces on a ...
*
Eikonal equation
An eikonal equation (from Greek εἰκών, image) is a non-linear first-order partial differential equation that is encountered in problems of wave propagation.
The classical eikonal equation in geometric optics is a differential equation of t ...
*
Parallel (aka offset) curve
*
Signed arc length
Signing may refer to:
* Using sign language
* Signature, placing one's name on a document
* Signature (disambiguation)
* Manual communication, signing as a form of communication using the hands in place of the voice
* Digital signature
A digit ...
Notes
References
*
*{{cite book , author1=Gilbarg, D. , author2=Trudinger, N. S. , year=1983 , edition=2nd , title=Elliptic Partial Differential Equations of Second Order , publisher=Springer-Verlag , volume=224 , series=Grundlehren der mathematischen Wissenschaften (or the Appendix of the 1977 1st ed.)
Applied mathematics
Distance