Performance tips and tricks
Simulation
StateMachine vs StateMachine XPU
The state machine computes each agent pose on the CPU. This is heavy to compute. If you are CPU-bound please try to switch to the stateMachineXPU component.
This component simulates only the root bone on the CPU, while it computes the full pose on the GPU. However, there are some limitations. The foot lock and foot adaptation are not supported. Accessing bone transformation from the game thread is possible but expensive since Atoms needs to compute the full pose on the CPU.
For more information about the Anim XPU, look here: XPU Animation.
Multiple behaviour component
Usually, every component uses a parallel_for method to do its job on the agents. The parallel_for wakes up the threads from the thread pool and uses them in parallel to execute some works. This can be expensive, especially in Unreal, where waking up threads is slow. Try to reduce the number of behaviour components as much as possible. For example, use a behaviour tree instead to use multiple “addMetadata”/“trigger metadata”/.. components.
Each behaviour module has a “singleThread“ property. This switches the parallel_for to a simple parallel. Usually, for simple behaviours, like initializing metadata or set metadata it is faster than the parallel version.
Behaviour Tree
Use the behaviour tree as much as possible, especially if you need to read/write metadata. Expose the metadata you need to use inside the blackboard and set your entry's “Use Metadata” to “Link”. Then, set the metadata value using the setBlackboardEntry tasks.
It is faster than using the setAgentMetadata methods since Atoms doesn’t need to query the metadata by its name.
Multiple agent groups
It is similar to the multiple behaviour components optimization. Fewer agent groups mean fewer parallel_for calls, so better performance.
Ragdoll and Collisions
Ragdoll and capsule collisions are slow since it is impossible to update or query the rigid bodies in parallel. Use them only on the agents you need. Consider using animation clips for death animations instead of simulating a full ragdoll.
Rendering
Lod
Atoms support LODs, so if you are GPU-bound, please turn on the LODs on your skeletal/static meshes.
Skeletal mesh: number of influences
You can gain some performance by setting the number of influences on your Lods. Try to decrease the number of influences. This helps the draw.
Render passes
You can disable render passes that you don’t need. Usually, the shadow pass is heavy to draw on many agents. Consider disabling shadow/reflection pass on some LODs.
Assets
Loading an agent-type asset could be expensive, since it needs to read every anim sequence used by the state machine. Please use the “Atoms Assets Subsystem” to load them in advance.
Copyright © 2017, Toolchefs LTD.