home/ atoms/ sdf-ellipsoid-space-distortion

An ellipsoid SDF is computed by scaling space to transform the ellipsoid into a unit sphere

The SDF for a perfect sphere is length(p) - r. An ellipsoid with three different radii (rx, ry, rz) can be evaluated by dividing each component of p by its corresponding radius before computing length, then dividing the result by the minimum radius to approximately recover a Euclidean distance. The exact ellipsoid SDF requires iterative solving, but the space-distortion approach is cheaper and accurate enough for most rendering purposes. The distortion causes the field to be slightly non-Euclidean for very elongated ellipsoids.

Examples

float sdEllipsoid(vec3 p, vec3 r){ vec3 q=p/r; return (length(q)-1.0)*min(min(r.x,r.y),r.z); }

Assessment

Why does the min(r.x,r.y,r.z) factor in the ellipsoid SDF approximation help, and when does it fail (what shape produces the worst error)?

“distort the distance at the end. So this is equivalent. What happens now is that now we can start generalizing the radius, not to be a float”
corpus · inigo-quilez-live-coding-happy-jumping-video · chunk 7