Volumetric lighting, also known as "God rays", is a technique used in 3D computer graphics to add lighting effects to a rendered scene. It allows the viewer to see beams of light shining across the environment. Examples of volumetric lighting are seeing sunbeams shining through a window and seeing sunbeams radiating when the Sun is below the horizon, also known as crepuscular rays. The term seems to have been introduced from cinematography and is now widely applied to 3D modeling and rendering, especially in the development of 3D video games.
In volumetric lighting, the light cone emitted by a light source is modeled as a transparent object and considered as a container of a "volume". As a result, light has the capability to give the effect of passing through an actual three-dimensional aerosol (e.g. fog, dust, smoke, or steam) that is inside its volume, just like in the real world.
Volumetric lighting requires two components: a light space shadow map, and a depth buffer. Starting at the near clip plane of the camera, the whole scene is traced and sampling values are accumulated into the input buffer. For each sample, it is determined if the sample is lit by the source of light being processed using the shadow map as a comparison. Only lit samples will affect final pixel color.
This basic technique works but requires more optimization to function in real time. One way to optimize volumetric lighting effects is to render the lighting volume at a much coarser resolution than that which the graphics context is using. This creates some bad aliasing artifacts, but that is easily touched up with a blur. One can also use stencil buffer like with the shadow volume technique.
Another technique can also be used to provide usually satisfying, if inaccurate volumetric lighting effects. The algorithm functions by blurring luminous objects away from the center of the main light source. Generally, the transparency is progressively reduced with each blur step, especially in more luminous scenes. Note that this requires an on-screen source of light.[1]