- Home /
Toon Shader using Surface Shader
Hi, so I've been learning how to make shaders in unity the last week, and I tried making a toon shader using the Surface Shader and the Vertex Fragment Shader. The look I want to achive is getting plain colors, I want to pixelate the screen later to get that limited pixel art color pallet. The problem is that when I use the Surface Shader, I get the color bading that I want, but the shadows look more complex that I want. Look the dark areas and compare that to the Vertex Fragment Shader. The later one has plain colors, but getting that shader to work using multiple lights is a pain for me right now. Is there any way to get the simple colors in the Surface Shader? is it getting light form global ilumination? I'm still new to unity :s
Here's the surface shader
Shader "Custom/ToonCustomLightModel"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
}
SubShader
{
CGPROGRAM
#pragma surface surf BasicLambert
half4 LightingBasicLambert (SurfaceOutput s, half3 lightDir, half atten)
{
fixed NdotL = max(0, dot(s.Normal, lightDir));
fixed aux = NdotL * atten;
half4 c;
c.rgb = aux > 0.5 ? s.Albedo * _LightColor0.rgb * 1: s.Albedo * _LightColor0.rgb * 0.2;
c.a = s.Alpha;
return c;
}
struct Input
{
float2 uv_MainTex;
};
fixed4 _Color;
void surf (Input IN, inout SurfaceOutput o)
{
o.Albedo = _Color.rgb;
}
ENDCG
}
FallBack "Diffuse"
}
Your answer
Follow this Question
Related Questions
All my assets unaffected by light source 2 Answers
Can you get how much light is on the surface in a shader? 0 Answers
Lighting shader doesn't work outside spotlight 0 Answers
Shaders problem makes the gameobject invisible 0 Answers
Terrain Becomes Purple when assigning a Render Pipeline Asset. 0 Answers