Shadow map depth bias (constant, slope-scale, normal offset)
A family of offsets that keep a surface from shadowing itself in a shadow map: a constant depth offset, a term scaled by the surface's slope to the light, and a shift along the normal before lookup.
Also known as shadow bias, depth bias, slope-scaled depth bias, normal-offset shadows, shadow acne fix
In the family Visibility, shadows & ambient occlusion, shadow map artifact control
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Built in | light.shadow.bias, light.shadow.normalBias docs |
| Babylon.js 9.38.0 | Built in | shadowGenerator.bias, shadowGenerator.normalBias docs |
| Godot 4.7 | Built in | Light3D.shadow_bias and Light3D.shadow_normal_bias docs Constant plus normal offset; no separate slope-scale parameter. |
| Unity | Built in | Light > Shadow Type; Light.shadowBias and Light.shadowNormalBias docs |
| Unreal 5.7 | Built in | Light component > Details > Shadow Bias properties (set per light) docs Per-light bias properties. |
| Blender 5.2 | Built in | EEVEE > Render Properties > Sampling > Shadows (virtual shadow maps + normal/jitter bias) docs |
| WebGPU W3C | Built in | GPUDepthStencilState: depthBias, depthBiasSlopeScale, depthBiasClamp docs Hardware constant and slope-scale bias; normal-offset bias is done in WGSL. |
| Metal | Built in | MTLRenderCommandEncoder.setDepthBias(_:slopeScale:clamp:) docs Constant and slope-scale bias; normal-offset bias is done in MSL. |
How it works
A shadow map stores depth at texel centres, but a receiver sampled between centres sits at a slightly different light-space depth, so a tilted surface compares itself against a sample that can be nearer than the point being shaded. Without correction half of every texel reads as shadowed (acne). Three fixes are combined. A constant bias subtracts a fixed amount from the receiver depth. A slope-scaled bias grows with the tangent of the angle between normal and light (or the depth gradient, as hardware polygon offset does), because the error grows as the surface becomes grazing. A normal offset moves the world position along the geometric normal by about one shadow texel (scaled by the sine of the light angle) before projecting, which shrinks the needed depth bias and avoids light leaking at contact points. Biases are best expressed in texel or world-space units per cascade, not clip-space depth, because texel footprint changes with every cascade and light type. Adaptive schemes compute the bias from the receiver's actual depth gradient.
When to choose it
Reach for it when
- shadows covered in stripes on surfaces facing away from light
- shadow detaches from the bottom of objects
- floor looks striped or moire-patterned in shadowed areas
- characters seem to float above ground because shadow is offset
- shadow leaks through thin walls near contact point
Use it in every shadow-mapped renderer; it is the first thing to tune before blaming filtering. Prefer normal offset plus a small slope-scaled term over a big constant bias, which causes peter-panning (shadows detached from their casters). Reach for Percentage-Closer Filtering or Variance Shadow Maps when the remaining artifact is blocky edges rather than self-shadowing, and use Screen-Space Contact Shadows to recover the small-scale detail that bias removes. Per-cascade tuning matters with Cascaded Shadow Maps; Virtual Shadow Maps and Ray-Traced Shadows reduce but do not remove the need.
Field marks
- Shadow acne stripes on surfaces near-parallel to the light when bias is too small
- Peter-panning: the shadow visibly detaches from the base of the caster when constant bias is too large
- Light leaking at thin walls and contact edges because bias exceeds wall thickness
- A bias tuned for one cascade or light range shows acne or detachment in another
- Normal offset shrinks or grows silhouettes of shadows on curved or finely tessellated geometry
- Back-face casting hides acne on closed meshes but leaks on thin or open geometry
Presets
Bias comparison: acne, tuned, peter-panning
{
"slope": 2,
"texels": 32,
"bias_panels": [
0,
0.08,
0.3
]
}Show GLSL (32 lines)
// GLSL ES 3.0, Shadertoy-style. Three panels: no bias (acne), tuned bias, huge bias (peter-panning).
// Top-down view of a ground plane lit at a grazing angle, shadowed by a wall, with a low-res shadow map.
const float SLOPE = 2.0; // receiver light-depth gradient across the plane (grazing light)
const float TEXELS = 32.0; // shadow-map resolution across one panel
const float GAP = 0.8; // depth separation gained per unit of shadow length behind the wall
const vec3 BIAS = vec3(0.0, 0.08, 0.3);
const float WALL_X = -0.5;
float lit(vec2 p, float bias) {
float t = 2.0 / TEXELS;
vec2 c = (floor((p + 1.0) / t) + 0.5) * t - 1.0; // texel centre: what the map actually stored
bool inShadowTexel = c.x > WALL_X && c.x < WALL_X + 0.6 && abs(c.y) < 0.35;
float stored = SLOPE * c.x - (inShadowTexel ? GAP * (c.x - WALL_X) : 0.0);
float receiver = SLOPE * p.x;
return (receiver - bias > stored) ? 0.0 : 1.0; // 0 = shadowed
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = fragCoord / iResolution.xy;
float panel = floor(uv.x * 3.0);
vec2 p = vec2(fract(uv.x * 3.0) * 2.0 - 1.0, uv.y * 2.0 - 1.0);
float bias = panel < 0.5 ? BIAS.x : (panel < 1.5 ? BIAS.y : BIAS.z);
float l = lit(p, bias);
vec3 ground = vec3(0.86, 0.80, 0.68) * (0.30 + 0.70 * l);
ground *= 0.92 + 0.08 * sin(p.y * 40.0);
bool wall = p.x > WALL_X - 0.08 && p.x < WALL_X && abs(p.y) < 0.35;
vec3 col = wall ? vec3(0.35, 0.22, 0.18) : ground;
float edge = abs(fract(uv.x * 3.0) - 0.5);
if (edge > 0.495) col = vec3(1.0);
fragColor = vec4(col, 1.0);
}
Attribution: written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| shadow-bias-acne-vs-peter-panning | Tesla T4 1920x1080 | 0.99× baseline (feather) · 0.033 ms / 0.040 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| shadow-bias-acne-vs-peter-panning | NVIDIA L4 1920x1080 | 0.99× baseline (feather) · 0.016 ms / 0.016 ms · 2.1× faster on L4 | opengl-timer-query · Cross-architecture validation |
| shadow-bias-acne-vs-peter-panning | NVIDIA A100-SXM4-40GB 1920x1080 | 1.00× baseline (feather) · 0.029 ms / 0.029 ms · 1.1× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): cited by Moment Shadow Maps.
Crosses
- Cascaded Shadow Maps: Per-cascade texel size defines the bias and normal-offset magnitude applied in each cascade lookup.
- Percentage-Closer Filtering: Bias must cover the whole PCF kernel footprint, so the receiver depth is plane-fitted or offset before the multi-tap compare.
Sources
- primaryHang Dou, Yajie Yan, Ethan Kerzner, Zeng Dai, Chris Wyman (2014). Adaptive depth bias for shadow maps. Proceedings of the 18th meeting of the ACM SIGGRAPH Symposium on Interactive 3D Graphics and Games.Verified via crossref · 2026-11-29doi:10.1145/2556700.2556706
- tutorialMicrosoft. Common Techniques to Improve Shadow Depth Maps. learn.microsoft.com.Verified via live page · 2026-11-29
- tutorialMatt Pettineo. A Sampling of Shadow Techniques. therealmjp.github.io.Verified via live page · 2026-11-29
- implementationmrdoob (2010). mrdoob/three.js. JavaScript 3D Library.GitHub API · license MIT · 2026-11-29