home/ atoms/ sdf-symmetry-abs

Taking the absolute value of one coordinate in an SDF replicates geometry on both sides of a mirror plane

For symmetric objects (creatures, machines) you need the same feature on both sides without coding it twice. In the local coordinate system, replace p.x with abs(p.x) before evaluating the SDF. This maps all negative-x points to their positive-x mirror, so any SDF defined for positive x appears on both sides. One sphere at (+0.1, 0, 0.3) becomes two eyes. One ear becomes two ears. The trick works for any axis and is ubiquitous in SDF character modeling. The common pitfall is applying abs to the wrong coordinate or applying it at the wrong level of the hierarchy.

Examples

vec3 symP = vec3(abs(p.x), p.y, p.z); float eye = sdSphere(symP - eyePos, eyeRad); — single sphere appears on both sides.

Assessment

Model a symmetric wing attachment. Why must abs be applied before offsetting to the wing’s position, not after?

“absolute value of one of the coordinates, everything that is on the negative side of the space will be equivalent of being on the positive side of the space because of absolute values”
corpus · inigo-quilez-live-coding-happy-jumping-video · chunk 8