OSX 10.6.8, MacBook Pro, ATI X1600
I have a problem with a shader.
This (test) code works:
Code :Vertex: void main(void) { gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = ftransform(); } Fragment: uniform sampler2DRect tex0; uniform int alpha; uniform int red; uniform float polyx[20]; uniform float polyy[20]; void main (void) { vec4 color0 = texture2DRect(tex0,gl_TexCoord[0].st); vec2 q = gl_TexCoord[0].st; float px1, py1; float d = 0.0; int alpha2 = 1; for ( int j = 0; j < 20; j++ ) { px1 = polyx[j]; py1 = polyy[j]; d = px1 + py1; } color0.g += 0.3 + d*0.001; gl_FragColor = clamp(color0, 0.0, 1.0); }
This shader code does not render anything:
Code :Vertex: void main(void) { gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = ftransform(); } Fragment: uniform sampler2DRect tex0; uniform int alpha; uniform int red; uniform float polyx[20]; uniform float polyy[20]; void main (void) { vec4 color0 = texture2DRect(tex0,gl_TexCoord[0].st); vec2 q = gl_TexCoord[0].st; float px1, py1; float d = 0.0; int alpha2 = 1; for ( int j = 0; j < 20; j++ ) { px1 = polyx[j]; py1 = polyy[j]; d = px1 + py1; if ( d == 0.0 ) d += 0.01; } color0.g += 0.3 + d*0.001; gl_FragColor = clamp(color0, 0.0, 1.0); }
The only difference is this totally legal line:
Code :if ( d == 0.0 ) d += 0.01;
When I move this line one line down, so that it is outside the for-loop, then the shader works.
Both shaders compile without a problem. But when the second code runs all I get is that the original texture (tex0) is passed through without any changes.
Interestingly both codes work in the OpenGL Shader Builder application.
I am sure that I pass all variables correctly. I also get good values for all variables when I pull the UniformLocation (greater than -1).
Note: The ATIX1600 graphics card does not seem to be able to handle shaders with arrays that are addressed with a variable index (here: j) on a hardware basis. The OpenGL Shader Builder shows me that it switches to "Apple Software Renderer").
Is this a bug in Apple's Software Renderer? Or am I missing something?



