Using XNAnimation with many models, slows game down tremendously

Jun 19, 2009 at 2:22 AM

Hello, I started using this library with my models since a lot of people said it was easy to use.  I have it up and running great, but when I have too many models it slows down my game tremendously.  I used a cpu profilier and noticed that almost all my processing power is going towards drawing those models (with the model meshes) and updating the animation controllers (most with the UpdatingChannelPoses that is inside the AnimationController update method).  My question is, is there a way to use this library, the animation controllers and drawing, and not have such a huge hit in performance?

 

Right now I have an EnemyManager class, that holds and manipulates my enemies.  I have it so that the EnemyManager has a SkinnedModel that loads the model of my enemy then I just pass it by reference to the enemy when I create it.  Each enemy has it's own version of a SkinnedModel and AnimationController.  I couldn't get the animations to work if I just had one animation controller in the EnemyManager class because all my enemies would be doing the same animation and not different ones.  Maybe if someone could help me out a bit or could help me out on how to improve the performance?  Any help is appreciated and I could put up my EnemyManager and Enemy class up if requested.  Thanks!

Jun 19, 2009 at 8:34 AM

Hi,

there is some sort of way of skeletal mesh instancing and rendering different animation (states) with it. But I don't know more about that or how one could use this with XNAnimation.

Before trying to optimize something of the XNAnimation code, take a step back and look at your current game situation like:
- how many enemies are on screen (and you only need to update & draw these)
- how complex are your shaders
- how high is the bone count of these models
- how high is the poly count of the models
- is your profiling result trustworthy (I had some bad experience when profiling something on the PC and then concluding that that was the problem on the XBOX too)?

 

Jun 19, 2009 at 1:01 PM

For right now in my game I am trying to get the max amount of enemies on the screen at the same time to be around 100.  The shaders are pretty simple, just using the skinnedmodel effect object within each mesh.  For now I am using the default EnemyBeast model, which has I think 59 bones, and I am not sure how many polys.  I am almost certain that the profiling is right, if I don't have many enemies out, my FPS is high, but when I have a lot, they are really really low.  I didn't know if anyone had any tricks up their sleeve or knew of any other XNA animation libraries that are more suited for a high number of animated models showing.

Jun 23, 2009 at 8:17 PM

I found a sample that used skinned model animation instancing but it was only for the xbox360.  Here's the link to my other forum on trying to figure the problem out: http://forums.xna.com/forums/p/33412/192735.aspx#192735  Please check it out anyone.  Thanks!

Jun 25, 2009 at 10:29 AM

As far as I've seen, the polycount of the beast is 3804 triangles, multiply that by 100 and watch you're frame rate explode..well actually implode(?) ^^
In other words: it is way to high if you use that high amount of enemies!

Jul 2, 2009 at 12:11 AM

Yeah, I inderstand that.  Plus my friend who is making all the models and art is going to have the poly count much lower than that.  I guess I can wait and see how much of a performance difference there is between our own 100 enemies and the 100 beast enemies before I decide whether or not I should do that.  I mean, it wouldn't hurt now would it? lol