home/ atoms/ sdf-shadow-ray

Shadow rays use the same raymarching loop from the shading point toward the light to determine occlusion

Hard shadows in SDF rendering use a second raymarching pass. Starting from the surface point (offset slightly along the normal to prevent self-intersection) and marching toward the light source, if the ray hits any geometry before reaching the light the point is in shadow. This reuses the same map() function used for primary rays — the visibility query is identical, just launched from a different origin in a different direction. The shadow factor multiplies the key-light contribution: 0 for full shadow, 1 for full light.

Examples

float shadow = castShadow(pos + nor*0.001, sunDir); — positive normal offset prevents the point from immediately intersecting its own surface.

Assessment

Explain why the shadow ray must be offset from the surface along the normal before it starts marching, and what artifact you get if you omit the offset.

“I do a new sequence of queries to check for objects in space, but not from the camera, but from the location in the sphere or in the floor that we are shading”
corpus · inigo-quilez-live-coding-happy-jumping-video · chunk 4