Game Development Community

How to speed up scenes with some hundreds of animated characters?

by GameArt Studio GmbH · in Torque 3D Professional · 11/04/2010 (10:44 am) · 11 replies

Hi,

I opened this thread to discuss how you would go about to have a playable scene with as many animated characters as possible. I'm talking of about roughly 200 characters per screen. I tried the RTS demo setup and started to drop in batches of AIPlayers. In a release build the render time is sufficient to deal with a few hundred bots, but the behavior of the AIPlayers is completely erratic. Looks like a bunch of sand fleas hopping about. One thing I tried is to disable the playerobject-playerobject collision, which brings a bit of a speed up. Other bottlenecks seem to be the terrain collision and the scripting. It's propably not the best idea to use the AIPlayer scripts in this setting. Another bottleneck seems to be the Giddeon character model, my guess here is that it has too much detail for what I want.
Any suggestions?
Think of Serious Sam and the Total War series. We don't aim at the same character counts, but those are examples what should be doable on mediocre hardware.

Cheers,
Thomas Lobig from Game Art Studio

#1
11/06/2010 (8:51 am)
Well, you have to understand that the AIPlayer is an advanced object. Why don't you try an object that doesn't require so much networking or cut down on how much networking the object has to do?
#2
11/06/2010 (10:03 am)
games with hundreds of animated characters probably make heavy use of multi-threading, which torque doesn't. there are certain things you can do to speed up performance for those kinds of scenes, such as decreasing the frequency of movement processing, decreasing the frequency of collision detection, and using a thread pool for parallel processing. however, by default, torque isn't optimized to handle a scene with hundreds of ai characters.
#3
11/06/2010 (6:28 pm)
200+ AI entities running at an acceptable framerate in a multiplayer environment is certainly achievable with T3D. In fact double that is possible if you're willing to get down and dirty with the source code. Here are some tips:

1) Definately don't use AIPlayers.

2) In fact, don't use anything derived from ShapeBase. ShapeBase is a dirty class with way too much unnecessary overhead.

3) Write yourself a new class derived from GameBase, and add in only the functionality that you absolutely require. Don't use complicated collisions and physics if they aren't absolutely necessary.

4) Limit the frequency of your transform updates across the network.

5) Limit the frequency of your AI processing.

6) Make sure that you aggressively LOD your models. Also, try and make the skeletons for your models as simple as possible. One of T3D's performance bottlenecks is the animation of skinned meshes, so by limiting the number of bones in your model, you are reducing the cost of animating them. This can really add up.

By doing this, 200 AI entities on screen is perfectly doable.
#4
11/11/2010 (6:43 am)
Thanks Guy, your post is most enlightening. Some of it I assessed likewise (eg that the skinning function really is.. well.. slow)

Btw, I really could use a realtime profiler, also: Relative time spent in the function is not the only thing you need to know.. gosh.

I will try what you suggested, Guy, and see where I get to by doing that.

Edit: Atm I'm developing on an Intel i3 machine, not one core is fully loaded, the limiting factor in my scene is not the CPU - I think we know now where to put the programming work to.
#5
11/11/2010 (1:44 pm)
Networking is a big area that can be tackled. Check out bumping up the network prefs (those prefs were put in place for modems), as well as ripping out stuff you don't need.

And Guy is right, the current Player/AIPlayer is very heavy. I'd love to see a stripped-down, bare bones version.
#6
11/11/2010 (5:49 pm)
I read multiple times that AIPlayer is full of non useful thing that make it "not recommedable" for multiplayer.

Can someone explain if I understand that properly?
From what I understand, the issue is that the bits use by player are not useful for an AIPlayer (but if the bits are not dirty nothing is sent?). As a consequence, more information are sent over the network and this is the major drawback of the current implementation.

Concerning the network parameters, what type of parameters you will change? I mean, I don't see other thing than the packet size that could be useful.

Information frequency sent for AIPlayer: Is there a way to do that?

Thanks,
#7
11/12/2010 (9:00 am)
The skins are a real problem in a large scene with many ais.
Over 60-80 skinned players-aiplayers lags a lot.
#8
11/12/2010 (9:55 am)
Ivan, could you please give more details?
I'm not sure to understand what the downside of the skins system.

What should be done to clean this Improve the performance?
#9
11/12/2010 (10:38 am)
Performance depends on how the model is rigged,are there many sub meshes,etc..
Using the bone system frequently will hurt your framerate.
#10
11/12/2010 (2:37 pm)
LOD like a man possessed, LOD bones too.
#11
11/12/2010 (6:31 pm)
I understand the LOD things and trying to have AI Player as simple as possible.
Is there other areas to look at? because I things the performance can also be improved in the C++ source and not only at the model level.