Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to implement a GPU skinning version of the md5mesh.js by @tojiro (demo with CPU skinning) in WebGL (live demo of the project here, use WASD to move the camera around).

The main concept is as follows: I modified the Vertex buffer object in order to fit the information of bones indices and bone weights, then for every frame of the animation I modify the bone matrix (an array of transformation matrices for each bone) with the appropiate matrix (for each joint I create an identity matrix and multiply it by it's orientation and position, then I multiply the result by the inverse of the bind pose and it's ready to go to the shader).

This works OK when the boneMatrix array is filled with identity matrices (by concept it should render the bindPose and it does). However when I try to load an animation the movements appear messed up and clipped. I discarded a wrong/corrupt version of the md5mesh / md5anim by loading them in an MD5 viewer.

Here there is an example of what happens when the boneMat array is filled with identity matrices:

Looks good to me

I think this is the way the model should look, but when I try to animate it...

mesh is messed

The general movement of the mesh is correct but some vertices move with an strange direction / orientation which forces a lot of clipping to occur.

Maybe someone experienced in the matter can spot the problem directly from the image, if not I' willing to provide any part of my modifications on the md5Mesh lib.

In order to implement all of this I've followed this tutorial and took a lot of ideas from this implementation.

Any help will be appreciated, I've really hit a wall with this!

Thanks in advance.

share|improve this question

1 Answer 1

I know it's a boring suggestion :) but I suggest to go back to the basics. When I was writing my skinning code I started with 1 bone and 1 vertex, then 1 bone affecting 2 vertices, then 2 bones affecting 2 vertices (100% weights), then 2 bones affecting 2 vertices (50/50% weights) and so on.

You can easily manage this amount of data manually so write a set of tests to verify the vertices end up where you want them to. You will want your code to be as similar to a shader code as you can, using the same input/temporaty data structs you would with a shader etc. and essentially simulating your vertex shader on the CPU. By the time you have 3 bones and 5 vertices running fine your code is almost guaranteed to be OK, then it's time to move your code to a shader. If you made sure your code takes the same data format as input as the shader does it should be a straightforward port so any bugs will be easy to spot.

Oh, and:

  • remember to test straight bone chains and branches (two bones having the same parent) separately
  • not sure about md5 but in other formats you may get not normalised weights so test some crazy weights and make sure it works fine
  • again, not sure about md5 but you may need to handle multiple root bones
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.