I’m learning the book of.
There’s one example the code as:
Shader "Example/Masking Specular" {
Properties {
_MainTint("Diffuse Tint",Color)=(1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_SpecuColor("Specular Color",Color)=(1,1,1,1)
_SpecPower("Specular Power",Range(0,30))=1
_SpecularMask("Specular Texture",2D)="white"{}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Phong
sampler2D _SpecularMask;
sampler2D _MainTex;
float4 _MainTint;
float4 _SpecuColor;
float _SpecPower;
struct SurfaceCustomOutput{
fixed3 Albedo;
fixed3 Normal;
fixed3 Emission;
fixed3 Specularcolor;
half Specular;
fixed Gloss;
fixed Alpha;
}
inline fixed4 LightingPhong(SurfaceCustomOutput s, fixed3 lightDir,half3 viewDir, fixed atten)
{
float diff = dot(s.Normal,lightDir);
float3 reflectionVector = normalize(2.0*s.Normal*diff-lightDir);
float spec = pow(max(0,dot(reflectionVector,viewDir)),_SpecPower)*s.Specular;
float3 finalSpec = s.Specularcolor.rgb*spec*s.Specularcolor;
fixed4 c;
c.rgb =(s.Albedo*_LightColor0.rgb*diff)+(_LightColor0.rgb*finalSpec);
c.a =s.Alpha;
return c;
}
struct Input {
float2 uv_MainTex;
float2 uv_SpecularMask;
};
void surf (Input IN, inout SurfaceCustomOutput o)
{
half4 c = tex2D (_MainTex, IN.uv_MainTex)*_MainTint;
half4 specMask = tex2D(_SpecularMask, IN.uv_SpecularMask)*_SpecuColor;
o.Albedo =c.rgb;
o.Specular = specMask.r;
o.Specularcolor = specMask.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
but there’s always warning of syntax error on line 33 and 44.so,do any one understanding why?