Skeletal Animation Issues

Started by
15 comments, last by Bejan0303 13 years, 6 months ago
Hello all,

I have recently been playing with the ms3d files and implementing skeletal animation and loading it. I load the model and the skeleton seperately, so I can attach more than one model to the same skeleton. Then I create ModelInstances and SkeletonInstances, and they are where all transforms and joint evaluations happen.
My problem: my frame rate takes a huge dive with just a simple humanoid skeleton being animated. The only thing being drawn is the animated model. Its below 50. Is this normal?? I can't imagin professional games find this acceptable.

The steps I take to animate:
Evaluate the joints in skeletonInstance.
Transform each individual vertice into a temporary array.
Then I deference the model triangle list into an array with the newly transformed vertices( I figured this would draw faster than any other way).
Copy this into a buffer and dump it to the renderer.

I am using Direct3D 9, but I am pretty familiar with openGL if anyone has any examples in either API. If example code is needed I can post some. It just seemed very messy to post so if I could avoid it I would. Thanks a lot!

Also if my hardware is relevant:
2x 3.2Ghz pentium 4
256MB ATI Radeon 9800 XT
Advertisement
Are you transforming every vertex on the CPU?
There are different ways to do it on the GPU instead. You could upload a matrix for every bone, and transform each vertex according to a bone-id which you previously set.
Quote:Original post by Bejan0303
The steps I take to animate:
Transform each individual vertice into a temporary array.
Then I deference the model triangle list into an array with the newly transformed vertices( I figured this would draw faster than any other way).
Copy this into a buffer and dump it to the renderer.


this is not efficient. i think you should be passing these into vertex buffers like usual, and then passing your bones and such things to a vertex shader for evaluation.

"Transform each individual vertice into a temporary array." this is certainly not the way to do it.

------------------------------

redwoodpixel.com

Wow you guy responded fast! Yes definately all on CPU. I have never used aa shader to do something like that.
Could post of psuedo code on that? Also is the full list triangle vertices not triangles with indices to vertices, so I figured a temporary array would be good to only transform each vertice. If how would you guys go about that then.

Thanks so much for the quick replies!
for what it's worth, you can get good speeds by doing this on the CPU too (i know several retail games that do this).

Also, doing it on the GPU might be the good answer here, but if you are GPU bound, it's a better idea to do it on the CPU.

just fyi!
well thanks I can see that it works and animted correctly but when mke two instances frame rate hits 20 or less. I think I'm just doing something in correctly do you think copying from the temporary array to the triangle list is takin all the time?

It's tempting to go guessing at the reasons for why your code would be so slow (my bet would be the copying step into the buffer), but the best advice is probably that you should profile your code to find the bottleneck. It may be something as simple as locking with the wrong flags, but it might also be any of a number of obscure problems I can think of.

Skinning on the GPU is typically an order of magnitude faster though, because the vertex transforms take place on specialized hardware and it doesn't require any buffer locking or copying. The DirectX SDK should have some samples on skinning which may be worthwhile to look into.
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
When you say temporary array, do you mean something that you allocate each frame? In that case it would probably help to keep the array around.
No it have it declared in the model instance class and never changes in length so its only allocated once
Use the debug runtime, it can give you performance warnings.

Also, are your vertex buffers dynamic? If not, they should be. There's a section in the SDK documentation on how to use dynamic vertex buffers.

This topic is closed to new replies.

Advertisement