// See "Toony Colors Pro 2/User/SliderRamp" for the ramp model, and // "Voodoo_LaunchOps/SliderRampSpecularNormal" for the specular lobe. This variant adds a // rim term: 1 - N.V pushed through smoothstep(_RimMin, _RimMax) and added on top, which is // what gives the character its outline glow. Shader "Voodoo_LaunchOps/SliderRampSpecRimNormal" { Properties { [TCP2HeaderHelp(BASE, Base Properties)] _Color ("Color", Vector) = (1,1,1,1) _HColor ("Highlight Color", Vector) = (0.785,0.785,0.785,1) _SColor ("Shadow Color", Vector) = (0.195,0.195,0.195,1) _MainTex ("Main Texture", 2D) = "white" {} [TCP2Separator] [TCP2Header(RAMP SETTINGS)] _RampThreshold ("Ramp Threshold", Range(0, 1)) = 0.5 _RampSmooth ("Ramp Smoothing", Range(0.001, 1)) = 0.1 [TCP2Separator] [TCP2HeaderHelp(NORMAL MAPPING, Normal Bump Map,)] _BumpMap ("Normal map (RGB)", 2D) = "bump" {} [TCP2Separator] [TCP2HeaderHelp(SPECULAR, Specular)] _SpecColor ("Specular Color", Vector) = (0.5,0.5,0.5,1) _Smoothness ("Size", Range(0, 1)) = 0.2 [TCP2Separator] [TCP2HeaderHelp(RIM, RIM)] _RimColor ("Rim Color", Vector) = (0,0,0,0) _RimMin ("Rim Min", Range(0, 1)) = 1 _RimMax ("Rim Max", Range(0, 5)) = 1 [TCP2Separator] [HideInInspector] __dummy__ ("unused", Float) = 0 } SubShader { Tags { "RenderType"="Opaque" } LOD 250 CGPROGRAM #pragma surface surf ToonRamp fullforwardshadows #pragma target 3.0 fixed4 _Color; fixed4 _HColor; fixed4 _SColor; sampler2D _MainTex; sampler2D _BumpMap; half _RampThreshold; half _RampSmooth; half _Smoothness; fixed4 _RimColor; half _RimMin; half _RimMax; inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) { half ndl = dot(s.Normal, lightDir) * 0.5 + 0.5; half ramp = smoothstep(_RampThreshold - _RampSmooth * 0.5, _RampThreshold + _RampSmooth * 0.5, ndl); ramp *= atten; half3 tint = lerp(_SColor.rgb, _HColor.rgb, ramp); half3 h = normalize(lightDir + viewDir); half ndh = max(0, dot(s.Normal, h)); half spec = pow(ndh, max(1.0, (1.0 - saturate(_Smoothness)) * 128.0)) * atten; half ndv = 1.0 - saturate(dot(normalize(viewDir), s.Normal)); // _RimMin == _RimMax would make smoothstep undefined, so keep them apart half rim = smoothstep(_RimMin, max(_RimMax, _RimMin + 0.001), ndv) * _RimColor.a; half4 c; c.rgb = s.Albedo * _LightColor0.rgb * tint + _LightColor0.rgb * _SpecColor.rgb * spec + _RimColor.rgb * rim; c.a = s.Alpha; return c; } struct Input { float2 uv_MainTex; float2 uv_BumpMap; }; void surf (Input IN, inout SurfaceOutput o) { fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; o.Albedo = c.rgb; o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); o.Alpha = c.a; } ENDCG } Fallback "Diffuse" }