Unity Volumetric 2D Lighting

Another thing that always fascinated me was volumetric 2d lighting in videogames, such as flashlights in stealth games or lights that seem to cast proper shadows.

1 minute read

Platform

PC

Engine

Unity 5

Technologies Used

C# ShaderLab Unity

Another thing that always fascinated me was volumetric 2d lighting in videogames, such as flashlights in stealth games or lights that seem to cast proper shadows. So I started researching, and came up with a very basic implementation. Did not really care about performance, though it wasn’t too obscenely bad.

You can see the lights properly casting shadows against those objects, and you can also partially see the way light colors mix properly.
This is a demo directly showcasing light mixing, instead. I find it interesting how the slight misalignment gives it a RGB LED effect that’s been set to white. Anybody need a gaming rgb game?
This is the mesh generation without any light shader, has some debugging gizmos enabled too.

Unfortunately, while it was possible to adjust the light cone’s angle, I did not find any videos I took where I show how that looks. I cannot find the source code either.