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.
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).