Skip to main content
Back to the graphics atlas
Rendering pipelineLighting & visibility Technique Advanced

Shadow Mapping

Use a depth map from the light’s point of view to decide whether a visible surface point is blocked from that light.

Lighting & visibility is nested under Rendering pipeline , so the broader pipeline usually still applies here.

graphicslightingshadowsdepth

Interactive playground

Tweak the operator or scene live so the article connects to an immediate visual result.

Shadow mapping

Store depth from the light’s perspective, then compare visible points against that light-space depth later.

Light-space scene

Scene view

Shadowed receiver + shadow map strip

Result view

Moving the light updates both the saved depth profile and the receiver points that fall into shadow.

Family

Rendering pipeline -> Lighting & visibility

Shadowing, occlusion, and how scene depth influences shading decisions.

Builds on

3 topics

Read these first if you want the surrounding pipeline context.

Unlocks

2 next topics

Use these follow-ups when you want to keep turning the image-processing pipeline forward.

Learning paths

1

This topic appears in curated graphics progressions so the next step is obvious.

Choose this over that

Depth for visibility vs depth for lighting

Both z-buffering and shadow mapping use depth buffers, but one solves camera visibility and the other solves light visibility.

Current topic

Shadow Mapping

Choose this when: The next lighting question is whether a point is visible from the light source.

Choose something else when: Primary camera visibility is still unresolved or ambient darkening is enough.

Rendering pipeline Open topic

Z-Buffer

Choose this when: You still need the front-most surface from the camera view.

Choose something else when: That surface is already known and now you want shadows.

Lighting & visibility Open topic

Screen-Space Ambient Occlusion (SSAO)

Choose this when: A cheap screen-space approximation of local occlusion is enough.

Choose something else when: You need directional hard or soft shadow reasoning from a light source.

Problem

Primary visibility from the camera is not enough for lighting. A point can be visible to the camera yet hidden from the light source, which is exactly what a shadow is.

Intuition

Render the scene from the light first and keep its depth buffer. Later, when shading from the camera view, transform each visible point into light space and ask whether something else reached that light-space pixel first.

Core idea

  • Render depth from the light’s point of view into a shadow map.
  • During camera shading, transform the current surface point into that same light-space coordinate system.
  • Compare the point’s light-space depth against the stored shadow-map depth.
  • If the point is farther away than the stored depth, something occluded it and the point is shadowed.

Worked example

A floor point may be fully visible to the camera, but when projected into light space its depth falls behind the depth stored for a wall or cube. That mismatch reveals that the light cannot see it directly.

Complexity

Shadow mapping adds another scene render from the light plus per-fragment lookup and comparison in the camera pass. It is usually far cheaper than full geometric shadow queries for every shaded point.

When to choose it

  • Choose it for real-time shadowing in raster pipelines.
  • Choose SSAO when you only need a cheap local occlusion cue rather than directional shadowing.
  • Ray-marched scenes may use other visibility strategies, though the conceptual depth comparison still echoes here.

Key takeaways

  • Shadow mapping is depth testing from the light’s perspective.
  • Bias and filtering matter because naive comparisons cause artifacts such as acne or jagged edges.
  • It is a standard, practical real-time shadow technique.
  • Understanding the z-buffer makes shadow mapping much easier to reason about.

Practice ideas

  • Render a simple scene and visualize the shadow map directly.
  • Adjust depth bias and inspect acne versus peter-panning artifacts.
  • Compare hard shadow-map sampling with a simple filtered variant.

Relation to other topics

  • The z-buffer provides the core visibility intuition reused here from another viewpoint.
  • Barycentric interpolation and rasterization still provide the fragment positions and depth context.
  • SSAO is a different, screen-space approximation of darkness that does not replace true light visibility.

Build on these first

These topics supply the mental model or preceding stage that this page assumes.

What this enables

Once the current operator feels natural, these are the most useful follow-up jumps.

Related directions

These topics live nearby conceptually, even if they are not strict prerequisites.

More from Lighting & visibility

Stay in the same family when you want parallel operators built from the same mental model.

Paths that include this topic

Follow one of these sequences if you want a guided next step instead of open-ended browsing.

Raster pipeline

Follow the classic rendering path from clipping and rasterization into visibility, shadows, occlusion, and temporal cleanup.

From the blog

Pair the graphics atlas with recent writing from the broader site whenever you want a wider engineering lens.