- ...
- uniform mat4 u_FinalMatrices[MAX];
- void main()
- {
- vec4 Vertex = gl_Vertex;
- int Id = int( a_JointId );
- // compress input matrix
- vec4 temp1;
- temp1.x = u_FinalMatrices[Id][0][0];
- temp1.y = u_FinalMatrices[Id][0][1];
- temp1.z = u_FinalMatrices[Id][0][2];
- temp1.w = u_FinalMatrices[Id][1][1];
- vec4 temp2;
- temp2.x = u_FinalMatrices[Id][3][0];
- temp2.y = u_FinalMatrices[Id][3][1];
- temp2.z = u_FinalMatrices[Id][3][2];
- temp2.w = u_FinalMatrices[Id][1][2];
- // decompress matrix again
- mat3 mat;
- mat[0] = temp1.xyz;
- mat[1] = vec3( -temp1.y, temp1.w, temp2.w );
- mat[2] = cross( mat[0].xyz, mat[1].xyz );
- //Vertex = u_FinalMatrices[Id]*Vertex; <- using the uncompressed matrix works fine
- Vertex = vec4( mat*Vertex.xyz+temp2.xyz, 1.0 ); // <- using the decompressed matrix doesn't
- ...