Creating a custom diffuse lighting model
If you are familiar with Unity 4, you might know that the default shader it provided was based on a lighting model called Lambertian reflectance. This recipe will show you how it is possible to create a shader with a custom lighting model. Additionally, we will explain the mathematics involved and the implementation. The following diagram shows the same geometry rendered with a Standard Shader (on the right-hand side) and a diffuse Lambert one (on the left-hand side):
Shaders based on the Lambertian reflectance are classified as non-photorealistic; no object in the real world actually looks like this. However, Lambert shaders are still often used in low-poly games, as they produce a neat contrast between the faces of complex geometries. The lighting model used to calculate the Lambertian reflectance is also very efficient, making it...