It’s one single mesh, with UV data and then just a texture applied normally. So the color of the character is only based on the texture map (as far as I understand).
Shader "ToonRimShader"
{
Properties
{
_Color ("Main Color", Color) = (1, 1, 1, 1)
_MainTex ("Texture", 2D) = "white" {}
_BumpMap ("Bumpmap", 2D) = "bump" {}
_RampTex ("Shading Ramp", 2D) = "gray" {}
_RimPower ("Rim Power", Float) = 3.0
_Cutoff ("Alphatest Cutoff", Range(0, 1)) = 3.0
_UseColor ("Use Color", Color) = (1, 1, 1, 1)
_LightColor ("Light Color", Color) = (1, 1, 1, 1)
}
SubShader
{
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf ToonRimShader alphatest:_Cutoff
#pragma target 3.0
struct Input
{
float2 uv_MainTex;
float2 uv_BumpMap;
float3 viewDir;
};
sampler2D _MainTex, _BumpMap, _RampTex;
samplerCUBE _Cube;
float4 _UseColor;
float4 _LightColor;
float _RimPower;
half4 LightingToonRimShader (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
{
half3 h = normalize (lightDir + viewDir);
half NdotL = dot (s.Normal, lightDir);
half diff = NdotL * 0.5 + 0.5;
half3 ramp = tex2D(_RampTex, float2(diff * atten)).rgb;
float nh = max (0, dot (s.Normal, h));
float spec = pow (nh, 50.0);
half4 c;
c.rgb = (s.Albedo * (_LightColor0.rgb * diff * ramp) + (_LightColor0.rgb * spec)) * (atten * 2);
c.a = s.Alpha;
return c;
}
void surf (Input IN, inout SurfaceOutput o)
{
o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;
o.Albedo *= _UseColor.rgb;
o.Alpha = tex2D(_MainTex, IN.uv_MainTex).a;
o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
half rim = 1.0 - saturate(dot(normalize(IN.viewDir), o.Normal));
o.Emission = pow(rim, _RimPower) * _LightColor.rgb;
}
ENDCG
}
Fallback "Transparent/Cutout/Diffuse"
}
I wrote this with the help of the shaderlab documentation and a team fortress shader found somewhere on these forums. I think that I got a good sense of how it works and seem to understand the basics. As you might’ve noticed I’m fairly new to shader programming. I also added a _UseColor to change the Albedo color and that works well (it’s not needed, that was just for me). I AM also able to change the rim lighting color. Just not in the way I want. Maybe I’m doing it totally wrong.
Thanks for your help so far 