Skip to content
CoreSource checked

Shadow Mapping

Creates shadows by comparing camera pixels with depth from the light's view.

Quick Facts

Compact metadata for implementation and discovery.

Category
Rendering
Difficulty
Intermediate
Family
Real-Time Lighting
Tier
Core
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
6
Code example
Not ready
Visualization
Ready

Overview

Shadow Mapping renders a depth map from a light source and tests whether visible points are hidden from that light.

Core Concepts

rendered imageshadow visibilityvisibility orderingreal-time lightingscene representationvisibility testpixel output

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(f)

Average

O(f)

Worst

O(f)

Space

O(p)

When to Use

  • Use Shadow Mapping when you need to store light-space depth.
  • Use it for real-time shadows with inputs like scene geometry.
  • Use it when the scene representation and quality target match the rendering tradeoff.
  • Use it when the Real-Time Lighting tradeoff is acceptable for the problem size.

When Not to Use

  • Avoid it when the cost per pixel or sample is too high for the desired frame rate.
  • Avoid it when the required output is not shadowed rendered image.

What It Does

  • Stores light-space depth
  • Tests whether shaded points are behind stored depth

Use Cases

  • Real-time shadows
  • Game rendering
  • Rasterization pipelines

Inputs

  • Scene geometry
  • Light view
  • Camera view

Outputs

  • Shadowed rendered image

Key Formulas (1)

Shadow test

inshadow if receiverdepth > shadowmap depth + bias
in_shadow if receiver_depth > shadow_map_depth + bias

Compares a shaded point against the light's stored depth map.

Pseudocode

  1. 1.Render scene depth from the light
  2. 2.Render the scene from the camera
  3. 3.Transform each fragment into light space
  4. 4.Compare its depth with the shadow map
  5. 5.Darken fragments hidden from the light

Canonical Example

Input
scene = one triangle, one camera, one light
Output
image pixels showing the visible triangle
Explanation
Shadow Mapping: The algorithm converts scene data into visible pixel results.

Implementation Notes

  • Keep the input contract explicit: Scene geometry; Light view; Camera view.
  • Use this step as the implementation spine: Render scene depth from the light.
  • Then preserve the next state change: Render the scene from the camera.
  • Build tiny scenes with known geometry before testing complex materials or lighting.

Common Pitfalls

  • Shadow maps need bias and filtering to reduce artifacts.
  • Ignoring coordinate spaces, depth precision, or sampling noise while debugging image artifacts.
  • Returning shadowed rendered image without handling empty, invalid, or boundary inputs.

Interactive Mechanism Walkthrough

Spatial Primitive & Sweep-Line Canvas

Show a light-space depth map deciding which pixels are in shadow.

Shadow Mapping mechanism walkthrough step 1 of 5
Step 1 of 5: Render scene depth from the light
light-depth-map

Notes

Shadow Mapping operates in O(f) time and O(p) space within the Real-Time Lighting family. Key governing relation: in_shadow if receiver_depth > shadow_map_depth + bias. Often compared with Z-Buffering and Variance Shadow Maps.

Sources (1)

What each reference supports for this entry.

Williams shadow mapping paper

Paper

Original shadow mapping paper using z-buffer visible-surface computation from the light view.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Alternative toShadow Volumes

Both render shadows with different visibility representations.

Variance shadow maps are a filterable variant of shadow mapping.

Tags

GraphicsShadowVisibility