Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Controlling animation related systems execution.

Discussion in 'DOTS Animation' started by Antypodish, Apr 3, 2021.

  1. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,753
    I got following case scenario:

    upload_2021-4-3_1-55-16.png

    2500 rigs, which animates 40 bones each.
    I have 3 systems running constantly, which are killing my performance.

    In SimulationSystemGroup
    ProcessDefaultAnimationGraph 2.64 ms
    EndFrameParentSystem 2.85 ms

    In PreLateUpdate
    InitializePushSkinMatrixSystem 10.45 ms

    In second scenario I have 2500 rigs of character.

    upload_2021-4-3_2-34-32.png

    Only one is actually animated. Other stands still. But systems are pretty occupied.

    I need to figure out, how to inhibit entities from execution in these systems.
    I hope there is some component tag, which can control that behavior.

    One thing I haven't tested yet is, if I stop animation timer running, or set animation time to constant value, does recalculating actually stops? Or still run, even if bones don't change?

    Any helps, or suggestion would be massive appreciation.


    Edit:

    What I found is, in
    Library\PackageCache\com.unity.rendering.hybrid@0.11.0-preview.42\
    There is FinalizePushSkinMatrixSystem.cs
    following code.

    Code (CSharp):
    1. public abstract class FinalizePushSkinMatrixSystemBase : SystemBase
    2.     {
    3.         EntityQuery m_Query;
    4.  
    5.         protected override void OnCreate()
    6.         {
    7. #if ENABLE_COMPUTE_DEFORMATIONS
    8.             if (!UnityEngine.SystemInfo.supportsComputeShaders)
    9.             {
    10.                 Enabled = false;
    11.                 return;
    12.             }
    13. #endif
    14.  
    15.             m_Query = GetEntityQuery(
    16.                 ComponentType.ReadWrite<SkinMatrix>()
    17.             );
    18.         }
    19.  
    20.         protected abstract PrepareSkinMatrixSystemBase PrepareSkinMatrixSystem { get; }
    21.  
    22.         protected override void OnUpdate()
    23.         {
    24.             if (PrepareSkinMatrixSystem != null)
    25.             {
    26.                 CompleteDependency();
    27.                 PrepareSkinMatrixSystem.AssignGlobalBufferToShader();
    28.             }
    29.         }
    30.     }
    It looks like, there is no way to disable entities behaviour, unless removing DynamicBuffer <SkinMatrix> component, or by modifying system.
    However, I would like to avoid modifying unity.packages files.

    I could probably use
    Code (CSharp):
    1. Unity.Rendering.FinalizePushSkinMatrixSystem system = World.GetOrCreateSystem<Unity.Rendering.FinalizePushSkinMatrixSystem>();
    2.             system.Enabled = false / true ;
    To control frequency of this system update. But it feels, it is dirty approach. And my entities still will update, when unnecessary.
     
    Last edited: Apr 3, 2021