Search Unity

Performance with multiple masked layers

Discussion in 'Animation' started by WendelinReich, Nov 2, 2014.

  1. WendelinReich


    Dec 22, 2011
    Hi Mecanim devs!

    A question about performance. I have a complex dog character (generic rig) with separate animations intended for body, tail, ears, eyelids etc. Of course, these are handled by different layers in my animator controller. The layers use masks and are set to 'override'. I'm using nested blend-trees on most layers, so at any given point in time, a large number of animation clips (20? 30?) might run on the character.

    Here's the question: Is the performance cost of each additional layer the same as for the base layer, or does it get smaller because of the layer mask? For instance, the eyelid-layer only controls 4 deformation bones (out of ca. 90) - does this mean that the cost of using it is only about 5% of that of the base layer (assuming that each layer plays the same number of blended clips)?

    (I checked out the Mecanim Performance and Optimization tips, but they are not specific enough. I'm asking because I need to know if I should keep the number of layers as low as possible or if I can be generous with them.)

    Thanks, Wendelin
  2. Mecanim-Dev


    Unity Technologies

    Nov 26, 2012
    Hi WendelinReich,

    Not exactly, there is many step involve when you evaluate a controller:
    Evaluate state machine
    Evaluate animation clip
    Evaluate clip blending
    Write data into transform

    The layer mask affect only clip blending and Write data step. Animation clip evaluation is not affected so for each layer you will evaluate the whole animation's clip curve. So yes there is a cost but unless you have many dog in your game that shouldn't be an issue.
    WendelinReich likes this.
  3. Qriva


    Jun 30, 2019
    Sorry for necro, but information is 8 years old, so if possible I would like some update, @Mecanim-Dev is it still true or something changed over all these years and it's more optimized?