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.

Does nobody know? :frowning:

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.

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

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

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