Lighting
| Source guide | Project README |
Collects point lights from visible scene layers and maintains spatial grids for fixed and moving lights. Grid data is uploaded for the shared renderer.
Point-light grids
flowchart LR
Layers["Visible nightLight layers"] --> Collect["Collect world-space lights"]
Collect --> Fixed["Fixed grid"]
Collect --> Moving["Moving grid"]
Fixed --> Buffer["Shared GPU storage buffer"]
Moving --> Buffer
Buffer --> Shader["Nearby-light lookup"]
Grids use 32-metre cells. If their data exceeds the GPU storage limit, the update throws; buffer growth also refreshes bindings. Directional sunlight uses separate shadows.
- updatePointLights.js: collect, cache and upload light grids.
- lightGrid.js: build a spatial light grid.
- worldLights.js: transform lights into world coordinates.