Game dev
Saved & recent

Shadow map

The standard way to draw shadows. The scene is first rendered from the light's point of view, keeping only depth. That image records the closest surface the light can see in each direction.

When shading a pixel, its distance to the light is compared with the stored one. If the pixel is farther, something is in the way and it is in shadow. Low resolution maps give blocky shadow edges.

Further reading
LearnOpenGL: shadow mapping
light blocker lit receiver occluded receiver depth map floor texel blocker texel
The 32 × 32 image is computed from the light’s viewpoint: darker texels store nearer surfaces, and lighter texels store farther ones; white is empty. The warm receiver matches its stored floor depth. The red receiver lies beyond the crate depth stored in its matching texel, so it is occluded. The stepped shadow compares receiver depth against those same coarse texels. Depth is linearized along the light camera’s axis; one perspective view of an ideal point light is shown. Floor self-shadow artifacts and depth bias are omitted.

View in the full Game dev collection