Creating a Toon Shader
One of the most used effects in games is the toon shading, which is also known as cel shading (short for celluloid). It is a non-photorealistic rendering technique that makes 3D models appear flat. Many games use it to give the illusion that the graphics are being hand-drawn rather than being 3D-modeled. You can see, in the following picture, a sphere rendered with a Standard Shader (right) and Toon Shader (left):
Achieving this effect using just surface functions is not impossible, but it would be extremely expensive and time-consuming. The surface function, in fact, only works on the properties of the material, not its actual lighting condition. As toon shading requires to change the way light reflects, we need to create our custom lighting model instead.
Getting ready
Let's start this recipe by creating a shader and its material and importing a special texture, as follows:
- Start by creating a new shader; in this example, we will extend the one made in the previous...