Shader "Skin2NormalsBlend"
{
Properties
{
//_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
_Shininess ("Shininess", Range (0.01, 10)) = 0.078125
_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
_BumpMap ("Bump (RGB)", 2D) = "bump" {}
_BumpMap2 ("Bump2 (RGB)", 2D) = "bump" {}
_Blend1 ("Red Blend", Range (0.0, 1)) = 0.0
_Blend2 ("Green Blend", Range (0.0, 1)) = 0.0
_Blend3 ("Blue Blend", Range (0.0, 1)) = 0.0
_RimTex ("Rim ramp (RGB) Fresnel ramp (A)", 2D) = " grey" {}
_WrapTex ("Wrap ramp (RGBA)", 2D) = "black" {}
}
SubShader {
Tags { "RenderType" = "Opaque" }
LOD 400
CGPROGRAM
#pragma surface surf BumpSpecSkin vertex:vert
fixed _Shininess,_Blend1,_Blend2,_Blend3;
//fixed4 _Color;
sampler2D _MainTex,_WrapTex,_RimTex,_BumpMap,_BumpMap2;
fixed4 LightingBumpSpecSkin (SurfaceOutput s, fixed3 lightDir, fixed3 viewDir, fixed atten)
{
fixed rimf = dot(s.Normal, viewDir);
fixed4 rim = tex2D (_RimTex, rimf.xx);
fixed3 h = normalize( lightDir + viewDir );
fixed diffusePos = dot(s.Normal, lightDir) * 0.5 + 0.5;
fixed4 diffuse = tex2D (_WrapTex, diffusePos.xx);
diffuse.rgb *= rim.rgb * 4;
fixed nh = saturate( dot( h, s.Normal ) );
fixed spec = pow( nh, s.Specular * 128) * s.Gloss;
fixed4 c;
c.rgb = (s.Albedo + _SpecColor.rgb * spec * rim.a) * diffuse * (atten * 2) * _LightColor0.rgb;
c.a = _LightColor0.a * _SpecColor.a * spec * atten;
return c;
}
fixed4 LightingBumpSpecSkin_PrePass (SurfaceOutput s, fixed4 light)
{
fixed spec = light.a * s.Gloss;
fixed4 c;
c.rgb = (s.Albedo * light.rgb + light.rgb * _SpecColor.rgb * spec);
c.a = s.Alpha + spec * _SpecColor.a;
return c;
}
struct Input
{
fixed2 uv_MainTex;
fixed3 vColor;
};
void vert (inout appdata_full v, out Input o)
{
o.vColor = v.color.rgb * fixed3(_Blend1,_Blend2,_Blend3);
}
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 texcol = tex2D( _MainTex, IN.uv_MainTex);
o.Albedo = texcol.rgb;// * _Color;
o.Gloss = texcol.a;
o.Specular = _Shininess;
fixed3 n1 = UnpackNormal (tex2D (_BumpMap, IN.uv_MainTex));
fixed3 n2 = UnpackNormal (tex2D (_BumpMap2, IN.uv_MainTex));
fixed lerpmask = IN.vColor.r + IN.vColor.g + IN.vColor.b;
o.Normal = lerp(n1,n2,lerpmask);
}
ENDCG
}
Fallback "Diffuse"
}