Render Techniques
Concept
Section titled “Concept”In EntropyPortal, an IRenderTechnique encapsulates a specific strategy for drawing the scene. This abstraction allows us to switch between different rendering paths (e.g., Forward vs Deferred) or debug modes without changing the core engine loop.
The RenderService delegates the actual drawing command recording to the active IRenderTechnique.
Clustered Shading Technique (ClusteredShadingTechnique)
Section titled “Clustered Shading Technique (ClusteredShadingTechnique)”This is the primary rendering path for EntropyPortal, implementing a Clustered Forward Rendering pipeline.
Architecture
Section titled “Architecture”- Grid Construction: The view frustum is divided into a 3D grid of clusters (tiles x depth slices).
- Light Culling (Compute):
- A compute shader calculates which lights affect which clusters.
- Result is a per-cluster light list stored in GPU buffers.
- Forward Rendering:
- Geometry is drawn in a single forward pass.
- The fragment shader determines the current cluster from screen position and depth.
- It iterates only the relevant lights for that cluster, drastically reducing shading cost compared to standard forward rendering.
Key Components
Section titled “Key Components”- AABB Buffer: Bounding boxes for each cluster.
- Light Index List: Flattened array of light indices.
- Light Grid: Offset/Count per cluster pointing into the index list.
- Global Index: Atomic counter for filling the index list.
sequenceDiagram
participant RenderService
participant Technique
participant Compute
participant Graphics
RenderService->>Technique: beginFrame()
Technique->>Compute: Dispatch BuildClusters
Technique->>Compute: Dispatch CullLights
RenderService->>Technique: render()
Technique->>Graphics: Draw Geometry (Read LightGrid)
Debug Render Technique (DebugRenderTechnique)
Section titled “Debug Render Technique (DebugRenderTechnique)”A specialized technique for visualizing engine internals.
Capabilities
Section titled “Capabilities”- Wireframe Overlay: Draws wireframes over the scene.
- Frustum Visualization: Draws camera frustums (e.g., frozen culling tests).
- Bounding Boxes: Visualizes ECS entity bounds and spatial index nodes.
- Light Heatmaps: Visualizes light density per cluster (color-coded).
It is designed to be composited after the main technique, allowing it to draw on top of the rendered frame.