Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC wrote:
Yes, on the shader side, the float array is declared as

uniform float altitudes[10];

The array size itself is just passed in as another uniform int.

Thanks for bringing that up. I had forgotten to include the shader side of
things...:)

I've used uniform arrays to pass an array of matrices to do hardware vertex skinning. Instead of the setArray() method, I just used setElement(index, matrix) for each matrix (you still need to call setNumElements() to set the size of the array on the CPU side).

In the shader, they're accessed like this:

uniform mat4 matrixList[36];

Here's the code that accesses them (weight and boneIndex are two extra vertex attributes):

   // Accumulate the vertex's influences by weighted sum into a
   // final matrix
   for (int i = 0; i < 4; i++)
   {
      // Get this bone index
      bone = int(boneIndex[i]);

      // Get the bone's weighted matrix and add it to the final
      // matrix
      boneMatrix = matrixList[bone];
      finalMatrix += boneMatrix * weight[i];
   }


--"J"


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to