The SDF of a sphere with radius \(r\) centered at the origin \(\boldsymbol {o}\) is
\[
f(\boldsymbol {p})=\lVert \boldsymbol {p}\rVert -r
\]
as depicted below:
The SDF above for a sphere translates to the following GLSL:
float sdSphere(vec3 p, float r)
{
return length(p) - r;
}