atm i’m computing animation in software, but i’d like to do it in a vertex shader. a model has an array of joint matrices and every vertex has an id which refers to a position in that array.

i want to upload the matrices as an array of uniform mat4 to the vertex shader and pass the joint id as a vertex attribute:

attribute int a_JointId;
uniform mat4 u_JointMatrices[32];

The (transposed) 3x4 matrices are packed into 2 vec4 vectors. The decompression cost the instructions that are saved at mixing. The bone depencys are packet too. The fractional part is the weight and intger part is used as index. (the weight shouldn’t be bigger than 0.999)

great, thanks!
this is what i have so far. the code to transform the vertices is simply copy pasted from my software solution. some vertices are transformed correctly, the others are not the model has less than 32 joints.

i import my animatins from ms3d, which does not support weights. so there is only one joint matrix influencing each vertex. exactly the same function is working nicely in software, so i do not understand why it does not in a vertex shader. what confuses me the most is that some vertices are transformed correctly, while some are not…

It’s possible that you’re getting a matrix transposed - I notice that your code assumes post-multiplied matrices (v * M) while OpenGL conventionally uses pre-multiplied matrices (M x v).

If you want to get good performance out of the shader (once you’ve made it work), you should let GLSL handle the matrix-vector multiplication instead of breaking it up into scalars; that will allow it to use vector instructions.

everything is working fine now one question remains, though: i have to reupload all matrices everytime i switch shaders. that sounds like a lot of overhead. is there a way to permanantly store the matrices on the gpu instead? the bindable uniform extension sounds interesting, but i guess it’s gf8+ only, right? or could i use the new render to texture feature instead?