Files
butchers-games-test/Assets/Art/Shaders/Voodoo_LaunchOps_SliderRampSpecularNormal.shader
T
Boris Nikolaev 5f1e94b653 add project files
2026-08-14 01:58:31 +03:00

70 lines
2.3 KiB
Plaintext

// See "Toony Colors Pro 2/User/SliderRamp" for the ramp model. This variant adds a normal
// map and a toon specular lobe; _Smoothness is TCP2's "Size" slider, which controls how
// wide the highlight is rather than a PBR roughness.
Shader "Voodoo_LaunchOps/SliderRampSpecularNormal" {
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", Float) = 0.2
[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;
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));
// _Smoothness reads 0..1 as "highlight size", so map it to an exponent inversely
half spec = pow(ndh, max(1.0, (1.0 - saturate(_Smoothness)) * 128.0)) * atten;
half4 c;
c.rgb = s.Albedo * _LightColor0.rgb * tint + _LightColor0.rgb * _SpecColor.rgb * spec;
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"
}