How to batch Playable graph.Evaluate() from multiple gameObjects?

As described in an old forum https://forum.unity.com/threads/perfomance-problems-of-playablegraph-optimizing-animators.1414872/ - graph.Evalute is a single threaded call ( awaited for multiple animation jobs and graph update for a single gameObject).
We need to batch multiple of those graphs and evaluate them using all available cores.

Is it possible or do we need to completely redesign from scratch all animation and start all over again? ( e.g. DOTS Animation Jobs + custom system and components to apply all the weights\time\animation clip per node onto root gameObject)

It is very frustrating when Unity can’t even see the obvious use cases…

4 Answers

4

if anybody is still interested - you simply switch

Graph.SetTimeUpdateMode( DirectorUpdateMode.UnscaledGameTime );

and in your Update method where you are using actual Evaluate(delta):

_animator.speed = deltaTime / Time.unscaledDeltaTime;

Note:

This is not exactly evaluated as you wish, as PlayableDirector will schedule and batch all of the graphs somewhere from update to LateUpdate - only once per frame.

The above solution works only in if you are using Unity's Update Loop, without it - you can't batch any PLayable Graphs. Please Unity help us find the solution to this!

–

Additionally there is a good explanation on how and when PlayableGraph executes:

Do you mean add _animator.speed = deltaTime / Time.unscaledDeltaTime; before the Evaluate(delta) call? Or replace it?

when using default Unity animation batching via PlayableDirector - you don't need to call Evalute on the graph, instead Unity will do it sometime from Update to LateUpdate for all graphs that are in automatic mode ( see how to set graph into playableGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime) ) TLDR: if you want batching - do not call evaluate ( it will force single threaded evaluation of a single instance of the object grpah)

–

Additionally - when you have IK - if you are using manually evaluation - your IK Rig should sync target to the Rig ( Rig builder has it’s own Rig internal ECS systems and components) via

      // TODO: This is a separate single thread call ( in the main thread) for each character, see if we can also batch it.
      RigBuilder.SyncLayers();

I’m not quite sure on how to batch that separately and make sure it will be evaluated before the animation graph is evaluated by the director ( in the same frame).