Expand description
Volumetric Fog — Froxel-based participating media rendering.
Clean-room implementation based on published techniques:
- Wronski, “Volumetric Fog and Lighting” (SIGGRAPH 2014)
- Hillaire, “Physically Based & Unified Volumetric Rendering” (SIGGRAPH 2015)
- CryEngine volumetric fog (algorithmic reference only, clean-room reimplemented)
§Pipeline
-
Density injection: Fill a 3D froxel grid with scattering/extinction coefficients. Sources: global fog, height fog, force field density, game state (corruption, boss aura), particle emitters.
-
Light scattering: For each froxel, compute in-scattered light from all scene lights using Henyey-Greenstein phase function (Mie) and Rayleigh scattering. Supports directional, point, and spot lights.
-
Temporal reprojection: Blend current frame with previous to reduce noise and flickering (exponential history, 95% previous / 5% current).
-
Ray march integration: Accumulate scattering and transmittance front-to-back through the froxel grid for each pixel.
-
Composite: Apply fog color and transmittance to the scene in the existing bloom/composite pass.
§Froxel Grid
The 3D grid is frustum-aligned: XY matches screen tiles, Z uses exponential depth distribution (more slices near camera for detail). Default: 160 x 90 x 128 = ~1.8M froxels.
Depth slice mapping (exponential): z_world = near * (far/near)^(slice/num_slices)
This gives ~64 slices in the first 10% of the depth range.
Structs§
- Field
Injection Config - How force fields inject density into the fog.
- FogField
Source - A force field that injects fog density.
- FogPresets
- Room-type fog presets for different game areas.
- FogResult
- Result of ray marching through the froxel grid for one pixel.
- Froxel
- Data stored per froxel.
- Noise
Config - 3D noise for density variation (turbulence, wisps).
- Volumetric
FogConfig - Full volumetric fog configuration.
- Volumetric
FogPipeline
Enums§
- FogField
Type - FogLight
- A light that contributes to volumetric scattering.