© 2019  Joseph Kane

  • LinkedIn Social Icon

Volumetric Lighting for Unity

"Volumetric lighting for Unity" was my dissertation project for my bachelor's degree. It is a set of scripts and shaders for the Unity game engine which can be added to lights to simulate light scattering due to particles in the air, creating rays of light, commonly known in games as "god rays". The project aimed to be capable of running in realtime applications such as games while also being realistic and adjustable, per light, to the user's needs. The description of how it works can be found in the dissertation which can be accessed using the button at the bottom of the page.

My work on the project included:

In C#:

  • Programmed procedural generation of sphere and cone meshes to represent the lights volume

  • Implemented precalculations each frame in C# that pass the results to the shader.

  • Implemented a method of accessing Unity's most recently created internal shadow map using a command buffer so that it can be accessed by the volumetric light shader.

In shaders using Shaderlab and Cg:

  • Programmed the calculation of the intersection points of the current pixels view ray, with the lights volume.

  • Implemented raymarching from each screen pixel to perform calculations at sample points within the lights volume.

  • Programmed calculating the light contribution and light transmittance

  • Implemented interleaved sampling using a dithering texture to improve performance

  • Added option to calculate at a lower resolution which required the implementation of downscaling the depth texture using a min function

  • Implemented depth aware bilateral upsampling to upscale the texture while taking depth into account so as to improve quality of upscaling after calculating at a lower resolution.

  • Implemented a depth aware Gaussian blur for smoothing the resulting light without affecting surrounding rendered objects.

Outside of programming:

  • Analyzed documents on volumetric lighting techniques used in other projects to find the best solution for this project.

  • Planned the project using class diagrams and activity diagrams.

  • Created a method of calculating the intersection points of a ray through a cone.

  • Debugged shaders through using the RenderDoc application and Unity's frame debugger.

  • Assessed the projects performance using Unity's GPU profiler.

  • Documenting the project throughout its development.

Code viewable from source control

Below is the links to the project source on my bitbucket account

Project source

C# scripts


This site was designed with the
website builder. Create your website today.
Start Now