In shadow mapping, what causes shadow acne and peter-panning, and how do constant bias, slope-scaled bias and normal offset trade between them?
answer
- one stored depth per texel
- sloped receivers vary across a texel
- too much bias detaches contact
- scale with slope, or move the lookup
basics
~20 sAcne is false self-shadowing: a shadow texel covers a sloped surface patch whose depth varies, so part of it tests behind its own stored depth. Bias hides that error; too much bias detaches shadows from their casters, called peter-panning.
solid answer
~50 sA shadow map stores one depth per texel, but each texel's footprint covers a patch of surface. When the surface is tilted relative to the light, its true depth rises across that patch, so points on the far side test as behind the stored value and shadow themselves in stripes or moire: **acne**. Depth quantization adds to it. A **constant bias** shifts every comparison by a fixed amount, but enough for steep slopes is too much for flat ones: receivers just behind a caster's base test lit, and the shadow separates from the contact, as when a character's feet float above their own shadow. That is **peter-panning**. **Slope-scaled bias** grows the offset with the surface's depth slope in the shadow map, so flat surfaces get little. **Normal offset** moves the lookup position along the surface normal by about a texel's world size, removing acne with less detachment.
go deeper
Recall the two names: acne is a lit surface shadowing itself in stripes, peter-panning is a shadow detached from its caster, and bias trades one for the other.
Explain acne from one depth per texel against a sloped receiver, why a constant bias detaches contacts, and how slope-scaled bias and normal offset reduce both.
Diagnose from the picture: stripes on grazing surfaces, floating feet, acne only in far cascades. Name the knob that fixes each without breaking the others, including per-cascade scaling.
Decide what the renderer standardizes: bias in world units tied to texel size, default normal offset, and whether contact shadows are paid for on characters across the project.
## Why a lit surface shadows itself This answer assumes **depth grows away from the light**. A shadow map is a grid of samples: each texel stores the depth of whatever surface covered its centre when the light's view was rasterized. When the main pass shades a pixel, it projects the pixel's point into the light's view and compares the point's depth with the texel it lands in. A lit surface should pass that test against its *own* stored depth. Two things stop it: 1. **Footprint.** A texel's footprint spans some area of the surface. If the surface is tilted relative to the light, its depth changes across that footprint: one side is nearer the light than the sample at the centre, the other side farther. Points on the farther side compare as *behind* the stored depth and shadow themselves. 2. **Precision.** Depth is stored with finite precision, so even a surface facing the light squarely can round to a value slightly nearer the light than the receiver's computed depth. Because the error alternates from texel to texel, it shows up as stripes, rings or moire across surfaces that should be fully lit: **shadow acne**. It is worst where the light grazes the surface, because the depth change per texel grows as the surface turns edge-on. ## Constant bias and peter-panning The simplest fix subtracts a small **constant bias** from the receiver's depth (or adds it to the stored depth while rendering the shadow map), so a surface needs to be meaningfully behind the stored value to count as shadowed. One constant cannot suit every slope. A value large enough to cover grazing surfaces is far too large for flat ones, and then the bias eats real shadow. Near a contact point the caster and receiver are within the bias of each other: a character's foot resting on the floor sits only a few centimetres nearer the light than the floor beside it, so the floor there now tests as lit. The shadow starts some distance from the foot and the character seems to hover above its own shadow. That detachment is **peter-panning**. ## Slope-scaled bias The depth error across one texel is proportional to how fast depth changes across the shadow map, which grows roughly with `tan(theta)`, where theta is the angle between the surface normal and the light direction. **Slope-scaled bias** adds a term proportional to the triangle's depth slope: `bias = constantBias + slopeFactor * max(|dz/dx|, |dz/dy|)` where the derivatives are taken in shadow-map space. Many rasterizers can add exactly this while rendering the shadow map, from each triangle's own depth gradient. Flat-on surfaces get almost no offset, so contacts stay tight; grazing ones get more. Because `tan(theta)` grows without bound as the surface turns edge-on, the term is **clamped** to a maximum. ## Normal offset **Normal offset** stops adjusting depth and instead moves the **lookup position**. Before projecting the shaded point into the light's view, push it along its surface normal by about one shadow texel's world-space size, often scaled up as the surface turns away from the light. The moved point floats slightly above the surface, so its light-space depth is clearly nearer the light than the surface depths stored around it, and it passes the test with a much smaller depth bias. Because the offset needed stays near one texel's size instead of growing like `tan(theta)` at grazing angles, it detaches contact shadows less than a depth bias that removes the same acne, though too much offset still shifts or thins shadows. ## Other levers - **Tighter depth range**: fitting the light's near and far planes closely to the casters and receivers improves precision for free. - **More texels per world unit**: higher resolution or tighter cascades shrink each texel's footprint, so less bias is needed. - **Per-cascade bias**: bias in world units should scale with each cascade's texel size; one value tuned for the nearest cascade leaves acne in far ones. - **Back faces only** in the shadow pass: for closed meshes the stored depth comes from the far side of the object, so lit front faces sit well in front of it. Acne moves to surfaces facing away from the light, which the lighting term already darkens, but it fails for thin or open geometry and can show where back faces meet the ground. - **Contact shadows**: a short screen-space ray march toward the light restores the small contact shadows that bias removed. ## The trade-off in one table | Technique | What it adjusts | Strength | Weakness | |---|---|---|---| | Constant bias | receiver or stored depth | trivial | one value cannot fit all slopes; detaches contacts | | Slope-scaled bias | depth, by slope | little offset on flat surfaces | needs a clamp at grazing angles | | Normal offset | lookup position | removes acne with small depth bias | can shift or thin shadows if overdone | | Back-face shadow pass | which surface is stored | moves acne off lit faces | breaks on thin or open meshes | In practice renderers combine a small constant bias, slope-scaled bias and normal offset, tune them per cascade, and add contact shadows where characters meet the ground.
- Why does drawing only back faces into the shadow map reduce acne, and where does it fail?For a closed mesh the stored depth comes from the far side of the object, so the lit front faces sit well in front of it and pass easily. Acne moves to faces turned away from the light, which the lighting term already darkens. It fails for thin or open geometry such as single-sided leaves and walls, and acne or leaks can appear where an object's back faces meet the ground.
- What are screen-space contact shadows, and why are they added on top of a biased shadow map?Each pixel marches a short ray toward the light through the depth buffer, a few centimetres to tens of centimetres. If the ray passes behind stored scene depth by less than an assumed thickness, the pixel is occluded. That restores the small contact shadows that bias and shadow-map resolution remove, such as a foot on the ground, but it only sees on-screen occluders and has to guess their thickness.
- Why does a bias tuned for the nearest shadow cascade misbehave in the far ones?Bias exists to cover the depth error inside one texel, and far cascades have much larger texels and deeper ranges. A bias sized for the nearest cascade is too small far away, so acne returns there; one sized for the far cascades makes near shadows detach. Bias, and normal offset, are therefore scaled by each cascade's texel size.
- Shadow acne means the shadow map's resolution is too high for the scene.
- Raising a constant bias until acne vanishes is safe because it costs nothing visible.
- Slope-scaled bias grows with distance from the camera, not with the surface's slope.
- Normal offset changes the depth stored in the shadow map rather than the lookup position.
- Peter-panning means the light's far plane clipped the caster out of the shadow map.