Volumetric Fog
Volumetric Fog is a rendering feature that simulates light transmission through a scene that contains fog (dust, smoke, particles, steam, etc.). The effect itself is implemented using a set of 3D textures (volume textures) that are attached to the camera and are used to compute the per-cell fog particle density, albedo, and lighting. This information is used to estimate the amount of light scattering through the volume to the camera. This results in realistic-looking fog and gives a very good performance-quality ratio.
Technical aspects
- Target PC + Consoles
- Requires 3D Textures + Compute Shaders
- ~1.1ms (on GTX 840M - Witcher 3 runs at a stable 21 FPS on it)
- Low-res sampling + Temporal filtering
- Local fog particles density and color
- Volumetric shadows
Algorithm
- 3D texture aligned to camera the frustum
- Voxels (3d texels) store data per world-space cell
- Supports hardware filtering
- Low resolution 3D texture (e.g. 150x80x64)
- Outputs 3D texture with accumulated lighting and transmittance
Algorithm steps:
- Initialize volume properties
- Write fog attributes into the set of two 3D textures:
- Scattering.rgb, Absorption.a – R16G16B16A16
- Emissive.rgb – R11G11B10
- Use volume particles to modify fog locally (eg. steam coming out of pipe)
- Light Injection
- Calculate per-cell diffuse lighting (use HDR format R11G11B10, can use shadow maps)
- Light Scattering
- Calculate scattering and extinction
- Apply temporal blend (~7% blend current frame with the previous)
- Final Integration
- Integrate along the view ray (the one moment in your life when you actually use ∫f(x)dx)
How to use it
Use the Exponential Height Fog actor and enable the Volumetric Fog option. Then you can adjust its density and other parameters. Also, every light can affect the fog by adjusting the Volumetric Scattering Intensity value and Cast Volumetric Shadow option.
Showcase
Local Fog via Volumetric Fog Particles
The Exponential Height Fog actor controls the global properties of the fog on the scene such as Albedo, Density, and Emission. To create local-fogging effects such as smoke, dust or mist use particles with the Volumetric Fog Rendering module.
Make sure to assign the material shader to the material created with a Volume Particle domain. Then use a Color input to define the albedo color of the fog, Emissive input for light emission and Mask with Opacity to define the fog particle shape (eg. use a world-aligned noise texture to add a more realistic look to the fog).
Volumetric Fog Particles are rendered using a Sphere shape, so use the per-particle Radius property to control the size of the particles.