I apologize preemptively for the title.
So I picked up a Samsung Galaxy Tab today, for testing...yeah, that's it, "testing"...
I installed the USB driver for Windows, restarted my computer, and was able to start debugging Leadwerks3D on it with no trouble at all. However, the rendering showed black objects that ought not be black.
At this point in the game, having such a basic issue is very scary to me. I tracked the problem down to the lighting uniforms being passed to the shader, but something didn't make sense.
In GL Shading Languages (GLSL), you can have arrays of uniforms, like this:
vec3 mediump lightdirection[4];
A uniform array like this should be accessible from the main program by setting individual elements in the array, or by setting the entire array at once with a pointer to eight floats. See for yourself:
http://www.khronos.o...spec_2.0.25.pdf
Page 35:
The first element of a uniform array is identified using the name of the uniform array appended with "[0]". Except if the last part of the string name indicates a uniform array, then the location of the first element of that array can be retrieved by either using the name of the uniform array, or the name of the uniform array appended with "[0]".
It did not appear that the light color and direction was being sent correctly, and more detailed debugging confirmed this.
After a few hours of testing, I finally determined that uniform array names on iOS have end with '[0]' (I didn't test any other element indexes, at least on the iOS simulator. My provisioning profile just expired, and that's a whole other story...), and just setting the uniform array at once with the name will not work. On the Samsung Galaxy Tab, the situation is reversed. My HTC Evo is the only device that follows the OpenGLES specification and allows either.
Samsung Galaxy Tab: "lightdirection"
iOS: "lightdirection[0]"
Evo: "lightdirection" or "lightdirection[0]" (as it should)
The solution? I'll just avoid using uniform arrays on any mobile devices. It's not hard to avoid now that I know what to look for, but it's hell figuring out which parts of the GL spec the driver authors ignored.
Fortunately, you don't have to worry about any of that, so you can just make your games and be happy.
5 Comments
Recommended Comments