Jump to content
  • Advertisement
Sign in to follow this  
keym

+4 bones vertex skinning

This topic is 2015 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I tried to implement vertex skinning using Cg and OGL. I searched the web and most tutorials do it with 4 bones at max, claiming that "you don't need more than 4 bones anyway". I beg to differ. For instance I used "cyberdemon" from Doom3 for testing and it uses up to 7 bones per vertex. And this game is 2004... I know it has nothing to do with that (just tell artist what he can and can't do and problem is solved, right?). But in this topic http://www.gamedev.net/topic/628092-gpu-skinning-4-bones/ MJP said that I can pass as many bone weights per vertex as I want. Currently I'm packing them into TEXCOORD0-7 and I'm hardly getting away with 6 bones - I even sacrificed TBNs and I want to use them too. So the question is what's this trickery that allows me passing more bones without stress?

1. If anyone's curious - I just wanted to implement up to 8 bones just to be safe, also it may come in handy when we start with facial animation.

2. Yes, I know that I can discard least significant weights and then renormalize, but that's "lazy solution", I want to do it right and MJP's post lead me to that direction. Also see above.

3. I'm fairly new to VBOs so I might be missing something about packing vertex attributes.

Share this post


Link to post
Share on other sites
Advertisement

Currently I'm packing them into TEXCOORD0-7 and I'm hardly getting away with 6 bones

 

I'm guessing your problem is that you're using float2 because that's traditional for texture coordinate UVs?

 

In fact, there's nothing stopping you using a float4 for each TEXCOORD. That would mean that just 4 TEXCOORDs will give you 16 scalar values, which is enough for 8 weights + 8 bone indices.

Share this post


Link to post
Share on other sites
I use float4 and int4 but I also pass 3d vector - weight position - that is part of MD5 format (maybe there is a workaround for this?). That's why it's so crowdy in there... Bones itself are 3d vectors (pos) + 4d vectors (orient).

So just to clarify - there's no way to pass more attributes other than pack them through ATTR0-ATTR15? I'm asking cause MJP's post:

"You should be able to pack as many bones + weights as you want in your vertex."


gave me the impression that I can pass more data and I just don't know the trick. Edited by keym

Share this post


Link to post
Share on other sites

Let me see if I'm understanding right: you're storing the bones directly in each vertex? Using uniforms would make more sense (then you only need to pass the bone ID and the weight to each vertex).

Edited by Sik_the_hedgehog

Share this post


Link to post
Share on other sites
I have seen that sort of an approach before (in a CPU skinning context) and I'm not aware of any benefits of it over and above the more common bind pose approach. I think that Max or Maya (or maybe both) tend to make it easier to get the weighting data that way, so perhaps that why it made it's way into the file format, but I'm pretty sure that when it comes to runtime skinning, you're best off processing the skin data to get a single bind pose position per vertex.

Do you know if Doom3 actually used the "weight position" that way in its shaders? I would be a little surprised if it did, but if it did, then I presume there was some good reason that I'm not seeing.

I think if you're keen on supporting >4 vertices, then you probably ought to do bind pose skinning. In fact probably you ought to do bind pose skinning regardless, unless there's some big benefit to doing it the "weight position" way. Edited by C0lumbo

Share this post


Link to post
Share on other sites
I'm confused. Is was under the impression that in fact this is the "bind pose approach" - these weight positions are provided only in bind pose (scratch that, they are pose independant, they only inform about mesh "volume", combined with bones, bind pose or not, they give the final result) and I also have bind pose skeleton provided. So how do I get rid of these weight positions? What's the usual approach here? Right now I have bind pose skeleton but in fact I don't use it while animating. It's only helpful when "unpacking" animation (skeleton) frames but it looks like there's a reason it's there. I have no idea if Doom3 uses these weight positions in shaders. I just followed mentioned tutorial and ended up here. Edited by keym

Share this post


Link to post
Share on other sites

I'm confused. Is was under the impression that in fact this is the "bind pose approach" - these weight positions are provided only in bind pose (scratch that, they are pose independant, they only inform about mesh "volume", combined with bones, bind pose or not, they give the final result) and I also have bind pose skeleton provided. So how do I get rid of these weight positions? What's the usual approach here? Right now I have bind pose skeleton but in fact I don't use it while animating. It's only helpful when "unpacking" animation (skeleton) frames but it looks like there's a reason it's there. I have no idea if Doom3 uses these weight positions in shaders. I just followed mentioned tutorial and ended up here.

 

I animate MD5 meshes in a way C0lumbo implied. Post multiply your animation pose matrices with the inverse bind pose. Then you can just send the bind posed vertices to the GPU.

 

I'm not sure how animating is done in Doom 3, but maybe it is possible that they did not use GPU skinning, because they needed the transformed vertices for constructing shadow volumes. Then it should be faster to have the vertices in weight space so that post multiplication by inverse bind pose is avoided.

Share this post


Link to post
Share on other sites

I'm confused. Is was under the impression that in fact this is the "bind pose approach" - these weight positions are provided only in bind pose (scratch that, they are pose independant, they only inform about mesh "volume", combined with bones, bind pose or not, they give the final result) and I also have bind pose skeleton provided. So how do I get rid of these weight positions? What's the usual approach here? Right now I have bind pose skeleton but in fact I don't use it while animating. It's only helpful when "unpacking" animation (skeleton) frames but it looks like there's a reason it's there. I have no idea if Doom3 uses these weight positions in shaders. I just followed mentioned tutorial and ended up here.

 

I animate MD5 meshes in a way C0lumbo implied. Post multiply your animation pose matrices with the inverse bind pose. Then you can just send the bind posed vertices to the GPU.

 

I'm not sure how animating is done in Doom 3, but maybe it is possible that they did not use GPU skinning, because they needed the transformed vertices for constructing shadow volumes. Then it should be faster to have the vertices in weight space so that post multiplication by inverse bind pose is avoided.

 

Yes, this is how it worked. The PC version did all skinning on the CPU. The resulting meshes were used for collision, shadow volume extrusion, and decal splatting. For the Xbox version, we couldn't afford to do CPU skinning -- so we transformed everything into bind pose to do GPU skinning.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!