There's more...

There are many different ways whereby you can achieve a toon shading effect. Using different ramps can produce dramatic changes in the way your models look, so you should experiment in order to find the best one.

An alternative to ramp textures is to snap the light intensity NdotL so that it can only assume a certain number of values equidistantly sampled from 0 to 1:

half4 LightingCustomLambert (SurfaceOutput s, half3 lightDir,                 half3 viewDir, half atten) {   half NdotL = dot (s.Normal, lightDir);   // Snap instead  half cel = floor(NdotL * _CelShadingLevels) /              (_CelShadingLevels - 0.5);   // Next, set what color should be returned  half4 color;   color.rgb = s.Albedo * _LightColor0.rgb * (cel * atten );   color.a = s.Alpha; 

Get Unity 2018 Shaders and Effects Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.