阴影贴图偏移作为几何误差
Shadow-map bias represents a physical length along the light ray, added just before the depth comparison. Applying too little of this length causes an analytically lit receiver to be incorrectly classified as shadowed, resulting in acne. Applying too much detaches the contact shadow of a thin occluder from its true foot, creating peter-panning. The overarching curve in this note visualizes the exact trade-off between these two artifacts.
Topics such as discrete depth encoding, winner-islands, and reverse-Z belong to the previous note, Z-fighting is geometric compression plus quantization. That text already refers here for the distinction between acne and peter-panning, and fight-fractions remain in that scope. This note fixes a single shadow map and avoids sweeping a depth code. The shared underlying concept is strictly geometric: a depth failure can be quantified as a physical length. There, it is a resolvable interval in front of the camera; here, it is a bias , measured in metres along the sun ray.
The test scene is a service-yard curb. An asphalt apron, a 160 mm concrete curb, a poured wash ramp pitched at , and a 12 mm steel plate are arranged in a single frame. The lighting environment consists of one directional sun at an altitude of , casting into a single depth-compare map with an 8 m orthographic projection. The shadow map is rendered exactly once. Across the evaluated ladder, only the compare bias changes.
The beauty pass uses Mesa llvmpipe in scene-referred linear Rec.709, followed by the display path detailed in Tone Mapping: Scene-Referred to Display-Referred. We apply Khronos PBR Neutral using parameters , , , and , finishing with the sRGB OETF evaluated on the CPU. The exposure gain is locked at for all bias samples. Neutral merely assigns display codes; it has no influence on the acne fraction or the contact gap.
The optimization curve selects the operating point (). As the bias increases from through to , ramp acne falls from through to , and apron acne drops from to . Conversely, the contact gap widens from through to . Relying instead on slope-scale at and clears both acne fractions while maintaining a gap of just . By comparison, the smallest constant sample with identically resolved ramp acne sits at , where the gap has already stretched to . The verification suite prints 11 pass / 0 fail.
These abbreviated figures map onto the unrounded tokens of this run as follows:
| lede | this run |
|---|---|
| , , | |
| , | |
| , , | |
| slope | |
| , | , |
| apron median | |
| regime ratio |
What you are seeing
The visual working space for the scene photographs is scene-referred linear Rec.709, processed through Khronos PBR Neutral at and . In contrast, the sweep plot and the metrics snapshot are authored natively in sRGB and bypass the Neutral mapper entirely. The records are intentionally separated: the photographs illustrate the physical curb, while the tables explicitly quantify and .
Cover — the operating point. Captured at with a bias of , showing the service-yard curb, wash ramp, and steel plate. The on-screen HUD displays a single line containing the bias and the resolution. A faint shadow residue remains visible on the ramp, while the apron reads completely clear. This residue corresponds to the leftover ramp acne of recorded in the table, whereas the clear apron reflects an at this sample. The gap denotes a physical length across the apron, rather than a mere grey level in the JPEG.

Acne — the short end. This frame shares the same camera and shadow map, evaluated at . Both the ramp and the apron incorrectly self-shadow in prominent stripes. Each stripe represents a receiver with an analytic visibility of 1 that the comparison logic has erroneously marked as shadowed. Here, the ramp acne peaks at and the apron acne reaches , keeping the contact gap tightly at .

Peter-panning — the long end. Captured with the same camera and map at . At this extreme, both acne fractions have successfully fallen to . However, the plate’s contact shadow has visibly detached from its foot. The measured gap along the apron now spans (). The pronounced dark band highlights this detachment, while the curb’s inherent occlusion remains a distinct, separate shadow.

Sweep — teaching pin. This plot graphs , , and against a constant bias, marking explicitly alongside the slope-scale triple as a special callout. Eight specific contact strips sit underneath the main plot: the samples nearest , , , , , and , followed by , and finally the slope-scale result. The quantised staircase nature of is left visible to accurately reflect the data. This figure visually summarizes the trade-off. The subsequent table highlights selected rows from this sweep; the plot supplements rather than replaces the raw numbers.

