Repository navigation
Shadow receiver bias in world units for every cascade reader - #207
Conversation
Follow-up to #199, which sized the main pass's receiver bias as one shadow texel of world distance instead of a constant in NDC. The other readers of the directional cascades still subtracted NDC constants, and all of them scale with the pancaked depth range: over a 600 m ground plane 0.002 is a metre, so anything closer than that to a receiver stops casting on it. Each reader now measures its bias from the cascade's own orthographic view-projection (x row = 2 / width in metres, z row = 1 / depth range), so no new uniform is needed: - GI mesh-card relight: 1.5-texel normal offset along the card normal plus one texel of depth; flags.x is a texel count now. - WSRC probe bake: two texels (free-space probes, no normal). - Path tracer hybrid sun: normal offset plus one texel, takes the normal. - Planar reflection pass: one texel (it already had the normal offset). - Transmitted shadows: two texels on the receiver, two opaque-map texels for the caster's hidden-glass test; the draw uniforms are now visible to the fragment stage for that. - Virtual shadow maps: one virtual texel in the scene helper, two in the material helper. The hardware GI variants trace their sun visibility and are unchanged. Co-Authored-By: Claude <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Summary
Follow-up to #199, which moved the main pass's shadow receiver bias from a constant in NDC to one shadow texel of world distance. Every other reader of the directional cascades still subtracted a constant in NDC, and all of them scale the same way: the cascades pancake their depth range to the scene bounds, so a 600 m ground plane turns
0.002into a metre and anything closer than that to a receiver stops casting on it (a deck no longer shadowing the hull under it, contact shadows floating).This PR gives each remaining reader the same world-sized bias, measured from the cascade's own orthographic view-projection so no new uniform is needed: the x row of an ortho VP has length
2 / widthin metres and the z row1 / depth range, so one texel is2 / (|x row| · map size)metres and|z row|times that in NDC.CARD_LIGHT_WGSL)0.002NDC, position onlyflags.xis now a texel count)WSRC_BAKE_WGSL)0.002NDCsun_vis_cascade)0.002NDC, caller added 2 cmrefl_sun_shadow)0.001NDC0.0015NDC0.00075NDClight_vp)0.001NDC0.001NDCThe hardware GI variants (
CARD_LIGHT_HW_WGSL,WSRC_BAKE_HW_WGSL) trace their sun visibility and never read the bias, so they are unchanged. The SSGI probe-trace uniform still carries a0.002inshadow_params.x, but no shader reads it. Point and spot light VSM pages keep their perspective-depth bias; that one does not pancake.Test plan
cargo test --release --no-fail-fastinnative/shared: 509 unit tests, the golden suite and the runtime suites pass with no golden image changed. The one failure,visibility_shading_matches_forward_reference(max delta 2 against a 1-LSB bound), fails identically onmainat 49cf675 on this machine (148 changed channels in both).cargo fmt --check,./scripts/ci-check.sh --quick --component lintand--component contracts(file-size ratchet included) pass.mainare visually identical at 1600×900. The user-visible fix was shadows: the receiver bias is a shadow texel of world distance, not a constant in NDC #199; this one brings the bounce-light and reflection feeds in line with it.Summary by CodeRabbit
Bug Fixes
Documentation