Parent
Part of #898.
Depends on
#900. Phase 1 (#899) may proceed in parallel after Phase 0.
Goal
Replace the contradictory CSM math and sampling path while preserving the existing Vulkan shadow resource ownership and reverse-Z convention.
Scope
- Compute practical/logarithmic cascade splits from camera near/far and configured shadow distance.
- Fit exact frustum-slice corners or correctly sized stable spheres rather than the current camera-origin far-corner radius.
- Use positive view-space depth consistently for fitting, selection, overlap, and final fade.
- Stabilize X/Y translation to the real shadow texel grid and control rotational swimming from the moving sun.
- Define explicit cascade overlap bands contained by both cascades.
- Derive map-edge margins from the active PCF kernel radius.
- Express caster/receiver bias in world and texel units with per-cascade scaling.
- Build caster candidates from receiver volumes extruded toward the light instead of a camera-centered square.
- Keep caster distance independent from receiver distance and include a chunk safety margin.
- Implement atlas-aware alpha testing for cutout shadows; stop discarding diagonal vegetation wholesale.
- Include supported entities in the shadow scene.
- Replace misleading PCF settings with coherent hard/4/9/16-tap tiers.
- Enable batched shadow submission by default once parity and overflow tests pass.
- Repair shadow-map debug previews and retain useful cascade/caster/seam channels.
Acceptance criteria
Required tests
- Frustum-corner containment and overlap containment.
- Reverse-Z endpoint mapping.
- Translation stability below one texel.
- View-depth cascade selection.
- Bias scaling across cascades.
- Alpha-cutout discard behavior.
- Caster extrusion and boundary chunk coverage.
Verification
nix develop --command zig fmt modules/engine-graphics/src modules/world-runtime/src
nix develop --command zig build test
nix develop --command zig build -Dskip-present
nix develop --command zig build test-robustness
nix develop --command zig build run -Dskip-present -Dshadow-test-scene -Dscreenshot-path=screenshots/lighting-phase2-shadow.png -Dscreenshot-frame=180
nix develop --command zig build benchmark -Doptimize=ReleaseFast -Dbenchmark-preset=high -Dbenchmark-duration=60 -Dbenchmark-output=lighting-phase2-high.json
Parent
Part of #898.
Depends on
#900. Phase 1 (#899) may proceed in parallel after Phase 0.
Goal
Replace the contradictory CSM math and sampling path while preserving the existing Vulkan shadow resource ownership and reverse-Z convention.
Scope
Acceptance criteria
Required tests
Verification
nix develop --command zig fmt modules/engine-graphics/src modules/world-runtime/src nix develop --command zig build test nix develop --command zig build -Dskip-present nix develop --command zig build test-robustness nix develop --command zig build run -Dskip-present -Dshadow-test-scene -Dscreenshot-path=screenshots/lighting-phase2-shadow.png -Dscreenshot-frame=180 nix develop --command zig build benchmark -Doptimize=ReleaseFast -Dbenchmark-preset=high -Dbenchmark-duration=60 -Dbenchmark-output=lighting-phase2-high.json