Diffuse Lighting

  • Custom Lighting

    Calculating a Custom Diffuse Lighting Model from scratch

  • HLSL + C#

    Using these languages to achieve these results

  • Stylized Application

    Exploring a more stylized interpretation

Creating a Custom Diffuse Lighting Model in Unity to further understand how the interaction of light works inside a game engine

The Problem:

Whilst using the Universal Render Pipeline (URP) in Unity, I noticed Surface Shaders were no longer supported (these helped by calculating lighting for you). Whilst Unity’s Shader Graph provides a simple method to acquire this data, I wanted more control and to understand how diffuse lighting is is calculated.

The Solution

Diffuse Lighting was calculated using HLSL to obtain the Sun’s light direction and C# was used to manipulate these values based on the ‘Main Directional Light’. This resulted in a simple, cheap and easy solution that meant I had access to lighting data which I could manipulate in several different ways.

 

One of these methods involved taking a more stylized approach to the lighting data by applying a colour ramp to the sun’s affected area. In doing so a quantized look was applied to the objects and a greater understanding of lighting was obtained