Results 1 to 6 of 6

Thread: Passing a mat3 attribute to a Vertex Shader

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    12

    Passing a mat3 attribute to a Vertex Shader

    Hello.

    I'd like to pass a mat3 attribute to a Vertex Shader.
    I know how to pass vectors but despite I tried almost everythng I don't manage to pass a ma3.
    I know I could just pass 3 vec3 and combine them into a mat3 inside the shader but I'd rather use something more straightforward.

    Maybe that's just not possible but I think I saw it once.

    I need to know, anyway.

  2. #2
    Junior Member
    Join Date
    Mar 2012
    Posts
    12

    Re: Passing a mat3 attribute to a Vertex Shader

    Does nobody know?

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    12

    Re: Passing a mat3 attribute to a Vertex Shader

    I guess "attribute mat3" is just a mecanism that cannot be used yet.

    Thus, it should just not compile when present in the shaders' code.

  4. #4
    Junior Member
    Join Date
    Sep 2011
    Posts
    11

    Re: Passing a mat3 attribute to a Vertex Shader

    You need to pass typed (Float32Array) 1-dimension (in this case 9-elements) array.
    See example of passing 4x4 mat: http://learningwebgl.com/blog/?p=28 search for "mvMatrix"

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

    Re: Passing a mat3 attribute to a Vertex Shader

    Quote Originally Posted by gliniak
    You need to pass typed (Float32Array) 1-dimension (in this case 9-elements) array.
    See example of passing 4x4 mat: http://learningwebgl.com/blog/?p=28 search for "mvMatrix"
    No that is not the way, he's talking about an attribute, not a uniform.

    Yes, it is possible to use mat4 and mat3 as attributes. But remember though that the number of attributes that can be used is limited, are you sure you want to send down a whole matrix for every vertex?

    What you do, is you define your

    Code :
    attribute mat3 myAttrib;

    Then, when querying for the attribute location x, you will get the location for a vec3, the subsequent location x+1 will also be a vec3, and the x+2 the last column (note column oriented matrices in OpenGL).

    It is mentioned in the GLSL for ES specification: http://www.khronos.org/registry/gles/sp ... 1.0.17.pdf at '4.3.3 Attribute'.

    And the mechanism i explained is also explained in the OpenGL ES 2.0 specification:
    http://www.khronos.org/registry/gles/sp ... 2.0.25.pdf at '2.10. VERTEX SHADERS', page 33

  6. #6
    Junior Member
    Join Date
    Mar 2012
    Posts
    12

    Re: Passing a mat3 attribute to a Vertex Shader

    Thanks but this won't work with webGL since you don't work with numeric pointers in it (so "location x+1" is invalid).

Similar Threads

  1. attribute mat3 should prevent shader from compiling
    By Sergejack in forum WebGL - General
    Replies: 0
    Last Post: 03-14-2012, 03:31 AM
  2. Difference between uniform and constant vertex attribute?
    By andyskinner in forum OpenGL ES 2X - for programmable 3D graphics pipelines
    Replies: 3
    Last Post: 10-17-2011, 04:28 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
  •