Creating a custom diffuse lighting model
If you are familiar with Unity 4, you may 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 and explain the mathematics and implementation behind it. The following image shows the same geometry rendered with a Standard Shader (right) and diffuse Lambert one (left):
Shaders based on the Lambertian reflectance are classified as non-photorealistic; no object in the real world really 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 perfect for mobile games.
Unity has already provided us with a lighting function that we can use for our shaders. It is called the Lambertian lighting model. It is one of the more basic...