Volumetric Lighting Part 1

Basic Volumetric Lighting

Posted by Xingyu Wang on December 21, 2020

Volumetric Lighting

I will talk about how scattering works briefly.

And then I will go through how I implement and optimize basic volumetric lighting.

At the end, I will talk about some better techniques .


About Scattering

Volumetric lighting is one of the simulations of how rays propagate through air. During this propagation process, rays hit particles(medium) floating on the air.

When a photon hits a particle, two things happen:

  1. The direction of photon changes. (Scattering)
  2. The kinetic energy of photon may change.

There are two scattering models that describes the distribution of scattering: Mie Scattering and Rayleigh Scattering.

There are more models, but we only care about these two.

Fortunately, it seems like the kinetic energy of photon is conserved in both models. Two models differs base on size of particle and wavelength of incident ray.

Rayleigh Scattering model in general, is being used to describe atmospheric scattering.

Mie Scattering model is used for interaction with large particles, like dust or fog.

In a nutshell, the model that has been used for scattering is just another form of BRDF. But since scattering is a interaction with particle so that the cosine part is unnecessay. Also, it’s no long an integral of a hemisphere, it should be an integral over the whole sphere.


My implementation

  1. Generate depth map in light space
  2. Ray marching
  3. Ordered Dithering
  4. Gaussian Blur

Depth Map

Nothing new about depth map.

Procedure of Ray Marching

1. Trace a view ray from camera position(eye) to pixel position.

Ray Marching Explaination!



2. Sampling along the view ray.

Higher number of samples will give a better result along with high computational cost and vice versa for low number of samples.

Ray Marching Explaination!

Ray Marching Explaination!

Rendering time increases from 5.3 ms/frame to 28.9 ms/frame

This runs on my Surface Laptop 2.
GPU: Intel(R) Iris(R) Plus Graphics
CPU: Intel Core i5 8250U



3. Calculate light intensity by using phase function, in this project I use Henyey-Greenstein phase function.

Henyey-Greenstein phase function!

1
-1 <= g <= 1

g determines distribution of scattering from backward scattering (g < 0>) through isotropic scattering (g = 0) to forward scattering (g > 0).



4. Accessing depth map the make sure the sampling position is not occluded by any objects.

occlution! This is depth map is not in light space.



5. The accumulation of all samples is the final volumetric light intensity.

Accumulation!



Ordered Dithering

I’m not going to talk about how dithering works in details. (maybe I will if I have time)

The idea of useing Ordered dithering is to optimize volumetric lighting.



I did not expect there are so many thing I need to write.

I will complete this post another day.