# New example demonstrating a few possible animations optimizations

**URL:** https://forum.castle-engine.io/t/new-example-demonstrating-a-few-possible-animations-optimizations/1223
**Category:** News
**Created:** [June 7, 2024, 4:34pm UTC](https://forum.castle-engine.io/t/new-example-demonstrating-a-few-possible-animations-optimizations/1223 "2024-06-07T16:34:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [June 7, 2024, 4:34pm UTC](https://forum.castle-engine.io/t/new-example-demonstrating-a-few-possible-animations-optimizations/1223/1 "2024-06-07T16:34:13Z")

</div>

| [![Optimize animations](https://forum.castle-engine.io/uploads/default/original/2X/c/caa7560e592cf981438dbd8bcd32e64fbbfdcbe6.png)](https://castle-engine.io/wp/wp-content/uploads/2024/06/screenshot.png "Optimize animations") |

I added a new example showcasing various engine features you can enable to optimize how animations are processed. It is present in [examples/animations/optimize\_animations\_test](https://github.com/castle-engine/castle-engine/tree/master/examples/animations/optimize_animations_test) subdirectory of the engine. Enjoy!

Make sure to make a _release_ (not _debug_) build to experiment with performance. On my system, I can make FPS between 15 and 60 (which is maximum with vsync=on for my system), depending on the configuration of the switches. So there’s a nice spectrum to show how various options improve the speed.

Read the API reference of the linked options for details — what these things do, when do you want to enable them (and when not):

- `OptimizeExtensiveTransformations` and `InternalFastTransformUpdate` — both especially useful in case of nested transformation hierarchies when many transformations change every frame. Like typical animations done using skeleton, in Spine or glTF. In the future, I hope to be able to actually remove both these flags, and have their respective optimizations always “on” and universal (always beneficial, never losing any functionality)

- `TCastleViewport.DynamicBatching` also helps, though it is really a rendering optimization (doesn’t affect how animations are processed).

- `TCastleSceneCore.AnimateOnlyWhenVisible` does pretty much does what it says :), it only optimizes animations if you look _away_ from them. The invisible animations are not updated, saving time. You can experiment with this by looking away (press right mouse button to activate mouse look in the example).

- `TCastleSceneCore.AnimateSkipTicks` is a “brutal” optimization — if you set it to something \> 0 then animation just doesn’t update every frame. In this example you can toggle it between 0 (don’t skip) and 1 (skip every other frame). You can experiment with setting it to something even larger, like 2, for even more performance but sacrificing quality.
