Open Duskitten opened 1 month ago
With such an high number of active animation players on characters, you'd need SceneTree multithreading to achieve reasonable performance. However, this isn't finalized yet.
Your best bet for now is to disable animation playback for nodes that are far away, or set their process mode to Manual and step through their animation less often (e.g. once every 2 frames). This is a common approach in AAA games.
VisibilityNotifier3D in 3.x has a Max Distance property that can be used to disable animation playback in the distance automatically. It hasn't been ported to 4.x's VisibleOnScreenNotifier3D yet though.
The manual process mode trick should be documented somewhere
Since I've been delving into performance stuff, here's a shot of Tracy profiling of animations with my fairly simple low-poly enemies in KOOK:
So the average _process_animation takes around 40 microseconds. With 100 enemies, that's like 4ms, which isn't super great.
Here's the tracy file if anybody wants to poke around: kook trace 20240621.zip
Most of the time is spent in AnimationMixer:_blend_process followed by _blend_calc_total_weight. About 20 microseconds and 9 microseconds there.
If manually stepping is the solution, it would be nice to have some sort of built in system to prioritize closer/in view objects so they update every frame and then have a max number of animations played per frame or something.
I do feel like some optimizations could be done, though, outside of that and multithreading.
Edit: Just realized there's a PR to do some optimizations here: https://github.com/godotengine/godot/pull/92838 Nice!
Animation does not support multi-core
Animation does not support multi-core
This is expected for now, as SceneTree multithreading isn't finished yet. Work on this started in 4.1 but it's only applied to a few parts of the engine, so I don't think AnimationTree is able to work in a thread-safe manner currently.
Despite this, it's still possible to optimize AnimationTree significantly as evidenced by the PRs linked above.
![]()
For more performance minimize or close the editor windows as that is alos consuming fps , and also what calinou said and make the debug screen fullscreen , as they are not the same size as flax so it not quite fair as a comparison...
Tested versions
Confirmed by me:
Confirmed by other people:
System information
Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1080 (NVIDIA; 31.0.15.4629) - AMD Ryzen 5 1600 Six-Core Processor (12 Threads)
Issue description
Upon the creation of many animation players + animation trees (in this case 1024) with animation indexes, but no actual keyframes the engine proceeds to drop frames or fps becomes incredibly unstable due to high process call ms being added (goes from 16ms to 25-30ms)
Steps to reproduce
Create a new object, put give it an AnimationPlayer + AnimationTree (keep the animation running) and animate it, but remove the actual keyframe, and duplicate it 1024 times, fps becomes unstable or process ms doubles and causes consistent framedrops.
Disabling animation playback returns to stable 60fps.
Minimal reproduction project (MRP)
AnimationTimer.zip This simply duplicates a pre-made character 1024 times to sit in a 3D scene, with an animation with 0 keyframes running and performance begins to hurt in master branch.
Disabling animation playback returns to stable 60fps.