Shadows
| Source guide | Project README |
Creates and renders directional sunlight shadow maps, with cached camera and mesh state to avoid unnecessary redraws.
Shadow pass and cache
flowchart LR
Sun["Sun position"] --> Check{"Casters + sun altitude ≥ 3°?"}
Meshes["Loaded shadow casters"] --> Check
Check -->|no| Disable["Disable shadow pass"]
Check -->|yes| Cache{"Cache matches?"}
Cache -->|yes| Reuse["Reuse depth map"]
Cache -->|no| Draw["Fit matrix + render depth map"]
Loaded off-screen geometry can cast shadows. Cache snapshots include direction, world versions, geometry and draw ranges: changes affecting shadows must invalidate the cache. Point lights are separate.
- renderSunlight.js: update sunlight shadow rendering.
- shadowMatrix.js: fit the shadow camera to scene bounds.
- ensureShadowPipeline.js: prepare shadow GPU pipelines.