Was playing around with shaders trying to make flatshading shader and by accident came upon that cool way of doing sharp cel-shading (think 2d cartoons instead of something like ToyStory) without ramp textures. Maybe will be useful for someone. Releasing under CC-by-sa (have to mention me in the credits, otherwise do whatever you want, but if modified, release under same license)
Shader "Darkhog/Awesome Toon Shader" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Color ("Main Color", Color) = (1,1,1,1)
}
SubShader {
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf WonderToon
half4 LightingWonderToon (SurfaceOutput s, half3 lightDir, half atten) {
half NdotL = round(dot (s.Normal, lightDir));
half4 c;
c.rgb = s.Albedo * _LightColor0.rgb * (NdotL * atten);
c.a = s.Alpha;
return c;
}
struct Input {
float2 uv_MainTex;
};
sampler2D _MainTex;
fixed4 _Color;
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb*_Color;
}
ENDCG
}
Fallback "Diffuse"
}
Shader in action. Obviously it would look better when model, textures and lighting are prepared for the thing, however in this case I don’t have time to do it. Feel free to post screenshots with models/scenes made for this shader.