Global Illumination
EntropyPortal uses a system of Light Probes stored as Spherical Gaussians (SG) to provide diffuse global illumination.
Light Probes
Section titled “Light Probes”Light probes capture the irradiance at a specific point in space. Unlike reflection probes, which store high-frequency detail, light probes store low-frequency lighting information suitable for diffuse indirect lighting.
Spherical Gaussians (SG)
Section titled “Spherical Gaussians (SG)”We approximate the irradiance using a sum of Spherical Gaussian lobes (typically 9 or 12 lobes).
- Compact: SG coefficients are much smaller than a cubemap (even a low-res one).
- Efficient: Irradiance reconstruction is a simple dot product in the shader.
- Interpolation: SG lobes can be interpolated smoothly between probes.
The Probe Grid
Section titled “The Probe Grid”Probes are arranged in a sparse 3D structure managed by the ProbeVolumeService.
- Capture: A low-resolution cubemap (8x8) is rendered at the probe position.
- Fitting: A compute shader converts the 8x8 cubemap into SG coefficients (
GpuSGLobe). - Storage: The coefficients are stored in a
StructuredBufferfor GPU access. - Clustering: Light probes are injected into the clustered shading grid as point lights, allowing for efficient culling and lookup.
graph TD
Sync[Sync with Scene] --> Check{Dirty?}
Check -->|Yes| Queue[Queue for Capture]
Check -->|No| Skip
Queue --> Render[Render 8x8 Cubemap]
Render --> Compute["Compute Shader:<br/>Fit SG Lobes"]
Compute --> Buffer[Write to GPU Buffer]
Relighting
Section titled “Relighting”When an object is rendered:
- The shader looks up the nearest light probes from the
LightProbeGrid. - It interpolates the SG coefficients based on the object’s position.
- It evaluates the irradiance using the surface normal.