I've discovered a problem passing an array from a vertex shader to a pixel 
shader. Somewhere the array ends up overlapping with other constants, for 
example if I have an array of UV coordinates and a colour being passed 
though, then changing the UV coordinates will affect the colour. Using 
either the colour or UV alone works, I assume because the compiler optimises 
out the unused variables and prevents the overwrite occurring. This happens 
even with an array size of 1.

To give a simple example, this pixel shader will render incorrectly:

varying highp vec4 vl_TexCoord[1];
varying highp vec4 vl_Color;
uniform highp sampler2D _diffuseMap;
void main() {
   gl_FragColor = vl_Colo r* texture2D(_diffuseMap,  vl_TexCoord[0].xy);
}

However changing main to either of these cases work, giving either a 
correctly mapped texture, or correct vertex colour:

void main() {
   gl_FragColor = vl_Color;
}

void main() {
   gl_FragColor = texture2D(_diffuseMap,  vl_TexCoord[0].xy);
}

Changing the vl_TexCoord array to a simple vec4 makes the problem go away, 
so I have a workaround, but this seems like a fairly serious problem, 
possibly in the shader compiler.

The same issue was raised on gamedev so I think it's a genuine bug:
http://www.gamedev.net/topic/594352-gl-20-shader-varying-array-problem/

Has anyone else experienced this problem? I'm using a HTC Desire HD for 
testing, using the 2.2 Android SDK. I don't know if it's hardware or SDK 
version specific at the moment.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to