PDA

View Full Version : using Variables to index arrays in GLSL on an ATI



burito
02-13-2011, 10:17 PM
I want to index an array with a variable. From what I can find some people on SO think that back in the day when GLSL 1.3 was around, ATI cards didn't allow indexing arrays with anything but constants.



uniform sampler2D tex;

void main()
{
int foo = 0;
gl_FragColor = texture2D(tex, gl_TexCoord[foo].st);
}

This code, on my ATI 4870x2 produces an empty screen.



uniform sampler2D tex;

void main()
{
gl_FragColor = texture2D(tex, gl_TexCoord[0].st);
}

This code renders a textured model where I was expecting one to be rendered.

There was much talk that this kind of thing would fail on affected cards at the glCompileShader() call, and the log would yield a message that hinted at the problem.

The first fragment shader compiles & links with no problems on my box, but does not render anything.

Is this a known bug, and/or is there a page somewhere describing how to write GLSL without doing things that trip up the really lazy vendors?

Oh yes....
Version GL=3.3.10428 Compatibility Profile Context, GLSL=3.30
I believe this is the current version of the drivers from ATI, at least they didn't offer anything newer when I upgraded 30 minutes ago.