Jump to content
  • Advertisement
Sign in to follow this  
dpadam450

"unexpected operator for indirect index"

This topic is 3252 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ERROR: 0:33: Compiler error: unexpected operator for indirect index I get this when using the ATI Shader Analyzer. I'm currently using Nvidia hardware so I have to use this program to figure out what is wrong. Below is my entire shader code, but really it is complaining about this: varying float attenuation[5]; float newattenuation[5]; newattenuation = pow( attenuation, 2.0); It will only work if I take off the "[5]" and make it a single varying instead of 5. Any ideas?
varying vec3 normal[5];
varying vec3 lightvec[5];
varying vec3 viewvec[5];
varying float attenuation[5];
float newattenuation[5];
vec3 reflectvec[5];
float specValue[5];
vec3 newnormal[5];
vec3 newviewvec[5];
vec3 newlightvec[5];
vec4 summed_Diffuse;
vec3 summed_Specular;

int NUM_LIGHTS = 5;


uniform sampler2D tex1;
uniform sampler2DShadow Shadow_Tex;
void main(void)
{
	summed_Diffuse = vec4(0.0, 0.0, 0.0, 0.0);
	summed_Specular = vec3(0.0, 0.0, 0.0);

	float shadow = clamp( shadow2DProj(Shadow_Tex, gl_TexCoord[1] ).r + .5, 0.0, 1.0);

	//Lighting Contributions
	for(int i = 0; i < NUM_LIGHTS; i++)
	{
		newnormal = vec3( normalize(normal) );
		newviewvec = normalize(viewvec);
		newlightvec = normalize(lightvec);
		reflectvec = reflect(-newlightvec, newnormal);
		newattenuation = pow( attenuation, 2.0);
		
		specValue = clamp(dot(reflectvec, newviewvec),0.0, 1.0);
		specValue = pow(specValue, 2.0);

		summed_Diffuse += max(dot(newlightvec, newnormal), 0.0)*gl_LightSource.diffuse*min( (120.0/newattenuation), 2.0);
		//summed_Specular += (specValue*gl_LightSource.specular)*(120.0/attenuation);
	}

	//ambient
	summed_Diffuse += 0.5;
	vec4 texture_Diffuse = texture2D(tex1, gl_TexCoord[0].st)*vec4(summed_Diffuse.rgb, 1.0)*shadow;
	
	gl_FragData[0] = texture_Diffuse;
}

[Edited by - dpadam450 on October 27, 2009 1:39:37 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sorry, I don't know. Could be because you have too many varyings. Certain hw can do 8 vec4 and some can do more.
You are able to run that on your nvidia? That's incredible.
You might want to contact AMD about their error message or consult their documents.

Share this post


Link to post
Share on other sites
this sends warning bells

varying vec3 normal[5];
varying vec3 lightvec[5];
varying vec3 viewvec[5];
varying float attenuation[5];

== 5*3*3+5*1 = 50 varying floats + gl_TexCoord[1] == 4 varying floats = 54 varying floats

my card nvidia 9500
has a limit of 60 varying floats (older cards are like ~32) thus youre getting close to my cards limit + have exceeded the limit on some cards

u can check the ASM generated with nvidia shaders to see how many it uses

Share this post


Link to post
Share on other sites
It has been running on my Nvidia 8600 for ever. 9500 just tested and worked.

I believe it compiled on a 7600GS as well, because the person didn't say anything about it spitting up an error.

As for this error I am over-riding it with doing this;

newattenuation = attenuation;

and then doing:

newattenuation = pow(newattenuation, 2.0);

It really just will not let me index the varying float or something. I mean this is what the shader analyzer is saying, but I have not actually used an ATI card to figure it out and compile.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!