- Home /
Shader error: too many "TEXCOORD"
I wrote a surface shader that's an extension to the bumped diffuse shader (ads 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 (1 use the float2 uv_MainTex for both the diffuse and normalmap)
So anyone that can help me ?
Edit: the shader:
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 surface surf BlinnPhong
#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"
Edit2: the compiled 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" }
// surface shader with errors was here
Pass { }
/*/* surface debug info:
needs world normal vector
needs world space position
stuff performed in tangent space
passes tangent-to-world matrix to pixel shader
*/
/* surface debug info:
needs world normal vector
needs world space position
stuff performed in tangent space
passes tangent-to-world matrix to pixel shader
*/
/* surface debug info:
stuff performed in tangent space
*/
/* surface debug info:
needs world normal vector
needs world space position
stuff performed in tangent space
passes tangent-to-world matrix to pixel shader
*/
*/
#LINE 65
}
Fallback "snowSpecular"
}
The important thing is what sematics have you assigned to your vertex data. TEXCOORD0, TEXCOORD1, TEXCOORD2, ...? It seems you try to use a uv-channel greater than 7. Can you post the shader? or at least the parameters / vertex data definition.
Feel free to edit your question.
nothing, it's a surface shader, you don't need to assign semantics as it doesn't have any effect (at least that's my understanding of it), I tried giving them all a TEXCOORD semantic, but that fixes nothing.
Answer by ScroodgeM · Jul 14, 2012 at 02:04 PM
enable #pragma debug in shader, this will add comments to compiled shader.
open compiled shader and you'll see all semantics that really used in shader - there will be shadows textures and so on
disable unused checks and calculations and shader - this can free some texture coordinates you need
if nothing helps, try to use one mapping (tiling/offset) for many textures, for example, use uv_MainTex in tex2D methods for _MainTex and _BumpMap - this will free 1 texcoord
thanks for the answer. 1+2. I added the #pragma debug, but it doesn't really help me much, because the shader doesn't compile, I get "// surface shader with errors was here" followed by some info about passes, which doesn't tell me much appart form the fact that it seems to do 4 passes, of which 3 seem to be the same (see my editted post above). 3. I added "nolightmap nodirlightmap"but that doesn't seem to make a difference, I don't what else I can do. 4. I already do that
so I'm still at loss here :s
float4 snow = tex2D (_SnowTex, IN.worldPos.xz);
this row makes error. so first you can avoid this method to get pixel based not on geometry and then your shader will compile. after that repeat 1+2
huh, you're right, I guess some extra texturecoordinates are needed for that for some reason. The compiled shader looks like chinese to me though, but I'll try to make sense of it. thanks for the help
Your answer
Follow this Question
Related Questions
Adding Spheremap reflection and Gloss/Shininess controls to a Sruface Shader 0 Answers
Surface Shader Specular 0 Answers
Specular vs. Emission in Surface Shader? 2 Answers
How can I use a "Specular" property with surface shaders using the Standard lighting model? 0 Answers
Simple Blinn Phong Surface Shader 1 Answer