Uniform array names

My understanding of GLSL uniform arrays is that they should be identifiable by both the name along, and the name along with the array index in brackets. For example, if I had this uniform array in my shader:
Code:
uniform float lightrange[4];

Then according to the spec, my program should be able to set the array, or parts of the array, with any of the following uniform names:
Code:
lightrange
lightrange[0]
lightrange[1]
lightrange[2]
lightrange[3]


I ask because it appears iOS would only recognize “lighttange[0]” while Samsung’s stuff only recognizes “lightrange”.

IIRC only ‘lightrange[i]’ can be used, ‘lightrange’ is not allowed by the spec, but it would be anyways equivalent with ‘lightrange[0]’.

Thus it seems that iOS got the behavior correctly.

IIRC only ‘lightrange[i]’ can be used, ‘lightrange’ is not allowed by the spec, but it would be anyways equivalent with ‘lightrange[0]’.

Wrong. lightrange[0] is the proper name for the array (as well as the first element). But glGetUniformLocation is able to use lightrange as well to refer to the name. This is true for all versions of OpenGL and OpenGL ES:

These all define how glGetUniformLocation works (or the Program Interface equivalent, glGetProgramResourceLocation).

So both Apple and Google are wrong; just in different ways.

Thanks for the clarification, Alfonse. I know you’ll always be there correcting me if I’m saying something wrong, that’s why I feel free to talk stuff off the top of my head :slight_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.