Motivation
A surface can face a light and still receive no direct light because another surface blocks it. A local illumination calculation at the receiver cannot discover that blocker from the receiver's normal alone. A shadow map adds a second view of the scene: first look from the light and record the closest surfaces, then use that record when shading the camera's view. The shadow test estimates visibility to a particular light; it does not replace the material model or determine ambient and indirect illumination.
We develop a simple directional or perspective-light model. We first assume opaque, two-sided shadow casters, the same static geometry in both passes, exact arithmetic and point samples. Later we relax only the sampling assumptions we explicitly discuss.
A light-space depth record
Definition 3.4.1
(Light-space coordinates and window depth)
Let be a receiver point and let be a world-to-light-clip matrix. Write . For a perspective light we assume and that the point lies inside the light's clip volume. Divide to obtain , and apply the same viewport and depth convention used when creating the map. For the illustrative convention , set
Here are texture coordinates and is window depth. An orthographic light uses an affine projection, normally with constant positive , and the same comparison principle. This note assumes that smaller means closer to the light. Other API conventions, reversed depth, face culling and depth-range settings require a matching rule; the formulas are not an API-independent default.
Definition 3.4.2
(Shadow map and the receiver test)
At a light-view sample , the shadow map stores , the minimum depth among the opaque fragments that actually cover that sample. If there is no such fragment, use a declared sentinel for this convention. The receiver test for an exact corresponding sample is
The value means visible according to this map, not an assertion that every point on an extended light source is unoccluded. Equality is counted visible by policy. Fragments at the far endpoint and the no-fragment sentinel may be indistinguishable; this is a limitation of the representation, not proof that geometry was absent.
Theorem 3.4.3
(Why the minimum is a visibility test)
On one light ray, suppose opaque surface intersections in the light's depth range form a nonempty finite set and depth strictly increases with distance from the light. Let be the depth of a receiver intersection and the minimum intersection depth. Then exactly when no represented intersection in that depth range lies strictly between the light and the receiver. A blocker clipped outside that range is not recorded.
Proof
(Receiver depth versus the minimum on one ray)
The receiver itself belongs to the finite set, so . If no intersection is strictly closer, is a minimum and , hence . Conversely, if an intersection is strictly closer, its depth is smaller than , so and the test fails. Equal-depth intersections are treated as visible by the declared equality policy. This is a statement about the exact same ray and represented geometry; a neighboring texel is a different ray and need not have the same blocker.
Proof X-ray
The assumption behind the comparison
The proof uses the receiver's own intersection to establish . In an actual rasterized map, coverage rules, finite resolution, culling, displacement, animation or different geometry between passes can break that premise. A depth comparison remains a useful estimate, but the exact-ray theorem cannot simply be applied to a nearby stored sample.
Worked comparisons
Worked example 3.4.4
(A projected receiver and a blocker)
Let . Then and . If the selected stored depth is , the receiver fails and is classified shadowed. If it is , equality is classified visible. These values are already projected depths; they are not Euclidean distances from the light.
Worked example 3.4.5
(Depth is not distance)
Consider a perspective mapping for forward distance and constants . Its derivative is positive, so it preserves depth order, but the same depth interval corresponds to different distances at different . For , depths at are . Treating itself as a linear distance would incorrectly infer equal depth gaps from equal distance gaps. The exact coefficients depend on the projection and depth convention; this example illustrates the nonlinearity rather than defining a particular API projection.
Common mistake
(Clamping a receiver that lies outside the light frustum)
A receiver outside the light's valid clip volume has no valid projected map sample under this model. The renderer must specify its policy—for example, mark it outside the light's influence or use a separate visibility method. Blindly clamping its coordinates to the map edge invents a different ray. A point with must not be divided and treated as an ordinary in-frustum sample. A point light illuminates in many directions; one perspective map covers only its specified frustum, not the whole sphere.
Sampling, bias, and filtering
The map is a finite grid, whereas the receiver generally projects between grid samples. A point lookup associates it with one selected texel and compares depths from different rays. Even a single planar surface can show false self-shadow: its depth changes across the texel, so the stored sample can be closer than the receiver although no separate blocker exists. Quantization and differences between passes may add error. This is often called shadow acne; increasing map resolution can reduce spatial mismatch but does not prove it absent.
A common model subtracts a nonnegative bias from the receiver depth and tests . This expands the visible set. If the total discrepancy for a genuinely visible receiver is at most in the chosen depth units, then prevents a false shadow under that bound. But a blocker with is also declared visible: too much bias detaches the shadow from its caster. The appropriate bound depends on projection, surface slope, sample offset, quantization and implementation. A fixed bias is an engineering compromise, not a universal guarantee. If using reversed depth, both comparison and bias direction must be reconsidered together.
Worked example 3.4.6
(Bias repairs one error but can hide a blocker)
A planar receiver has depth and its selected texel stores at a nearby location. With no bias the test reports shadow; with , reports visible. Now suppose instead an actual blocker on the represented ray lies at while the receiver is at . The same bias produces the same visible answer, although the blocker is closer. The depth numbers alone do not identify which geometric situation occurred.
Definition 3.4.7
(Percentage-closer filter)
To soften spatial aliasing, one may compare the receiver with several selected depths and average the resulting visibility values. For weights summing to one, a simple percentage-closer filter (PCF) estimate is
The weights describe a discrete kernel, not a physical light-source distribution unless a separate model establishes that relationship.
Worked example 3.4.8
(Percentage-closer filtering by hand)
With equal weights and stored depths , a receiver at and zero bias has comparisons , so . Multiplying an unshadowed direct-light contribution by blends these sample decisions; it is not an exact area-light visibility integral.
Hardware comparison filtering, border rules and available depth formats depend on the chosen API and sampler configuration.
Counterexample mode
Filtering depth is a different calculation
Take two depths , with equal weights, receiver , and zero bias. Comparing first gives . Averaging depths first gives , which passes the equality test and returns . The step function is nonlinear, so averaging its inputs and averaging its outputs generally do not commute. Neither result alone proves physically correct penumbra coverage.
Applying visibility to shading
For a chosen direct-light model let be the unshadowed direct contribution at the receiver, already accounting for the light and surface orientation. A simple hard-shadow model uses ; the discrete PCF approximation uses . Add other separately modeled contributions afterwards.
Common mistake
(Blacking out the whole color in shadow)
Setting the entire final color to black whenever incorrectly discards any independently modeled ambient, emission or indirect light.
Shadow maps contain only the nearest recorded depth per sample: transparent transmission, multiple layers and light bouncing require additional models.
Exercises
Quick check
(Under the stated convention, project to . Classify it when the selected depth is and bias is zero.)
Solution · Answer
Division gives and . Since , the selected comparison reports shadow.
Quick check
(Four equally weighted depths are . Find PCF for and . State the equality convention.)
Solution · Answer
The biased receiver depth is . The first two comparisons fail and the last two pass, giving . Equality is visible; it does not arise in this calculation.
Quick check
(A map comparison has maximum true-visible discrepancy in depth units. What bias is sufficient under the stated bound? Give a closer-blocker depth gap that this bias would incorrectly accept.)
Solution · Answer
suffices if the stated bound really applies. A blocker with depth gap is falsely accepted because ; a gap equal to also passes by the equality policy.
Quick check
(Why does the minimum-depth proof not certify a comparison with a nearby texel, even with infinite numerical precision?)
Solution · Answer
The minimum-depth proof concerns intersections on the receiver's exact light ray, including the receiver. A neighboring texel samples another ray and can intersect a different surface or depth. Exact arithmetic does not eliminate that geometric sampling mismatch.
Quick check
(A receiver has direct contribution and separately modeled ambient contribution . What is the result with in this linear contribution model?)
Solution · Answer
The result is . This numerical answer assumes contributions are represented in a linear additive space; applying the arithmetic directly to nonlinear encoded color is not equivalent.