Shader “Custom/LayeredEmitDiffuseShader“ {
Properties {
_MainTex (“Base (RGB)“, 2D) = “gray“ {}
_MainColor(“Recolor“, Color) = (1,1,1,1)
_DetailTex (“Detail (RGB)“, 2D) = “black“ {}
_DetailColor(“Recolor“, Color) = (0,0,0,0)
_EmitTex (“Emit (RGB)“, 2D) = “black“ {}
_EmitColor(“Recolor“, Color) = (0,0,0,0)
_EmitPower(“EmitPower“, range(0,2)) = 1
_MidShadowPower(“Mid Shadow Power“, range(0,1)) = 0.85
_MidShadowThreshold(“Mid Shadow Threshold“, range(0,1)) = 0.85
_DeepShadowPower(“Deep Shadow Power“, range(0,1)) = 0.15
_DeepShadowThreshold(“Deep Shadow Threshold“, range(0,1)) = 0.15
_StrokeThickness(“Stroke Thickness“, range(0,1)) = 0.3
_StrokeColor(“Stroke Color“, Color) = (0,0,0,1)
}
SubShader {
Tags { “RenderType“=“Opaque“ }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
half _MidShadowPower;
half _MidShadowThreshold;
half _DeepShadowPower;
half _DeepShadowThreshold;
// custom lighting function that uses a texture ramp based
// on angle between light direction and normal
//#pragma lighting ComicRamp exclude_path:prepass
// inline half4 LightingComicRamp (SurfaceOutput s, half3 lightDir, half atten)
// {
// half NdotL = saturate(dot (s.Normal, lightDir));
//
// half shadow = NdotL < _DeepShadowThreshold ? _DeepShadowPower : NdotL < _MidShadowThreshold ? _MidShadowPower : 1;
//
// half4 c;
// c.rgb = s.Albedo * _LightColor0.rgb * shadow * atten;
// c.a = s.Alpha;
// return c;
// }
sampler2D _MainTex;
sampler2D _DetailTex;
sampler2D _EmitTex;
half _StrokeThickness;
half4 _StrokeColor;
half4 _MainColor;
half4 _DetailColor;
half4 _EmitColor;
half _EmitPower;
struct Input {
float2 uv_MainTex : TEXCOORD0;
float3 viewDir;
};
void surf (Input IN, inout SurfaceOutput o) {
half stroke = saturate(dot (normalize(IN.viewDir), o.Normal)) > _StrokeThickness ? 0 : 1;
half4 c = tex2D (_MainTex, IN.uv_MainTex);
c.rgb *= _MainColor.rgb;
half4 d = tex2D (_DetailTex, IN.uv_MainTex);
d.rgb *= _DetailColor.rgb;
half4 e = tex2D (_EmitTex, IN.uv_MainTex);
e.rgb *= _EmitColor.rgb;
o.Emission = e.rgb * e.a * _EmitPower;
c.rgb = (d.rgb * d.a) + (c.rgb * (1.0 – d.a));
//c.rgb += (e.rgb * e.a * _EmitPower);
o.Albedo = stroke > 0.0 ? _StrokeColor.rgb : c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack “VertexLit“
}