Sign in to follow this  

Best way to render a skeletal animation?

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

I was recently picked up and am reading "Advanced Animation with DirectX" by Jim Adams. Well to my astonishment it said to create a new model with the transformed vertices to render, then render that. That would be a HUGE hit on not only switching models to render but pushing all that to memory every frame. With my current rendering system I have the everything with the same model render without switching vertex/index buffers. I can apply transformations at render time. So my question is, what is the best way to do this? I cant really push a new transformation matrix every vert, but I dont want to push a whole new model everytime I hafta render that model, and store twice the information. So my question is, what is the best way to render a skeletal animation model? Any input would be great, or to some documents that explain the differences would be a huge help. Thanks, Brad

Share this post


Link to post
Share on other sites
Depending on the situation, pre-transforming the vertices can in fact be a good idea. It requires zero additional code in the vertex shader, the pretransformed vertices can be cached, the whole thing is quite nice for shadow volumes etc. Considering the fact that today's bus speeds are quite high, I doubt this could be a bottleneck, except if you have many skinned models or many instances (btw, instancing and skinning do not work well together sometimes).

As for the bones, I'd use quaternions, and not matrices, this reduces the data amount from 16 to 4 floats per bone.

Share this post


Link to post
Share on other sites
Don't you have to keep more than one instace of the geometry anyway. You have to have a copy of the verts in the bind pose, and then transform from the bind pose to the new bone position. Mayhaps it's possible to interpolate the difference in transformation from one bone pos to another bone pos, but I've never seen that. Further, it seems like a good idea to have a system for cacheing the bindpose anyway, and sharing it among multiple instances of the same model (general instance, not hardware instancing or whatever). For example, if you have three monkey monsters (because everyone loves monkies), and they were not animated, you wouldn't want to load the data three times. Ok, so I guess it would have made for a better example if I picked something non animated, like a tree, but you get the point. If it's an animated model, you use one bind pose for all instances, and each instance will have a local copy representing the current state. Seems efficient enough to me. As for quats versus mats, doesn't the average model only have 20-30ish bones if that? It seems like the savings in computation from the conversion of quats to mats to transform the verts would be worth the extra space. That said, I use quats myself because of SLERP. I thought that was the primary reason for using quats.

Share this post


Link to post
Share on other sites
Well, when i first did skeleton animation, i transformed all the vertices myself, then rendered it, and it got a pretty good frame rate. But i'm sure it ate away at the speed.

Share this post


Link to post
Share on other sites
That does actually seem counter productive to pretransform, since you would have to do that per instance of that mesh in your scene. I transform in the vertex program, I have one mesh of untransformed vertices, I set the array of bone matrices, then I transform inside the program. Since I am using shadow mapping, I don't have to worry about finding the sillouhette or anything of the animated shape. Even for shadow volumes, it should be possible to transform in the program, AND extrude after that, still in the program, without having to worry about having it all pretransformed on the CPU.

If you want to get super efficient, then it probably is possible to transform per pose, and reuse that pose when needed. At that point, though, you are trading stability and straight forward code for efficiency, and I doubt it'd even be a huge boost unless you're rendering thousands of that mesh.

Share this post


Link to post
Share on other sites

This topic is 4203 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this