GLSL shader example
Ray-Marched Soft Shadows
March from the hit point toward the light. The occluder distance divided by traveled distance approximates a penumbra; compare hard and soft halves.
Live example
Edit the code and the preview updates as you type.
What to observe
Ray-Marched Soft Shadows.
Mechanism
March from the hit point toward the light. The occluder distance divided by traveled distance approximates a penumbra; compare hard and soft halves.
The controlling code
return min(length(p-vec3(0,.2,0))-.55,p.y+.5);
Experiment
Set the parameter to 0 and then 1, changing the softness factor 4.+u_parameter*18. from 4 to 22. The right-hand shadow becomes tighter as the multiplier rises, while the left half still thresholds the same shadow estimate into a hard edge.
Debugging and cost
After the primary 80-step march, a hit may launch up to 28 additional scene queries toward the light. Change j<28 to j<12 to lower shadow work; distant blockers may be missed even where the primary surface remains correct.