Vertex attribute output count exceeds hardware

Vertex attribute output count exceeds hardware limits.

I have got my number of bones down to 32, but that still seems to be too many for one user’s GE Force 8800 GTS.

Here is the shader:

attribute vec3 Tangent;
attribute vec3 Bitangent;
attribute vec4 BoneIndice;

uniform mat4 BoneMatrices[32];
varying vec3 T,B,N;

varying vec3 ModelVertex;
varying vec3 EyeVec;
varying vec3 BumpVector;
float BumpAvg;

#ifdef LW_LIGHTS

void light(in int i, in vec3 normal, in vec3 ecPosition3)
{
	float nDotVP;       // normal . light direction
	float attenuation;  // computed attenuation factor
	float d;            // distance from surface to light source
	vec3  VP;           // direction from surface to light position
	float spotDot;

	// Compute vector from surface to light position
	VP = vec3 (gl_LightSource[i].position) - ecPosition3;
	
	// Compute distance between surface and light position
	d = length(VP);
	attenuation = clamp( 1.0-(d/gl_LightSource[i].linearAttenuation), 0.0, 1.0 );
	
	// Normalize the vector from surface to light position
	VP = normalize(VP);
	
	#ifdef LW_BUMPMAP
		nDotVP =1.0;
	#else
		nDotVP = max(0.0, dot(normal, VP));
	#endif
	
	// Spot attenuation
	spotDot = dot( -VP, gl_LightSource[i].spotDirection);
        if (spotDot < gl_LightSource[i].spotCosCutoff)
        {
	    attenuation = 0.0;
        }

	float spotAttenuation = min( 1.0 - (spotDot - gl_LightSource[i].spotExponent) / (gl_LightSource[i].spotCosCutoff - gl_LightSource[i].spotExponent) ,1.0);
	if (gl_LightSource[i].spotCutoff==180.0)
	{
		spotAttenuation=1.0;
	}
	attenuation *= spotAttenuation;

	// Point & spot lights
	gl_FrontColor += 2.0 * gl_LightSource[i].diffuse * nDotVP * attenuation * gl_LightSource[i].position.w;
	
	#ifdef LW_BUMPMAP
		float bumpcontributor;
		bumpcontributor = attenuation * gl_LightSource[i].diffuse.w;
		BumpVector += (VP * gl_LightSource[i].position.w * bumpcontributor);
	#endif
	
	// Directional lights
	gl_FrontColor += 2.0 * gl_LightSource[i].diffuse * max(0.0, dot( normal, vec3( gl_LightSource[i].position ) )) * (1.0-gl_LightSource[i].position.w);
	
	#ifdef LW_BUMPMAP
		BumpVector += (vec3( gl_LightSource[i].position ) * (1.0 - gl_LightSource[i].position.w));
		BumpAvg += (1.0 - gl_LightSource[i].position.w);
	#endif
}

#endif


void main(void)
	{
	mat4 mat = BoneMatrices[ BoneIndice.x ];
	gl_Position = gl_ModelViewProjectionMatrix * ( mat * gl_Vertex);	
	
	#ifdef LW_BUMPMAP
		BumpVector = vec3(0.0,0.0,0.0);
		BumpAvg = 0.0;
	#endif
	
	#ifdef LW_BUMPMAP
		T = normalize(gl_NormalMatrix * gl_MultiTexCoord3.xyz);		
		B = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz);
	#endif

	N = gl_NormalMatrix * (mat3(mat[0].xyz,mat[1].xyz,mat[2].xyz) * gl_Normal); 

	gl_TexCoord[0]=gl_MultiTexCoord0;

	vec3 ecPosition3;
	vec4 ecPosition;
	vec3 lnormal;

	lnormal = normalize(N);
	ecPosition = gl_ModelViewMatrix * gl_Vertex;
	ecPosition3 = (ecPosition.xyz) / ecPosition.w;
	
	gl_FrontColor = gl_Color;

	#ifdef LW_LIGHTS
		gl_FrontColor = vec4(0.0,0.0,0.0,1.0);
		light(0,lnormal,ecPosition3);
	#endif
	
	#ifdef LW_BUMPMAP
		BumpVector = normalize(BumpVector);//( BumpVector / BumpAvg );
	#endif

	}

Hallo Leadwerks,

we do have a similar problem, which occured after updating to nVidia’s latest driver (linux: 169.09)

could you please tell me which driver you are using?
have you tried to print out GL_MAX_VERTEX_ATTRIBS:


    GLint tmp = 0;
    glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &tmp);
    cout << "GL_MAX_VERTEX_ATTRIBS " << tmp << endl;

For my Geforce 8800 GTX it say’s “16”, which is the minimum anyway, but I am not sure how build-in attributes (like gl_Color, gl_Normal… ) are handled.

Actually I would suggest, that the input attributes are not the problem at all - as the error message reads - there is an “attribute output count” exceeded.

And your uniform mat4 shouldn’t be a problem either, because it is not an attribute…

It looks like you’re using maybe 10 attributes. 3-4 texture coordinates, gl_Vertex, gl_Normal, gl_Color, and your 3 generic attributes. So it shouldn’t be a problem.

Also, as Chrisidefix rightly pointed out, your matrices are uniforms, not attributes. Are you sure it’s giving you an error for too many attributes, rather than uniforms?

If it is a uniform problem, I can’t quite understand how that could be the case, since the GeForce8xxx class hardware is perfectly capable of handling thousands of uniforms.

I did some further testing to localize the problem today. The error occurs during linking the shaders and tells us, that we are using too many attribute (!) outputs as Leadwerks wrote.

If possible you should try to reduce the number of varying variables between the vertex and fragment shaders. (I had to use less built-in functions as well, but I am not sure what this had to do with the error)
At least it helped me getting around this problem for now. I asked nVidia for help and waiting for an answer, because everything worked fine with an older driver version.

Chris

I solved this problem by lowering the number of varyings I was using. I replaced the built-in texcoord varyings (which are vec4’s) with my own vec2’s.

I am using driver “Version: 169.21 WHQL”.

I solved this problem by lowering the number of varyings I was using.

Why was the error talking about attributes then?

Why was the error talking about attributes then?

The good Lord works in mysterious ways. :\

Why was the error talking about attributes then?

It could be a bug in the driver…
Or they started to count attributes and varyings together - effectively limiting the amount of variables that can be interpolated
but for now using fewer varyings seems to be the solution…

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.