Jump to content
  • Advertisement
Sign in to follow this  
Bejan0303

OpenGL Skeletal Animation Issues

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

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!