Search Unity

[RELEASED] GPU Instancer - Crowd Animations

Discussion in 'Assets and Asset Store' started by LouskRad, Apr 29, 2019.

  1. Mic_Emond

    Mic_Emond

    Joined:
    Nov 16, 2016
    Posts:
    45
    Hello again,
    I have a situation where all my sub-objects of prototypes get unparented after calling AddPrefabInstance on the CrowdManager.

    My setup is:
    - ROOT
    - MESH
    - Root_Bone
    - bone (21 bones hierarchy)​
    - object with logic
    - object with logic child 1 (2, 3 etc)​

    After doing AddPrefabInstance
    The hierarchy in the scene gets flattened, even for the "object with logic" children. Meaning it's now:
    -ROOT
    - MESH
    - Root_bone
    - bone child 1
    - bone child 2
    - object with logic
    - object with logic child 1
    - etc
    All at the same level as "mesh".
    I've tried debugging etc, I can't see where this unparenting is happening.
    If I DONT use "sync bones". None of the bones are in the hierarchy, but the rest is still flatened.

    The model is setup with the "optimize gameobjects" option to OFF.
    I tried a prototype that was setup as a variant of the original fbx model. And a prototype with a original prefab created from the base model after doing "unpack" on the model.

    Could really use some help with this one, I've been bashing my head against it for a couple of days.

    EDIT:
    I've add some success with the following setup:
    NEW ROOT
    MODEL ROOT (keep link)
    Bone root
    bone 1 ,etc
    Attachement weapon​
    Object with logic
    Colliders
    Etc

    The bone hierarchy still gets flattened (only the ones with attachments show up)
    But the weapon attached now doesn't get flattened. Neither does anything "outside" the model root.

    Would still appreciate a pointer on what is happening here? In the demo for attachment, the whole bone hierarchy is there also. (which I don't mind, but would be nice that GPUInstancer affect only specific objects/ bones and not the whole hierarchy :/ )
     
    Last edited: Mar 28, 2023
  2. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    Crowd Animator requires to flatten the hierarchy by design so the transforms can be processed individually, used in suitable data structures in the GPU and modified in threads. So unfortunately there is not an option to keep the hierarchy.
     
  3. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    please check support email
     
  4. Raptor2k2

    Raptor2k2

    Joined:
    Jun 8, 2013
    Posts:
    2
    Hi, we've been considering integrating this plugin to our project. Our project is heavily based on the animator but the performance gain that we obtain using crowd animator are impressive enough to justify refactoring our codebase. One thing that I feel is missing is to have the equivalent of the OnAnimatorMove callback. We need to have root motion informations without the plugin updating transforms automatically. I can see where and how the plugin handle root motion and update transforms in a job. Any suggestion on how we could get position / rotation delta inside a MonoBehaviour?
    I've been able to hack my way by passing additional native arrays to the root motion jobs and preventing the job to change the transform access array but it's super messy and I'd rather have an official way of doing it
     
    Last edited: May 19, 2023
  5. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    If you need to calculate the position / rotation change from the previous frame, you can store the information and calculate the difference in a MonoBehaviour.
    Crowd Animator does not have a built-in way of doing it because it would slow things down to add callbacks or make additional calculations and store additional data.
     
  6. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    Hello, I'd like to know which is faster in these hypothetical scenarios:

    40,000 instances, each one with 300 triangles
    8,000 instances, each one with 1,500 triangles

    Basically, what's the tradeoff between having many low-poly instances, and few high-poly instances? Which is more of a drain on performance - poly count, or instance count?
     
  7. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,074
    I would say.
    8k instances is better.
    You will have your mesh stored on a gpu so only transformations are going to be sent.
     
    GurhanH likes this.
  8. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    Usually having higher instance count with lower triangles is better with GPU instancing rendering performance. But as @koirat mentioned, if you are making transform updates every frame, it might cause a bottleneck because of higher data transfer to GPU.
     
    Abbrew likes this.
  9. Mic_Emond

    Mic_Emond

    Joined:
    Nov 16, 2016
    Posts:
    45
    Hello,
    Any plans on supporting Vulkan on PC ?
    The asset store page shows that it should support Vulkan for Android. Figured I'd try, but I'm getting errors when trying to use it on Windows.
     
  10. zkajo

    zkajo

    Joined:
    Jul 28, 2016
    Posts:
    9
    I'm trying to expose some transforms on my prefab. I tried with only one or two, but the following test contains all of them. I'm using crowd animator.

    Only one is ever exposed - rest are missing (deleted). Why does it happen? I can't find anything in the documentation.





    Also, I'm getting some nasty deformations like here which do not happen in original animations. Is there any way to prevent that?

     
  11. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    We did not see any issues using Vulkan on PC during our tests. Can you please make a detailed bug report following this guide so we can investigate.
     
  12. daoviettuan2002

    daoviettuan2002

    Joined:
    Nov 5, 2018
    Posts:
    9
    Hi Sir,
    I have a question. Can I get value isfrustum of player when player inside camera or outside? I checked Use Frustum Culling is enable.
     
  13. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    GPUI makes the culling calculations on the GPU and reading back the results is a very slow process. GPUI does not have a culling check on the CPU side. You need to implement your own frustum calculations (e.g. using TestPlanesAABB).
     
    daoviettuan2002 likes this.
  14. KD_W

    KD_W

    Joined:
    Feb 9, 2015
    Posts:
    19
    Hi, How can I use bone attachments with no gameobjects? I don't know how to access the bone transforms.
     
  15. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    Since there are no GameObjects, there are no bone transforms that you can attach GameObjects to. So it is not supported.
    However it is possible to calculate the bone matrices from the baked data, if you wish to implement a custom solution. You can use the ApplyBoneUpdatesJob in GPUICrowdRuntimeData.cs as a starting point. There, you can see an example of how to calculate the bone matrices.
     
  16. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    The lowest framerate allowed for a prototype is currently 15. Is there a reason for this? Could I modify it to be 5 without unexpected consequences?
     
  17. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    It is just a limit on the inspector UI. You can change it.
    However, Crowd Manager uses linear Interpolation to estimate bone matrices between baked frames to transition smoothly (otherwise it would look like a stop-motion animation). Lower framerate values will reduce the accuracy of this estimation and it might become an issue especially on animations with fast movement.
     
    Abbrew likes this.
  18. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    Been getting this error every time I open the Unity Editor and enter Play Mode with a GPU Crowd Manager in the scene

    Code (csharp):
    1.  
    2. ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    3. Parameter name: index
    4. System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <a44461766a7a46b18786ab80319cad08>:0)
    5. GPUInstancer.CrowdAnimations.GPUICrowdUtility.SetAnimationData (GPUInstancer.CrowdAnimations.GPUICrowdRuntimeData runtimeData) (at Assets/GPUInstancer-CrowdAnimations/Scripts/Core/Static/GPUICrowdUtility.cs:124)
    6. GPUInstancer.CrowdAnimations.GPUICrowdRuntimeData.InitializeData () (at Assets/GPUInstancer-CrowdAnimations/Scripts/Core/DataModel/GPUICrowdRuntimeData.cs:75)
    7. GPUInstancer.GPUInstancerUtility.InitializeGPUBuffer[T] (T runtimeData) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:132)
    8. GPUInstancer.GPUInstancerUtility.InitializePrototype (GPUInstancer.GPUInstancerPrefabManager prefabManager, GPUInstancer.GPUInstancerPrefabPrototype prototype, System.Int32 bufferSize, System.Int32 instanceCount) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:3620)
    9. GPUInstancer.GPUInstancerAPI.InitializePrototype (GPUInstancer.GPUInstancerPrefabManager prefabManager, GPUInstancer.GPUInstancerPrefabPrototype prototype, System.Int32 bufferSize, System.Int32 instanceCount) (at Assets/GPUInstancer/Scripts/API/GPUInstancerAPI.cs:594)
    10. Collapse.Actor.Engine.ConstructionManagedSystem.InitializeGPUIManager (GPUInstancer.GPUInstancerPrefabManager manager, System.Collections.Generic.Dictionary`2[TKey,TValue] modelMappings, System.Collections.Generic.Dictionary`2[TKey,TValue] variationIndexMappings, System.Collections.Generic.Dictionary`2[TKey,TValue] prefabData) (at Assets/Collapse/Scripts/Actor/Engine/Construction/Construction.cs:759)
    11. Collapse.Actor.Engine.ConstructionManagedSystem.AnimationBase () (at Assets/Collapse/Scripts/Actor/Engine/Construction/Construction.cs:672)
    12. Collapse.Actor.Engine.ConstructionManagedSystem.OnUpdate () (at Assets/Collapse/Scripts/Actor/Engine/Construction/Construction.cs:414)
    13. Unity.Entities.SystemBase.Update () (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.65/Unity.Entities/SystemBase.cs:418)
    14. Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.65/Unity.Entities/ComponentSystemGroup.cs:708)
    15. UnityEngine.Debug:LogException(Exception)
    16. Unity.Debug:LogException(Exception) (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.65/Unity.Entities/Stubs/Unity/Debug.cs:19)
    17. Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.65/Unity.Entities/ComponentSystemGroup.cs:713)
    18. Unity.Entities.ComponentSystemGroup:OnUpdate() (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.65/Unity.Entities/ComponentSystemGroup.cs:666)
    19. Unity.Entities.SystemBase:Update() (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.65/Unity.Entities/SystemBase.cs:418)
    20. Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.65/Unity.Entities/ComponentSystemGroup.cs:708)
    21. Unity.Entities.ComponentSystemGroup:OnUpdate() (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.65/Unity.Entities/ComponentSystemGroup.cs:666)
    22. Unity.Entities.SystemBase:Update() (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.65/Unity.Entities/SystemBase.cs:418)
    23. Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.65/Unity.Entities/ScriptBehaviourUpdateOrder.cs:526)
    24.  
    The only way to fix this is to rebake all animations each time I open the Editor. That prevents this error from resurfacing. I don't know what's causing this - but I can provide these details:
    • There's both a Crowd and Prefab Manager in the scene
    • Both are child prefabs of a parent prefab that is then dropped into a scene
     
    Ardinius likes this.
  19. gekidoslair

    gekidoslair

    Joined:
    Sep 7, 2012
    Posts:
    128
    Trying to get this setup with an ASE shader, but the second I connect the Crowd ASE node to my shader, my characters get scaled up in the scene by double for some reason? Any ideas?

    Without GPU Crowd (with 1m cube for scale reference):
    2023-06-24 14_28_16-PedestrianSystem - Inventory - Windows, Mac, Linux - Unity 2022.3.0_ _DX11_.png

    With:
    2023-06-24 14_29_11-PedestrianSystem - Inventory - Windows, Mac, Linux - Unity 2022.3.0_ _DX11_.png
     
  20. gekidoslair

    gekidoslair

    Joined:
    Sep 7, 2012
    Posts:
    128
    Next, I bake the animation for the character (which seemed to work), but then I click the 'test animations' button and...very interesting things happen:

    2023-06-24 14_47_18-PedestrianSystem - Inventory - Windows, Mac, Linux - Unity 2022.3.0_ _DX11_.png
     
  21. gekidoslair

    gekidoslair

    Joined:
    Sep 7, 2012
    Posts:
    128
    so this character mesh had multiple submeshes (hat / eyes etc), thought that might the issue, so I combined the meshes, and rebaked...and it is 'sorta' better? The head worked at least this time?

    Some specifics: animator has a single animation (just an idle to test), humanoid rig / animations

    2023-06-24 15_16_58-PedestrianSystem - Inventory - Windows, Mac, Linux - Unity 2022.3.0_ _DX11_.png
     
  22. gekidoslair

    gekidoslair

    Joined:
    Sep 7, 2012
    Posts:
    128
    it's strange, when I hit 'bake animations' I can see the proper mesh in the animation pose in the scene briefly before it completes baking...but...then this happens
     
  23. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    It seems like "Bake Animations For All" isn't saving the changes to the Scriptable Object properly Screen Shot 2023-06-25 at 9.48.04 AM.png Screen Shot 2023-06-25 at 9.48.15 AM.png


    The changes are made, but exiting Unity won't even prompt me to save the changes to these scriptable objects. They revert upon reopening Unity. I now have to manually select each prefab and click "Bake Animations" instead. "Bake Animations For All" used to always save - what could have happened to make this function break?
     
  24. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    83
    Hi, your asset looks very cool, I am just wondering if you have tried using it with PuppetMaster?

    I believe it would not work with active ragdolls as you could not bake the vertex positions, however perhaps I could have distant puppets set to fully kinematic, and render them with this?

    Would there be any benefit with GPUI or Crowd Animations when the puppets are in an active ragdoll state?

    Could you provide any pointers on this use case?

    Thanks.
     
  25. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    Please email us a bug report with a sample project following this guide and we can investigate the issue.

    There might have been some changes in Unity's editor behavior. We probably need to add SetDirty calls for some Unity versions. Please email us a bug report following this guide, so we have sufficient information to investigate the issue.

    Hi there,
    Crowd Manager bakes the bone transform matrices for each animation into a texture and uses this texture to apply GPU skinning to the meshes. So any runtime bone/vertex modification including ragdolls can not be rendered with Crowd Manager.
    I did not use PuppetMaster before, so I can not comment specifically about it.
     
  26. Dturk34

    Dturk34

    Joined:
    Nov 13, 2014
    Posts:
    24
    Hi there,

    I just bought the package and tried to play the example scene, and it's not working at all. Here are the exceptions that I get. I'm using the 2022.3.5f1 LTS Unity version and HDRP 14.0.8. Also, it's a DOTS project maybe it trigger something Idk.

    Here are the screenshots;
    gpuinstancer.jpg
    I got an exception while importing the package, GPUInstancer was already installed, and it's at the root position (Assets/GPUInstancer) and didn't move anywhere.


    After that, I loaded the example scene and I got this error. It's the Resources.Load line, I checked it. It can't load the "
    CSSkinnedMeshAnimate" so it's not working.

    gpuinstancer2.jpg


    In play mode, it spams this error;
    gpuinstancer3.jpg
     
  27. Dturk34

    Dturk34

    Joined:
    Nov 13, 2014
    Posts:
    24
    Also, I tried to copy the files to "Assets/Resources" with the folders "Compute" and "Editor". Tried with the exact location with the file type ".compute" and without it. It didn't work anyway. It always returns/loads null. Also, when I changed the code with the ".compute" I got these errors on the console.

    https://prnt.sc/AWq5gyzFfC_L

    Edit 1:
    I checked the location in the screenshot. The file is at the exact position that says, and here it's how the file looks;

    https://prnt.sc/oGauDbzl79bs

    https://prnt.sc/VLdPefZpicS7

    Edit 2:
    If I somehow manage to load the compute shaders into the script, I get problems anyway, so I decided to check the compute shaders, and I saw this. (It said these errors while importing them, but yeah.)
    1.jpg

    2.jpg

    I thought the package supports DX12. It does say it's on the asset store.

    Edit 3:
    I deleted the package from the project, made the Graphics API automatic, and imported the package. It's the same nothing changed.
     
    Last edited: Jul 22, 2023
  28. Dturk34

    Dturk34

    Joined:
    Nov 13, 2014
    Posts:
    24
    It's really annoyed me but I managed to work it, but I hope you guys update a patch to fix this. Here is the workaround for anyone having this problem.

    Change these lines in the compute shaders in the "Resources/Compute"


    #include "./../../../GPUInstancer/Resources/Compute/Include/PlatformDefines.hlsl"

    as

    #include "Assets/GPUInstancer/Resources/Compute/Include/PlatformDefines.hlsl"


    Copy the "Compute" folder to the "Assets/Resources" and then it works. I'm not sure if will it work on the build or not bc of the asset path. I'm going to work with it till the dev responds and lets me know how to fix it properly.
     
  29. Dturk34

    Dturk34

    Joined:
    Nov 13, 2014
    Posts:
    24
    Did you guys able to fix this? I'm having the same problem.

    3.jpg
     
  30. Dturk34

    Dturk34

    Joined:
    Nov 13, 2014
    Posts:
    24
    Okay, I found something interesting. I thought it was about my model, the humanoid rig or something like that, and I did investigate the example models. They are generic, and I thought it could be that, but no. It's about baking. If I bake the example models' animations, it's also broken. So, I can't bake animations. It's broken somehow. I realize something during the baking process. While baking, my models(humanoid rigs) go in some sort of sitting position, but the example models stay in the T pose. Both are not working for me anyway, so the baking system is not working for me, I'm waiting for help here. :D
     
  31. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    Hi. I am able to use Crowd Animations without any problems in one project. However, in this other project (Unity 2020.3 - HDRP) only the bones are animated, skinned mesh renderers do not. A sample video:



    These animals are runtime generated. The same animals do work in the other project (Unity 2021 - HDRP). Instancer setup is exactly the same. Where might I be doing wrong?

    EDIT: Ok, ignore this, I found my mistake. I set the prefab manager to animate Objects layer but after that I changed the animals to NPCs layer. Sorry for bothering. :)
     
    Last edited: Jul 30, 2023
  32. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    I have a different question, though. I am trying to rotate the spine1 bone of the character when it is carrying rifle to aim vertical properly (for example, you are on a hill and the enemy is below you). It is possible to do it on LateUpdate with animator. Is there a way to achieve this with crowd animator?
     
  33. EGGxWVING

    EGGxWVING

    Joined:
    Dec 16, 2019
    Posts:
    1
    I have question
    1. How can i removePrefabInstance on GameObject i crate from GPU Instancer - Crowd Animations
    - have anyway to remove prefab on i select it in scene? Remove by Select Gameobject and use api to remove it from the list by api?

    2. on 1 charactor can be much than 1mesh 1texture? on 1prototype
     
    Last edited: Jul 31, 2023
  34. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    Crowd Animations uses baked bone data to apply skinning. So runtime bone modifications are not supported.

    Hi there,
    I am sorry but I did not understand your questions. Please email us a support request following this guide and explain the issue in detail with some examples.
     
  35. shadow_tm

    shadow_tm

    Joined:
    Jul 2, 2014
    Posts:
    10
    Good day, I'm trying to use a GPUI for a corner model that consists of several optional parts. However, draw calls or batches sphericity does not decrease if some parts are turned off. As if all the parts are worn out, the thinness of the batches makes all the parts in the model (and I have 3000 of them), so the FPS drops to 40, which is slower than without instancing. Thus, the number of woodcutters does not increase as 100 prototypes are rendered, but the FPS falls flat. Tell me how to overcome it.

    Demo scene
    Screenshot 2023-08-04 183050.png Screenshot 2023-08-04 183434.png

    My scene
    Screenshot 2023-08-04 183731.png

    My prototype
    Screenshot 2023-08-04 184647.png
     
  36. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    Hello, regarding the incomplete SetDirty calls, I fixed the bug in Unity 2022.3.3 by opening GPUICrowdAnimationBaker.cs and finding

    Code (CSharp):
    1.                 EditorUtility.SetDirty(_animationBakeData.crowdPrototype.animationData);
    2.  
    I then added right after it

    Code (CSharp):
    1.                 EditorUtility.SetDirty(_animationBakeData.crowdPrototype);
    2.  
    And now Bake Animations For All properly saves all assets related to animations. Sorry for not providing you my project for local repo, I can't guarantee that it'll work on your machine out of the box due to it using both DOTS and GPUI Crowd Animations
     
    Ardinius and Dazza007 like this.
  37. KD_W

    KD_W

    Joined:
    Feb 9, 2015
    Posts:
    19
    Hi, I'm trying to make an outline feature. It outlines everything in a layer filter. It works with DOTS instancing. But I tried what I can think, and I can't make it work with GPUI. Any idea how I can make it work? BTW, I'm using noGameObject. Also, is there a way to change the layer of an instance? Thank you.
     

    Attached Files:

  38. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    Meshes rendered with GPUI will not be counted on the Tris and Verts amounts on the stats window. Those numbers will not be correct when using indirect instancing.
    GPU instancing is beneficial while rendering the same mesh/material combination many times. If you have many different meshes and/or materials, GPU instancing will not help. Please see the Terminology and Best Practices pages for more information.

    Thank you for the feedback. We will add this change to the next update.

    Hi there,
    All the instances are rendered with the Layer setting on the prefab. You can not have different layers for instances.
    As an alternative, you can have an Optional Renderer with the outline affect and enable/disable it when needed.
     
    KD_W likes this.
  39. shadow_tm

    shadow_tm

    Joined:
    Jul 2, 2014
    Posts:
    10
    --------------------------------------------------------
    Hi there,
    Meshes rendered with GPUI will not be counted on the Tris and Verts amounts on the stats window. Those numbers will not be correct when using indirect instancing.
    GPU instancing is beneficial while rendering the same mesh/material combination many times. If you have many
    different meshes and/or materials, GPU instancing will not help. Please see the Terminology and Best Practices
    pages for more information.
    --------------------------------------------------------

    Hi!

    First of all, I am very grateful for providing me with links to technology and practices, I can send you many interesting articles, will there be profit from this? Because we are discussing your product, not technology.

    1. I have one material for each parts of my mesh, and the same texture e.t.c
    2. Why those parts of the mesh that are disabled and are optional (inside optional parts list) are drawn (in your debug).
    3. I understand that this technology is intended for drawing a large number of identical meshes with identical materials. One model is just for example.

    This is your demo with your debug

    upload_2023-8-12_1-26-2.png

    Total instances 7
    Draw calls 5 - whay ?

    But enable only 3 part of bunny
    upload_2023-8-12_1-30-40.png


    Since the hare model has only 5 parts, it doesn't really affect the fps (productivity), but my model has more than 700 parts and I have 700 calls to draw with 10-15 activated parts.

    And please do not combine answers to different questions in one post.
     
  40. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    Instance count and the Draw call count are not the same thing. In this example, the renderer for the Body has 3 materials, so it results in 3 draw calls. Left-right arms and legs each have one material. So 3+4 =7 draw calls.
    Optional renderers share most of their data with the main prototype, including the instance count value, to avoid making the same calculations multiple times. When you disable an instance of an optional renderer, it is not removed but instead culled on the GPU. That is why the instance count numbers for optional renderers always show the same value as the main prototype.
    Optional renderers is designed for cases where you have few renderers (e.g. 4-5) which can be enabled/disabled but still have many instances of each optional renderer enabled most of the time. It is not made for 700 parts most of which have few or no instances enabled.
     
  41. Dazza007

    Dazza007

    Joined:
    Feb 11, 2014
    Posts:
    9
    You sir are a lifesaver - this has been annoying me for ages, having to "bake Animations" ever time I restart Unity.
    Sometimes forgetting and putting out a build with broken crowds. This fix solved all of my problems.

    I am using this asset for most of my simpler non ragdoll death animations, and its given me a great boost in performance. Couple that with a custom Compute shader and a few other goodies, and you get my game

    https://store.steampowered.com/app/2331220/1_Million_Zombies/

    Still a work in progress, but a lot of fun pushing the GPU
     
  42. shadow_tm

    shadow_tm

    Joined:
    Jul 2, 2014
    Posts:
    10
    Hi.

    You did a great job and saved a lot of development time for a lot of people. I didn't want it to seem like I'm criticizing your project, it's great. Basically I wanted to ask why the optional parts of my mesh are drawn when they are deactivated. I'm using the code from the OptionalRenderersDemo scene. One difference is that I create instances dynamically instead of placing them on the scene from scratch. I'm obviously doing something wrong, thanks for the replies.
     
  43. OldKing_Wang

    OldKing_Wang

    Joined:
    Jan 25, 2015
    Posts:
    46
    Hi

    i already ask for help days ago with my Order number. via support@gurbu.com.

    but not get any relpay mail :(

    should i just ask the question here ?

    ---

    Basically there are two major proplem for me .

    first . the Crowd Animations can't run Android device with Valkan. it will get

    QueueSignalReleaseImageANDROID failed: -4

    then the app will forzen . can't do anything expect kill the app.

    ps: GPU Instancer it's working fine.


    second. if i switch to OpenGLE3. it's working. but get very low performance. beacuse it get stuck on

    Gfx.WaitForPresentOnGfxThread

    i can't debug or profile what's wrong on GPU part. (my phone not support GPU profile.)

    and it's only happen in Andorid platform. PC is working fine. (IOS is not tested)

    more detail please check the mail.

    thank.
     
  44. Ardinius

    Ardinius

    Joined:
    Oct 4, 2015
    Posts:
    57
    Hi
    I also already emailed for support via support@gurbu.com on the 21st but haven't yet had a reply.
    So posting the problem here in the hopes that others have seen it.
    Basically upon Spawning GPUIC prefabs in the scene this warning appears on the GameObject "Instancing has not been initialized" - I can't find any reference as to why this error may occur in the documentation.
    upload_2023-8-24_11-35-52.png
    My work flow is:
    Fresh Unity version 2022.3.5f1 with fresh project.
    Render Pipeline Builtin
    Downloaded GPUI 1.7.7
    Downloaded GPUI crowds 1.1.5
    Made a prefab, baked its animation, crowd animator selected, saw warning so installed
    Burst 1.8.8
    Ticked of course Enabled runtime, add/remove, auto update transform etc

    Upon opening Unity and running scene
    upload_2023-8-24_11-38-0.png

    I do see the following error displays in the console from time to time:

    [Worker0] Internal: There are remaining Allocations on the JobTempAlloc. This is a leak, and will impact performance
    [Worker0] To Debug, run app with -diag-job-temp-memory-leak-validation cmd line argument. This will output the callstacks of the leaked allocations.


    I have cleaned out the PrototypeData in \crowd\animationData \crowd\prefab \crowd\textures

    Interestingly, if i open the crowdAnimationDemoScene and pop my prototype in to the list:
    upload_2023-8-24_11-42-14.png
    Then toggle through the "switch prototypes" it will correctly render
    upload_2023-8-24_11-43-5.png upload_2023-8-24_11-43-19.png
     
  45. Chunikus

    Chunikus

    Joined:
    Sep 5, 2020
    Posts:
    28
    So i've got some feedback, after using the asset for a couple of days.


    - I wasn't able to use packages, due to invalid compute shader cast errors until i right clicked the folder and did "remimport", deleting and importing from package manager didn't help. I have no clue why it's like that.
    - StartAnimation/Blend can only be run for main thread... would be nice to know beforehand, cause no errors hard to debug:)
    - Awake/Start/Update/Late update initialization race conditions. So i have one singleton that basically runs all my awakes/starts/updates on other systems and i control the order normally form top to bottom in the method. To incorporate this i had to rename awake/start/update methods in GPUI singletons and run them myself so i can control the order granularly. Kinda annoying to do it for every asset update going forward. Could be solved by having method renamed and having other component "GPUI initializator" that i can disable or remove, that would run the starts and awakes and updates inside the manager.

    - Baking animations should probably reset prefab. So i removed some exposed bones transforms, but they were still there in the prefab until i deleted GPUI components from prefab and rebaked prefab from scratch. Basically if it had this button would be nice. The same issue was with step one, i had non functional asset but it still made component prefab that didn't work at all, after fixing the asset folders, broken component remained and after debugging for a while i realized the whole prefab has to be nuked and reimported and will never fix itself.

    - I gave up on root motion with ai agents, dunno what bones to expose so it works the same way animator.rootPosition.

    - Sometimes baking animations gives logs to console about some memory leak from jobs system.

    - I miss obvious option to have instancing target my specified camera + editor camera if in editor mode. Making two singletons for these two cameras for both crowds and normal prefabs seems like unnecessary hassle.

    Overall documentation is amazing, i was able to implement shaders with amplify editor, i was explained difference between instancing and indirect instancing. Would be nice to have more examples how to use StartAnimation and Start animation blend... Thank you for this fantastic tool it must have been a ton of work ! I'll post review when i test it out in builds!
     
    GurhanH likes this.
  46. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    and thank you for the detailed feedback. We will look into these issues and your recommendations for future updates.
     
  47. Chunikus

    Chunikus

    Joined:
    Sep 5, 2020
    Posts:
    28
    Oh forgot one more important thing. Common use case. I save a game and want to load it and have the same animation state continue as it was. I mean good example in documentation or new method to get animation data wrapper / set animation data wrapper would be nice!.
     
  48. Chunikus

    Chunikus

    Joined:
    Sep 5, 2020
    Posts:
    28
    More questions :)

    Switching textures in materials.. is switching material api call only option currently? You can't make StructuredBuffer<Texture> but isn't it possible to give gpu array of textures to pick from? I'm using amplify editor..
     
  49. Chunikus

    Chunikus

    Joined:
    Sep 5, 2020
    Posts:
    28
    So there seems to be issue with transition time for

    Code (CSharp):
    1. public static void StartAnimation(GPUICrowdPrefab crowdInstance, AnimationClip animationClip, float startTime = -1.0f, float speed = 1.0f, float transitionTime = 0)
    So i'm not sure how it's supposed to work.

    Comments say this:


    /// <param name="transitionTime">(Optional) Time in seconds for smooth transition from the previous animation clips</param>

    or this

    // We also add a transition value of 0.5 for a smooth transition between idle and locomotion states.

    But it leads to this buggy behaviour. I always play animations with StartAnimation method like so :

    Code (CSharp):
    1.  public void TransitionAnimationToCurrentClipFromMainThread()
    2.     {
    3.         Debug.Log("requesting API to start animation clip name  "+ currentClipToInvoke.name + " start time -1 " + " animation speed " + currAnimationSpeed + " transition time  " + currTransitionTime );
    4.        
    5.         GPUICrowdAPI.StartAnimation(gpuAnimatorPrefabComponent, currentClipToInvoke, -1, currAnimationSpeed,
    6.             currTransitionTime);
    7.  
    8.         hasAnimationTransitionScheduled = false;
    9.     }
    And transition time is always 0.15f

    But for this sitting down animation it sometimes sits down instantly and sometimes plays intended 1s long animation clip...



    So is there a bug or i'm missing how it's supposed to be used. What i though it did is it blends to new animation clip i started for 0.15f seconds and after that new clip takes over.
     
  50. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    Yes you can not use a StructuredBuffer<Texture>. We usually handle texture variations with a texture atlas and a StructuredBuffer<float4> for assigning different UVs. Please see the TextureVariationDemo for an example usage and this documentation for adding variations to ASE shaders.

    It probably behaves differently because of the startTime = -1.0f parameter. When it is set to -1, the animation clip continues from where it was left. If you set the startTime to 0, then the clip will play from the beginning. That is why when you first call the StartAnimation method the character sits slowly, but when you call it again it starts from the middle of the clip where it is already sitting.