Shader error: too many "TEXCOORD"

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"
  }

You also use world position world normal, and those need to be passed in the texture coordinate interpolators.

Things you can do:

  1. use shader model 3.0 (#pragma target 3.0), that has two more texture interpolators.
  2. disable stuff that you don’t need from the shader. Don’t need lightmaps? Add “nolightmap” to #pragma surface line. Don’t need directional lightmaps? Add “nodirlightmap” and so on.
  3. do you actually use world position? If not, do not put it into the Input struct.
  1. I already use #pragma target 3.0
  2. I added nolightmap and nodirlightmap, but that doesn’t seem to make any difference, still “too big of a numeric index (8)”, are there other things I can disable that might help ?
  3. I do use the world position, I use it for the uv’s for the snow. But I don’t really use the worldNormal directly, I mean I use the normal map to set the normal, then I use WorldNormalVector() to get the worldnormal, I didn’t seem to work any other way, is that the correct way of dooing this ?

thanks for the reply Aras

Well, I guess then we have to see your full shader to tell any more details.

alright, I’ve editted my first post and added the full shader there.

Sorry, didn’t have time to look into this earlier, vacations stuff…

Turns out the culprit is OpenGL here; by default we compile into OpenGL ARB vertex/fragment programs, even in SM3.0 mode (long story of driver bugs with GLSL etc.). If you tell Unity to compile into GLSL when targetting OpenGL, the shader works.

Just add “#pragma glsl” line somewhere in your CGPROGRAM block.