Best way to render a skeletal animation?

Started by
3 comments, last by xycsoscyx 17 years, 10 months ago
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
--X
Advertisement
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.
~dv();
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.
Write more poetry.http://www.Me-Zine.org
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.
A wiseman once said nothing, but no one was there to hear it.
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.

This topic is closed to new replies.

Advertisement