I'm lost with skeletal animation. I've read some things about this, but their is still one thing I don't understand. This is conclusions I have. I saw 3 ways to animate a mesh with bones :
I have a Mesh class that contains vertices, vertex buffer, index buffer and texture Shader, and transform matrix. I could use class for each bone, add weight and it could me easy to animate the model. But that means use too much memory because some things stored are used some time when they have to be only once.
Use vertex shader. Add weight and bone index in the input vertex parameter, and use a matrix array as a global variable, so in the shader I just have to use the matrix of the bone. This solution seems more efficient for me, but I remember that on the directx 11 tutorial ( from Rastertek ) he said that HLSL should be fast because its used a lot of time, and I think this would be too heavy. Anyway this is the solution I'll try, at least to know if that works or not.
Use matrix and inverse matrix for each bones. As far as a read, this is the way to take. But this is the way I didn't understand. Why are matrix inverse used here, and how matrices are "linked" to vertices. I mean if I move the matrix for the right hand bone, what said in the code that only right hand vertices will be used?
So my questions are :
- Is the second way viable? or it will be too much for the GPU with some mesh and animations?
- Can someone explain the way matrices are linked to vertices and why are matrix inverse used? Or link me something about this.
I hope you did understand me, because I'm not sure i explained well. And please excuse my english, I did as good as I could. Thanks in advance.