home/ atoms/ sdf-ambient-occlusion-local

SDF ambient occlusion samples the field at short offsets along the normal to detect nearby geometry

Global AO via ray tracing is expensive. SDF scenes afford a cheap analytic approximation: march 4–5 short steps along the surface normal, compare the ideal distance (step*i) with the actual SDF value at each step. If the SDF value is smaller than the expected free-space value, something nearby is occluding the surface. The discrepancy, summed with exponential falloff, gives an occlusion estimate. Concave areas (mouth interior, armpits, eye sockets) naturally have more nearby geometry and receive more darkening.

Examples

float occ=0.; float sca=1.; for(int i=1;i<=5;i++){ float h=map(pos+nor*0.1*float(i)); occ+=(0.1*float(i)-h)*sca; sca*=0.95; }

Assessment

Describe three concave areas on a creature where this AO technique produces a visible darkening effect and explain why each area triggers it.

“five different points in space, around the point we are shading, it's gonna do like, SDF query is saying, hey, what's around me, and if there is a lot of stuff around its own location”
corpus · inigo-quilez-live-coding-happy-jumping-video · chunk 22