FAQ: Animation - Programmers

Dec 8, 2020.Knowledge

What optimization options are there in the animation system?

If the animation update is threaded, how is that threading handled?

  • Animation is threaded, except in the case of root motion driven character movement (as this updates and evaluates animation ‘in-line’ inside of character movement’s tick). The system uses the task graph to run graph update, graph evaluation and a few other tasks on worker threads. Basically if it can be sandboxed enough (ie. not general blueprint execution) then it is run on a worker thread.

In what order do the evaluations occur from tick to animation update to animation applying?

  • At a high level (GT = Game thread, WT = Worker thread)
    • GT - BlueprintUpdateAnimation (event graph) & NativeUpdateAnimation
    • GT/WT - Graph update
    • WT - Graph evaluate
    • WT - Interpolation/curve update
    • GT - Notify dispatch
    • GT/WT - Physics update
    • GT - Buffer flip

What is the data flow in the animation system? Where and when do we have access to what?

  • The SkeletalMeshComponent always holds the most recent pose. So until there is an animation update, that is the last frame’s pose. After, it will be the current frame’s pose. An animation update is split in 2 parts:
    • Update the graph hierarchy (tick graph from root to leaves to set weights and advance time).
    • Evaluate (from leaves back to root). Here the pose flows through each of the nodes to produce the final output.

What data within the level can you safely look at or modify in your own AnimGraphNodes?

  • You can perform queries on the scene, but actor/component data should not be accessed from Anim Nodes. Anim Nodes should only operate on data in the FAnimInstanceProxy.

We’re using the Update Rate Optimization (URO) to reduce the tick frequency of our characters but that doesn’t seem to make a noticeable difference to game thread performance. Where in a Razor CPU capture should we be expecting to see savings?

  • URO mainly reduces Update and Evaluation work which happen on worker threads not the game thread. Refresh Bone transforms should take slightly less time when URO causes a skip as we won’t set up the worker thread tasks.

Is there a way to put some blueprint script to run (on the client) after a Montage finishes?

  • Yes, you can bind to a delegate to execute some logic after a Montage has executed. You can do this in the montage itself, or manually if you’d like. You can take a look at the PlayMontage blueprint node as an example of the delegates you can bind to. See UPlayMontageCallbackProxy for more.

What is the cost of using Morph Targets? Are there best practises on how much and when or where to use them?

  • We don’t use them for performance reasons. Morph targets are heavy on the GPU and the performance cost scales with the number of blend shapes that need to be evaluated. Morph targets depend on the vertex indices being the same between blend shapes to properly interpolate, so mesh edits can be painful. In general, we recommend using Animation Pose Assets instead of Morph Targets.

How do you query animations that are not currently playing?

  • There are exposed APIs that allow this. If you have a reference to an AnimSequence asset, you can access it and start looking at the data.