Jump to content
  • Advertisement
Sign in to follow this  
metsfan

Need guidance regarding GPU Skeletal Animation.

This topic is 2027 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

Hello all,

 

I am currently re-factoring my animation system to offload more work to the GPU.  What I would like to do is something that is not uncommon: I would like to do my skeletal animations on the GPU in the Vertex Shader.  I was able to find some code of others who have done this before me to get some guidance.  One thing I noticed about pretty much every code sample I found was that each shader used a 4D vector for the bone weights.  The implication here is that no vertex will be transformed by more than 4 bones.  However, after analyzing one of my models, I am seeing a bunch of vertices in the model that have anywhere from 5-7 bone weights.  I could add a 2nd 4D vector, or use a 4x4 matrix for the bone weights, to allow for more bone weights, at the expense of memory, however, I don't know what the right number of bone weights is.  

 

How have other solved this?  Is there any reason to use all the bone weights for a vertex, or is 4 enough for most vertices (in other words, ignoring anything beyond the first 4 bone weights)?  or does it make sense to just support more bone weights, and hope that it never goes above my limit?  Is there a way to export the model with a limit on bone weights per vertex?
 

I am happy to provide any additional information that is needed.  Thanks.

Share this post


Link to post
Share on other sites
Advertisement
In my model importer, I find the largest 4 weights, discard the rest, then renormalize these 4 so that they add up to 1.0.

In complex situations, it may be that 5+ are required, but it depends... In one game that I worked on, we use 'skinning LOD', where close characters would use 4 weights, medium distance would use 2 and distant characters just 1.
Pretty much every curren engine that I've used is limited to 4 bones per vertex, and next-gen games seem to be supporting 8 per vertex where required.

Share this post


Link to post
Share on other sites

In my model importer, I find the largest 4 weights, discard the rest, then renormalize these 4 so that they add up to 1.0.

In complex situations, it may be that 5+ are required, but it depends... In one game that I worked on, we use 'skinning LOD', where close characters would use 4 weights, medium distance would use 2 and distant characters just 1.
Pretty much every curren engine that I've used is limited to 4 bones per vertex, and next-gen games seem to be supporting 8 per vertex where required.

 

Perfect answer, thank you.

Share this post


Link to post
Share on other sites

Add all the bones until the maximum weights on a vertex is 1. It does not matter how many bones affects a vertices, as long all the weights adds up to 1. But usually 4 bones per vertex works really well and more than that is usually not required.

Share this post


Link to post
Share on other sites

This although doesn't say you can't have more than 4, 8, etc. For generic solution allowing for high quality animation, you can also use F.e. compute shaders (in my case OpenCL) to have any number of bones affecting vertices.

 

The question is, do you need high quality animation without considering performance (in that case you might consider using compute shaders and full solution for supporting "unlimited" number of bones)? Or do you need fast animation for games, where time spent on animation is limited (in that case you're just fine with solution described by Hodgman)?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!