home/ atoms/ sdf-subtraction-max

SDF boolean subtraction uses max(distance, -cutter) to carve one shape out of another

Just as min() merges (unions) two SDFs, max(a, -b) subtracts shape B from shape A. The negation of B’s SDF makes its interior positive; max then keeps only points outside B that are inside A. This is used for sculpting: to add a mouth cavity to a face, define an ellipsoid for the mouth and compute max(bodyDist, -mouthDist). The body survives everywhere except inside the mouth ellipsoid. A smooth variant produces a rounded carved edge.

Examples

float mouth = sdEllipsoid(p - mouthPos, mouthRad); float body = smin(torso, head, 0.1); float creature = max(body, -mouth);

Assessment

A student uses min(body, -mouth) instead of max(body, -mouth) for subtraction and gets unexpected results. Explain what they would see and why.

“max population. So mean combines things together, max subtracts things from each other. The max operator is just like the mean, but what it says mean, we have to put max”
corpus · inigo-quilez-live-coding-happy-jumping-video · chunk 10