Results 1 to 2 of 2

Thread: Passing arrays to VS

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    13

    Passing arrays to VS

    Hey all,

    I need to pass an array of uniform mat4 to the VS in order for skin-and-bone animation. In other animation demos I've seen, they just make as many single uniform mat4 as they need. Is there not a way to pass an array of mat4?

    Such as
    uniform mat4 Bones[10];

    The webgl spec says

    void uniformMatrix4fv(WebGLUniformLocation location, GLboolean transpose,
    Float32Array value);

    void uniformMatrix4fv(WebGLUniformLocation location, GLboolean transpose,
    float[] value);

    I can't seem to get it to work without DOM errors.

  2. #2
    Junior Member
    Join Date
    Jul 2011
    Posts
    17

    Re: Passing arrays to VS

    Yes, you can pass a matrix array to a shader program they way you describe.

    GLSL requires (I'm not a WebGL-developer, but OpenGL should be the same in this case) that the length of the array can be determined during compiling or linkage. Which means that you can define it as: const int length = 10; uniform mat4 Bones[length]; You cannot however have the length defined as a uniform and try to load it later on..

    On to your problem: The array provided in GL is a single array of some type (in this case float), i'm guessing you're trying to provide a multidimensional array perhaps? The array has to be in column major order if transpose is not set to true.

    //Johan

Similar Threads

  1. passing constant value to kernel
    By duanmu in forum OpenCL
    Replies: 4
    Last Post: 10-26-2009, 03:34 PM
  2. Passing arrays of complex structures
    By onegin in forum OpenCL
    Replies: 4
    Last Post: 07-21-2009, 11:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •