Culling
EntropyPortal employs a multi-stage culling system to minimize the number of objects submitted to the GPU.
Visibility Service
Section titled “Visibility Service”The VisibilityService maintains a spatial index of all renderable entities in the scene.
- Structure: A loose Octree (or similar spatial partition).
- Updates: Handling dynamic objects vs static objects.
Culling Stages
Section titled “Culling Stages”1. Frustum Culling (CPU)
Section titled “1. Frustum Culling (CPU)”For each camera (Main, Shadow Cascade, Probe):
- Extract the camera’s view frustum planes.
- Query the spatial index for objects within the frustum.
- Result: A list of potentially visible
EntityIDs.
This coarse culling removes the majority of off-screen objects.
graph TD
Cam[Camera] --> Planes["Extract Frustum Planes"]
Planes --> Query["Query Octree"]
Query --> Traverse{Traverse Nodes}
Traverse -->|Inside| Add["Add to List"]
Traverse -->|Outside| Skip["Discard Node"]
Add --> Result["Visible Entity List"]
2. Occlusion Culling (GPU - Planned)
Section titled “2. Occlusion Culling (GPU - Planned)”Note: This feature is planned but not yet fully implemented.
Occlusion culling uses a low-resolution depth buffer (Hi-Z) to discard objects that are hidden behind others.
- Two-Pass Approach: Render occluders -> Build Hi-Z -> Cull occludees.
- Compute Shader: Bounding boxes are tested against the depth pyramid.
3. Light Culling (Compute)
Section titled “3. Light Culling (Compute)”As part of the Clustered Shading pipeline, lights are culled against the view frustum clusters. This ensures that a fragment only processes lights that actually affect it.