Volumetric Lighting
Volumetric light effects are caused by light being scattered in a humid or dusty environment. It’s a beautiful looking natural phenomenon also known as ‘god rays’.
To challenge myself, I tried implementing this effect in real-time in the Unity game engine based on the same technique used in Killzone: Shadow Fall from Guerrilla Games.
Technique overview
- For each light, create a custom render target (half or quarter resolution for better performance).
- Render a shape that represents the light’s volume. For point lights we render a sphere and for spot lights a cone. Directional lights are rendered with a fullscreen quad as the volume covers the entire scene.
- At every pixel, calculate a line segment of the view ray that intersects with the light’s volume.
- Raymarch along this line segment and sample multiple light contributions.
- A dither effect is used to offset the ray origin.
- In the post processing stage, we add the volumetric light render target to the light buffer.
References
GPU Pro 5 - Volumetric Light Effects in Killzone: Shadow Fall by Nathas Vos