I am working on something called a raymarcher. It's a type of 3D engine, and a rather peculiar one; it uses a signed distance function to describe a scene, which is surprisingly enough info to implement lighting, shadows, reflections, etc. Also, it is far faster than a standard raytracer, as it can easily be programmed as a shader and executed on the GPU. As such, I am interested in using this technique to render pretty implicit surfaces, such as the gyroid and Barth surfaces.
A signed distance function is essentially a function that tells you, for a given point in space, how close you are to some object. It is positive if this point is inside the object, negative if it's inside the object, and zero if it's on the object's boundary.
More formally, a signed distance function $D(\mathbf{p})$ to some manifold $\Omega$ in a metric space equipped with a metric $d$,
$\begin{align*} D(\mathbf{p}) = \begin{cases} d(\mathbf{p}, \partial \Omega) & \mathbf{p} \in \Omega \\ -d(\mathbf{p}, \partial \Omega) & \mathbf{p} \in \Omega^\complement \end{cases} \end{align*}$
where $\partial \Omega$ denotes the boundary of $\Omega$.
Is there a way to, given some arbitrary implicit surface defined by $f(\mathbf{p}) = 0$, calculate (or at least approximate to a reasonable degree) a signed distance to this surface?