GLSL Arrays?

Ive been trying to implement hardware skinning in my project using GLSL, but i dont know how to pass arrays of matricies to the shader, the only way i can think of is to have an array of handles and each element of this array is the handle to the corresponding matrix of the array in the shader…is there a simpler way of doing this? or a more effective way?

thanks for any responce.


When you specify the value of a uniform, you can specify some number of elements. Declare an array of Matrix4 values, and specify all of the values at the same time. It’s pretty well described in the actual specification for the GL_ARB_shader_objects extension.

GetUniformLocationARB can only retrieve location IDs for uniforms
declared as a basic type (float, int, bool and vectors thereof) and
arrays of basic types. It is not possible to query the location ID of a
structure, for example. The application will have to break down the
structure into its fields until it has reached a basic type or an array
of basic type. It does this by using the "." (dot) and "[]" operations
in the name string passed to GetUniformLocationARB. It is possible to
query the location ID of an element K in an array. It is possible to use
that location ID to load multiple values into an array starting at that
location K. However, it is not possible to take that location ID and add
an integer N to that location ID to advance to element K + N in that
array. The application will have to query the location ID of array
element K + N separately.

ok, so i’ll stick to what im doing which is

‘GLint BoneID[k] = uniform mat4 BoneMat[k]’

thanks, saved me alot of time trying to find other ways.


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