Skip to main content

Module volumetric_fog

Module volumetric_fog 

Source
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

  1. 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.

  2. 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.

  3. Temporal reprojection: Blend current frame with previous to reduce noise and flickering (exponential history, 95% previous / 5% current).

  4. Ray march integration: Accumulate scattering and transmittance front-to-back through the froxel grid for each pixel.

  5. 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§

FieldInjectionConfig
How force fields inject density into the fog.
FogFieldSource
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.
NoiseConfig
3D noise for density variation (turbulence, wisps).
VolumetricFogConfig
Full volumetric fog configuration.
VolumetricFogPipeline

Enums§

FogFieldType
FogLight
A light that contributes to volumetric scattering.