I wrote a surface shader that’s an extension to the bumped diffuse shader (adds snow based on world normal). that worked, then I made a variant with specular, but that doesn’t compile. I get the error:
Shader error in ‘Custom/snowBumpedSpec’: Program ‘frag_surf’, input semantic attribute “TEXCOORD” has too big of a numeric index (8) at line 74 Keywords: DIRECTIONAL, LIGHTMAP_OFF, DIRLIGHTMAP_OFF, SHADOWS_SCREEN
So apparently I use to many texcoord, which doesn’t make much sense to me, as I don’t use more than in my (snow) bumped diffuse shader.
Also, I looked at the built in Reflective/Bumped Specular shader, and it’s just as complex; the same amount of textures, the same amount of parameters, and even 1 more uv-set (I use the float2 uv_MainTex for both the diffuse and normalmap)
So anyone that can help me ?
here’s the setup of the shader:
Shader "Custom/snowBumpedSpec"
{
Properties
{
_MainColor ("Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {}
_SpecColor ("Specular Color", Color) = (0.5,0.5,0.5,1)
_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
_BumpMap ("Bumpmap", 2D) = "bump" {}
_SnowTex ("Snow", 2D) = "white" {}
_SnowAmount ("Snow Amount", Range(0.0,5.0)) = 1.0
}
SubShader
{
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma exclude_renderers gles
#pragma surface surf BlinnPhong nolightmap nodirlightmap
#pragma target 3.0
struct Input
{
float2 uv_MainTex;//:TEXCOORD0;
//float2 uv_BumpMap;
float3 worldPos;
float3 worldNormal;
INTERNAL_DATA
};
float4 _MainColor;
sampler2D _MainTex;
float _Shininess;
sampler2D _BumpMap;
sampler2D _SnowTex;
float _SnowAmount;
void surf (Input IN, inout SurfaceOutput o)
{
float4 tex = tex2D (_MainTex, IN.uv_MainTex)*_MainColor;
float4 snow = tex2D (_SnowTex, IN.worldPos.xz);
o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_MainTex));
float snowfactor = 1 - WorldNormalVector(IN, normalize(o.Normal)).y;
snowfactor = snow.a - snowfactor;
if (_SnowAmount>1)
snowfactor *= _SnowAmount;
else
snowfactor += (_SnowAmount-1)*2;
snowfactor = saturate(snowfactor);
tex = snow*snowfactor + tex*(1-snowfactor);
o.Albedo = tex.rgb;
o.Specular = _Shininess;
o.Gloss = tex.a;
o.Alpha = tex.a;
}
ENDCG
}
Fallback "snowSpecular"
}