The table below extracts selected constant-bias samples from this run. The full evaluation ladder consists of 31 samples ranging as , which are all plotted on the preceding figure.
| (mm) | (mm) | ||
|---|---|---|---|
| 0 | 0.509434 | 0.482759 | 0 |
| 16 | 0.283019 | 0 | 0 |
| 24 | 0.188679 | 0 | 11 |
| 36 | 0.018868 | 0 | 15 |
| 40 | 0 | 0 | 20 |
| 80 | 0 | 0 | 56 |
| 120 | 0 | 0 | 91 |
At , the contact gap remains strictly closed, but approximately half of each lit grid registers as false shadow. Apron acne is fully resolved by , though the ramp still exhibits an acne fraction of while the gap remains closed. Progressing to , the ramp fraction diminishes to , the apron is entirely clear, and the gap has just begun to open to . The ramp fraction finally reaches zero at , incurring a gap of . Pushed to the extreme at , both acne fractions are zero, but the gap expands unacceptably to . The chosen operating point sits strategically in the interior space where ramp acne is largely suppressed and the contact gap has only just started to pull away.
Metrics snapshot. A captured image of this run’s parameter table. Should any glyph appear soft or clipped in the image, the text-based markdown tables serve as the definitive reference.

Bias as a length on one map
The shadow map stores a single depth value per texel, representing the front-most surface rasterized from the light's perspective. The subsequent depth comparison simply asks whether the shaded point sits farther from the light than this stored depth. For surfaces that tilt across the texel, the majority of shaded points naturally fall farther away than the front-most fragment, causing them to fail the comparison. Acne is the direct visual manifestation of this mismatch: the receiver’s analytic visibility toward the sun is 1, yet the depth compare incorrectly classifies it as shadowed.
Given this specific frustum, the texel slope heavily dominates the 24-bit quantisation step. The geometric slope across the apron spans per texel, while the depth quantisation step is a mere . The ratio between them is (roughly ), which easily clears the acceptance gate threshold set at . Consequently, the acne observed in the cover’s family of frames is strictly a texel-slope failure. Phenomena such as winner-islands are categorized differently and remain detailed in the z-fighting note.
Introducing a bias subtracts a physical length along the ray just prior to the depth comparison, effectively pushing the shaded point toward the light source. A sufficiently large absorbs the texel mismatch, causing the acne fraction to reliably fall. However, this identical spatial push shifts the shadow boundary of any thin occluder away from its true physical contact point. The stretch of ground between the physical foot and the displaced shadow boundary is analytically shadowed, but the depth compare incorrectly evaluates it as lit. This detached length, when measured along the apron, is precisely the contact gap .
The presence of two distinct receivers prevents this trade-off from collapsing into a single, trivial slope. The wash ramp is lightly grazed by the sun at a shallow incidence of . Conversely, the apron faces the sun more directly, determined by the sun’s unadjusted altitude of . A constant bias large enough to quiet the severe acne on the ramp immediately induces a visibly detached gap at the steel plate. A slope-scale approach, however, adaptively applies a larger offset for the ramp’s steep texel slope and a comparatively shorter length for the apron. This intelligent scaling forces the marked point off the traditional constant-bias curve, driving ramp acne down while maintaining a tightly controlled gap.
The sample at anchors the acne-heavy end of the spectrum, whereas anchors the peter-panning end. The cover image represents the balanced interior sample, . Crucially, all three configurations share the exact same camera, exposure parameters, physical materials, and underlying shadow map. The slope-scale point is highlighted as a distinct callout, appears as the final strip on the teaching figure, and occupies a dedicated row in the metrics table. It serves as a single, highly optimized marked point residing on the exact same theoretical trade-off space.
The compare
The coordinate system is right-handed, with designated as up, measured in metres.
| symbol | meaning | unit |
|---|---|---|
| unit vector toward the sun | — | |
| sun altitude, | degree | |
| ramp tilt, | degree | |
| light depth, | ||
| ortho near and far in | ||
| window depth, at , at | — | |
| shadow texel, ortho width | ||
| constant bias along the ray, toward the sun | ||
| slope-scale multiplier | — | |
| plate thickness, | ||
| acne fraction | — | |
| contact gap along |
A single light camera is utilized across the entire ladder. Depth increases linearly along the vector. The orthographic projection uses a square frustum with a width of . Window depth is defined as:
For this run, the near and far planes are set to and , respectively, resulting in a world-space texel size of (). The corresponding quantisation step is . Calculated texel slopes are on the apron, on the ramp, and along the plate face.
Both the CPU metric analysis and the beauty shader rely on the identical depth compare function. The value represents the stored window of the winning fragment, subsequently decoded using the identical and parameters. The depth fetch relies strictly on point sampling (nearest texel). The bias function is evaluated directly against the receiver's geometric normal.
Constant sweep. For the baseline evaluation, , reducing the bias function to . The measurement ladder spans , yielding a total of thirty-one distinct samples. The underlying shadow map is rendered only once. The map's cryptographic checksum, a816326e2dbe2366, remains perfectly stable across every evaluated , including after the final beauty frame has finished rendering. The applied bias exists strictly within the comparison operator, never modifying the stored depth.
Slope-scale, one marked point. For this focused test, the constant bias is dropped () and slope-scaling is enabled (). On a planar surface, defining and as the axes of the light image, we have:
Because these derivatives are calculated per metre in the light image, effectively describes the metres of light depth traversed across a single shadow texel. On the flat, un-averaged geometry, this calculated length directly dictates the bias: across the ramp and across the apron. Note that the Khronos Neutral shoulder constant is purely a display-space parameter and represents a completely different symbol from this slope multiplier .
Acne fraction. This metric evaluates a receiver region subdivided into a strict grid. A grid sample is only considered if its analytic visibility toward the directional sun evaluates exactly to 1.
Both the ramp and apron evaluation grids adhere strictly to this definition. In this specific scene configuration, both regions are entirely analytically lit: the ramp verifies at samples, and the apron at .
Contact gap. The downstream face of the steel plate rests at , presenting a material thickness of facing the sun. When analyzing the raster map, each visible ground segment is majority-filtered using a sliding window; this filter is strictly isolated to finding the shadow boundary. The gap metric is defined as the starting coordinate of the longest continuous shadowed run, minus the physical edge coordinate . Crucially, this spatial filter is never applied to the acne metric . Immediately downstream of the plate, evaluated at , the raw comparison algorithm correctly shadows measured transect samples. This confirms that the fully closed gap is a genuine physical contact shadow, rather than an artifact of a missing shadow caster.
Ideal-map oracle. We employ a continuous analytical model as a unit test for the raster metric, scoped specifically for this plate and sun altitude:
The response curve features a distinct knee precisely at . When executed as an unfiltered walk across the ideal continuous depth profile, the algorithm aligns with to within across all five locked biases. The highest recorded walk error peaks at only . Note that the measured raster gap is empirically sampled and is not artificially fit to this oracle.
Operating point. By normalizing against the baseline extremes—defining and —we construct an objective function:
The optimal bias is computed as , where any tie defaults to the smaller . For this particular run, the solver identifies the global minimum at yielding a score of , which lands cleanly in the interior between the two swept extremes. The sample sweep was deliberately not extended beyond this bound.
Slope-scale as one marked point
Slope-scale represents a highly optimized point within the same conceptual trade-off space, defined by and , where spatial derivatives are computed in shadow-texel units. During this run, that specific configuration successfully clears both acne fractions (achieving and ) while holding the contact gap tightly at ().
Quote the metrics. The photographs are not the meter.
The metrics are evaluated in double-precision on the CPU, strictly before the Neutral tone mapper is applied. The beauty display utilizes Khronos PBR Neutral at , employing the static constants established in the tone-mapping note rather than re-fitting them per bias sample.
| item | value |
|---|---|
| scene | service-yard-curb |
| / | 32° / 20° |
| shadow resolution / ortho width | / 8 m |
| texel / depth path | 0.015625 m / color-copy |
| / | −3.722583 m / 3.934586 m |
| quantisation step / regime ratio | / 54787.622775 |
| apron / ramp / plate | 0.025005 / 0.073510 / 0.009764 m |
| shadow checksum | a816326e2dbe2366 |
| / Neutral | 3.40 / , , , |
| / | 0.036 m / 0.120 m |
| at , , | 0.509434 / 0.018868 / 0 |
| at , | 0.482759 / 0 |
| at , , | 0 / 0.015 m / 0.091 m |
| slope / | 1 / 0 |
| slope / / | 0 / 0 / 0.013 m |
| 0.040 m, | |
| apron median | −0.000350 m |
| boundary majority / depth format | 31 mm / DEPTH_COMPONENT24 |
| analytic gap / probes | pass / pass |
| asserts | 11 pass / 0 fail |
Honesty
-
The meter relies on the CPU compare. It evaluates the float color copy of the winning fragment depth against the analytic visibility grids. Both the acne fractions and the gap are derived strictly from this comparison. The shading probes sample world points using the beauty compare logic. At both and , the bits match the CPU function precisely, recording .
-
Gate 3, the apron median. The measured apron median of is (). This sits a third of a millimetre below the strict planning floor of 0, arising because the 8 mm evaluation lattice rests slightly sunward of the texel centers. Evaluating the same grid directly against those texel-center depths predicts . The control safely accepts medians above . By comparison, an undrawn apron would land near .
-
Neutral may shoulder the plate’s lit face. Specular highlights on the plate are structurally gated by the shadow bit and do not factor into or . The final display energy after the Neutral pass is not a subject of this claim. The exposure is held fixed rather than retuned per bias, utilizing the established constants from the tone-mapping note.
-
is a staircase. The majority window is employed exclusively to locate the contact boundary and is never applied to the acne calculation. The shipping gate formally demands only that . Adjacent samples along the sweep are permitted to step backward. However, on this specific run, the series does not regress: it holds on flat landings before rising monotonically from to .
-
Slope-scale is one marked point. The specific claim is that at matched ramp acne. Percentage-closer filtering, variance and exponential shadow maps, and cascades are outside this measurement.
-
One map, one checksum. The shadow pass runs once. A checksum mismatch stops the run. This run’s checksum
a816326e2dbe2366is constant across the sweep and after the last beauty. -
Rasterization is llvmpipe’s. The ideal-map oracle checks the metric code. The raster curve checks the shadow map. There is no discrete-GPU depth claim, no hierarchical-Z claim, and no vendor polygon-offset scale.
| item | value |
|---|---|
| renderer | llvmpipe, OSMesa core 3.3 request |
| color / depth | RGBA32F copy of the winning fragment ; attachment DEPTH_COMPONENT24 |
| window depth bits | 0 (the meter does not read that buffer) |
| depth-texture sample | sixteen apron texels match the color copy |
| hardware compare | sampler2DShadow agrees on 8/8 stable points |
| encode | , Neutral , sRGB OETF on the CPU |
| map | rendered once; checksum a816326e2dbe2366 |
This run can claim the following. On this OSMesa / llvmpipe build, one directional sun, one nearest-texel shadow map, and one constant-bias sweep from 0 to 120 mm produced a falling acne fraction on both receivers and a rising contact gap at a 12 mm plate. The operating point that minimises the normalised sum of ramp acne and gap is the interior sample (). Slope-scale at clears ramp acne at a shorter gap than the matching constant sample, 13 mm against 20 mm. The regime ratio places the failure in the texel-slope regime. The run prints 11 pass / 0 fail.
This run does not claim the following. A GPU, a wavefront, or a frame-time budget. A filtered shadow, a cascade, or a soft penumbra. A measured polygon offset, a normal-offset bias, or a receiver-plane depth. Acne or gap read from a JPEG. A second depth codebook, a fight-fraction, or a reverse-Z curve. A ranking of this bias length against a product shadow stack.
The eleven checks cover window depth, the regime ratio, the apron median, lit and covered regions, the ideal-map gap, probes and the checksum, frame projection, falling acne, a rising gap, an interior operating point, and the slope-scale gap.
Percentage-closer and contact-hardening filters, cascades, and atlas packing sit outside the measurement, as do a second light, an animated sun, and a soft penumbra. So do reverse-Z, a depth-format sweep, and the z-fighting note’s fight-fractions. The cover is the operating point. The sweep is the teaching figure. Bias is a geometric length, and the curve is the photograph.