Hey, I am having a problem with my shader.
Shader "1. Toon Step 1/Bump Map" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_NormalMap ("Normal Map", 2D) = "white" {}
_SpecMap ("Sepcular Map", 2D) = "white" {}
_Glossiness ("Gloss", range(1,4)) = 2
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
half4 _Color;
sampler2D _MainTex;
sampler2D _NormalMap;
sampler2D _SpecMap;
half _Glossiness;
struct MySurfaceOutput{
half3 Albedo;
half3 Normal;
half3 Emission;
half Specular;
half Alpha;
half3 GlossColor;
};
half diffuseTerm(half3 a, half3 b) {
return max(0, dot(normalize(a), normalize(b)));
}
half4 LightingSpecMap(MySurfaceOutput o, half3 lightDir, half3 viewDir, half atten) {
half d = diffuseTerm(o.Normal, lightDir);
half3 diffuseColor = _LightColor0 * o.Albedo * (1-d);
//half s = diffuseTerm(o.Normal, lightDir + viewDir);
//half3 specularColor = _LightColor0 * o.GlossColor * s;
half3 returnColor = diffuseColor * atten * 2;
return half4(returnColor, o.Alpha);
}
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout MySurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb * _Color; // times c.rgb with _Color makes it tint able
o.Alpha = c.a;
half3 n = UnpackNormal (tex2D(_NormalMap, IN.uv_MainTex));
o.Normal = n;
//half4 s = tex2D(_SpecMap, IN.uv_MainTex);
//o.GlossColor = s.rgb;
}
ENDCG
}
FallBack "Diffuse"
}
Whenever I run this code in unity it gives me this error:
Shader error in ‘1. Toon Step 1/Bump Map’: Program ‘SurfShaderInternalFunc’, incompatible type for parameter #1 (“s”) at line 71 & 73
Here’s the problem, there is no line 71 or 73.
The problem happens whenever I change put in MySurfaceOutput(which is the name of my struct) instead of SurfaceOutput in surf function
Is there a kind soul out there who can help solve this problem?