Search Unity

[RELEASED] GPU Instancer - Crowd Animations

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

  1. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    If you are able to separate the meshes, you might want to try the Has Optional Renderers option first. This will create multiple prototypes, but animator buffers are shared, so it might work.

    1- Variations are applied on all the materials of a prototype, but only the shader that uses the variation will be effected. So you need to use the variation shader on the submesh you want to be effected, and the rest can use a regular shader.
    2- Yes. There is also a demo called TextureVariationDemo inside Crowd Animations. You can use float/int values similar to the color variation example. But textures are a bit more complex since you can not use StructuredBuffer with textures. So the texture example uses an atlas texture and UV variation instead.
    3- You can only have a single MaterialPropertyBlock per draw call, so you can not use it for variations on instances.
    4- No. You can add properties to the block, but it will effect all instances. It will not create variations.
     
  2. FlightFight

    FlightFight

    Joined:
    May 29, 2017
    Posts:
    27
    Hi, how can I animate a rotating turret with GPUI?
    I have different animations for running looking forward, running looking right etc.
    When I blend between the different animations the turret changes size during the transition.
    Is there any way around this?
    Thanks for making this great tool.

     
  3. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    Looks like there is a problem with the matrix calculations. I can not say what is causing it without debugging it. Might be a float precision issue, a rigging issue or something else. If you can email us a sample project we can investigate it.
     
    FlightFight likes this.
  4. daoviettuan2002

    daoviettuan2002

    Joined:
    Nov 5, 2018
    Posts:
    9
    Hi, Can I change shader properties of prototype when run-time? Ex: change surface opaque to transparent.
    2. I use shader LUX URP "Lit extented uber" replace "URP Lit" shader but I cannot bake Animation Data. How to do fix it?

    I try add
    upload_2022-12-30_17-4-43.png


    3. Do you have a tutorial about
    Using a Custom Shader on the Character Models. Please help me.
    4. After I baked animation, the quality of the character is not the same as the original (the the left side), because the Occulusion Strength parameter not work (I think it always set 1) and the Metallic parameter always set 0. I try change it in ShadeGraph but not work. Pls help fix it for me.
    upload_2023-1-1_23-33-32.png

     
    Last edited: Jan 1, 2023
  5. ElSheriff

    ElSheriff

    Joined:
    Apr 12, 2014
    Posts:
    9
    I cannot seem to get a UV1 working with a custom ShaderGraph.

    Desired Effect: (Scene not in play mode)
    upload_2023-1-1_12-6-23.png

    Resulting Effect: (In Play Mode)
    upload_2023-1-1_12-7-23.png

    NOTE: Fireman is not setup with GPUI Crowd Animations

    Shader Graph: Modified provided Shader Graph Shader:
    upload_2023-1-1_12-11-26.png

    The Blood is found on UV1, and works. This is how the original shader works.

    However, UV1 does not seem to be active.
    Is there something special that I need to do to be able to access UV1. I read that UV2 and UV3 are used by the GPUI. So I don't see any conflict with UV1.

    -----
    Environment:
    Using: https://assetstore.unity.com/packag...-city-zombies-low-poly-3d-art-by-synty-131930
    Unity 2022.2.1f1
    Shader Graph: 14.0.4
    UPR: 14.0.4
     
  6. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    I'm getting the following when using Crowd Animations 1.1.4 and GPU Instancer 1.7.5

    Code (csharp):
    1.  
    2. System.InvalidCastException: Specified cast is not valid.
    3.   at GPUInstancer.CrowdAnimations.GPUICrowdAnimationBaker.AnimationBakerFinish () [0x0000e] in /Users/vincentli/Local/Collapse/Assets/GPUInstancer-CrowdAnimations/Scripts/Editor/GPUICrowdAnimationBaker.cs:506
    4. UnityEngine.Debug:LogError (object)
    5. GPUInstancer.CrowdAnimations.GPUICrowdAnimationBaker:AnimationBakerFinish () (at Assets/GPUInstancer-CrowdAnimations/Scripts/Editor/GPUICrowdAnimationBaker.cs:582)
    6. GPUInstancer.CrowdAnimations.GPUICrowdAnimationBaker:AnimationBakerUpdate () (at Assets/GPUInstancer-CrowdAnimations/Scripts/Editor/GPUICrowdAnimationBaker.cs:475)
    7. UnityEditor.EditorApplication:Internal_CallUpdateFunctions () (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorApplication.cs:359)
    8.  
    This is the offending line

    Code (csharp):
    1.  
    2.             _skinnedMeshAnimateComputeShader = (ComputeShader)Resources.Load(GPUICrowdConstants.COMPUTE_SKINNED_MESH_ANIMATE_PATH);
    3.  
    Not sure why the cast doesn't work. Any idea?
     
  7. GurhanH

    GurhanH

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

    Hi there,
    It looks like generated mesh does not use the UV1. Can you please try adding the following line of code and see if it fixes the issue?
    GPUICrowdUtility.cs after line 233 add:
    Code (CSharp):
    1. mesh.uv2 = originalMesh.uv2;
    It should look like this:
    Code (CSharp):
    1. mesh.normals = originalMesh.normals;
    2. mesh.tangents = originalMesh.tangents;
    3. mesh.colors = originalMesh.colors;
    4. mesh.uv = originalMesh.uv;
    5. mesh.uv2 = originalMesh.uv2;
    6. mesh.SetUVs(2, boneIndexes);
    7. mesh.SetUVs(3, boneWeights);
    Hi there,
    Most probably the Compute Shaders are not imported correctly. Please try right clicking and selecting Reimport on the GPUInstancer-CrowdAnimations/Resources/Compute folder.
     
    Abbrew likes this.
  8. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    Yep, doing Reimport on GPUInstancer and then Crowd Animations fixed it. Thanks!
     
  9. daoviettuan2002

    daoviettuan2002

    Joined:
    Nov 5, 2018
    Posts:
    9
    I fixed it, only change the Occlusion Map (From R to A). That will be OK,
    And About Matellic, I think your script have problem, I change in ShadeGraph defaul = 1, that be OK.
     
  10. finergames

    finergames

    Joined:
    Oct 15, 2016
    Posts:
    7
    Hey! Loving the asset, though took me some time to grok certain things with the API (and still not certain I do entirely lol).

    Not sure if it's an issue with GPUI, Unity, or "just the way things work," but I noticed doing command line builds with the "-nographics" arg caused issues with shaders (result was not seeing any GPUI objects -> logs seem inconsistent otherwise I'd post). Builds seem fine if not using that arg, though they do take slightly longer.

    Is this a known issue, or expected behaviour?
     
  11. nizhangmao

    nizhangmao

    Joined:
    Jan 19, 2019
    Posts:
    1
    Hello, I saw this error when I was baking an animation. When I browsed the forum records to find GPUI Crowd ASE Setup, I found that this file could not be opened because of a script error. Please help me to find out what caused this problem and how to fix it?

    Code (CSharp):
    1. System.InvalidCastException: Specified cast is not valid.
    2.   at GPUInstancer.CrowdAnimations.GPUICrowdAnimationBaker.AnimationBakerFinish () [0x0000e] in O:\Project\Survival\Assets\GPUInstancer-CrowdAnimations\Scripts\Editor\GPUICrowdAnimationBaker.cs:506
    3. UnityEngine.Debug:LogError (object)
    4. GPUInstancer.CrowdAnimations.GPUICrowdAnimationBaker:AnimationBakerFinish () (at O:/Project/Survival/Assets/GPUInstancer-CrowdAnimations/Scripts/Editor/GPUICrowdAnimationBaker.cs:582)
    5. GPUInstancer.CrowdAnimations.GPUICrowdAnimationBaker:AnimationBakerUpdate () (at O:/Project/Survival/Assets/GPUInstancer-CrowdAnimations/Scripts/Editor/GPUICrowdAnimationBaker.cs:475)
    6. UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
    7.  
     

    Attached Files:

  12. JRRReynolds

    JRRReynolds

    Joined:
    Oct 29, 2014
    Posts:
    192
    Is it possible to use the Crowd Animator in a multicam setup or do you have to resort to Mecanim? It seemed like the information from the Crowd Prefab was only being passed to one Crowd Manager/Animator and not the other one so animations were only playing for one screen.
     
  13. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    I'm currently using the No GameObject flow, but with the following modifications:
    • The Crowd Prefab Manager is attached to a GameObject and inside of a Prefab. The Prefab is instantiated at runtime. This has to be done since I'm using DOTS
    • Calls to UpdateVisibilityBufferWithNativeArray, StartAnimation, and InitializeWithMatrix4x4Array are done from inside of DOTS systems
    Now I'm getting the following error messages while running:

    Code (CSharp):
    1. Leaked BatchRendererGroup: Native object doesn't have a handle in the scripting domain. Potentially indicates a problem with domain load/unload.
    2. UnityEngine.Rendering.RenderPipelineManager:DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset,intptr,UnityEngine.Object,Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle)
    Any idea on if what I mentioned before is wrong, or if I'm doing something wrong elsewhere?

    Edit: you can ignore this. This seemed to be a problem with the Editor
     
    Last edited: Jan 8, 2023
  14. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    Hello, is it possible to enable/disable SkinnedMeshRenderer's meshes at runtime using the No GameObject Flow, and if so, could it be done through scripts rather than manual configuration in the Inspector?

    Also, the following documentation line "New prototypes will be defined automatically at runtime for the optional renderers." is concerning. Does that mean that if a prefab has 5 optional Renderers, then if 10,000 of them are randomized to have different combinations disabled and enabled, there will be a huge number of prototyped generated at runtime to account for all combinations?
     
  15. EgemenJP

    EgemenJP

    Joined:
    Oct 9, 2018
    Posts:
    5
    There seems to be difference with how Emissive Intensity affects brightness when using default HDRP lit shader but rendered using GPUI.
     
  16. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    Sorry for the slew of recent questions. This one should be the last for a while. If the following question's goal is possible, then feel free to ignore my previous questions this past week.

    Could the following setup be an alternative to enabling/disabling renderers with a No GameObject Setup? The goal is to simulate attachments like weapons, armor, and shields being randomized

    1. Have a normal rigged naked character with an animation (let's call the animation Walking). This will be the Character prototype. This character will also have special bones called ChestArmorAttachment, HelmetAttachment, RightHandAttachment, etc. that are included in the animations
    2. Have every single possible attachment piece like Montefortino Helmet, Lorica Hamata, Muscle Cuirass, Linothorax, Kopis Sword, Scutum Shield etc as their own prototypes. They will also be baked with the exact same animations as the Character prototype such as Walking, but they move with their respective attachments. For example, the Kopis Sword will move with the RightHandAttachment. As a result, when played, these attachments will seem to be possessed by a ghost, moving in mid-air
    3. If a character has, for example, a Montefortino Helmet, Lorica Hamata, and Kopis Sword, then, combined with the Character prototype, the resulting 4 animations will form an equipped character.

    I'm guessing that the total number of prototypes is "just" the total number of all unique attachments, plus the single naked character prototype. This might be better than having dozens or even hundreds of combinations of those attachments.

    Is this faster or slower than using a "Yes" GameObject Setup with Mechanim Animator and Bone GameObject exposed?
     
  17. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    It is expected behavior. GPUI will not work with "-nographics".

    Hi there,
    Unity sometimes does not import Compute Shader files correctly. Please right click and select Reimport on the GPUInstancer-CrowdAnimations folder and see if it solves the issue.

    Hi there,
    Animator data is not shared between managers so each manager works independently. Crowd Manager is not designed with multi-cam setup in mind, so many features will not work out of the box. I can not be specific since we did not make many tests with multi-cam setup, but it is something we will look into in the future.


    Hi there,
    By default, GPUI uses a replacement shader made with Shader Graph for the HDRP Lit shader. It is similar but not the same. So if there are differences, you can modify the Shader Graph properties to solve it.
    Shader is located under GPUInstancer-CrowdAnimations/Shaders/Crowd_Animations_LIT_SG.shader

    Hi there,
    You can not enable/disable SkinnedMeshRenderers with No GameObject Workflow since there are no GameObjects to enable/disable. Instead you modify the matrix array to add/remove instances.
    If a prefab has 5 optional Renderers, there will be 6 prototypes in total: 1 prototype for the original (e.g. base character) and 5 for the optional renderers (e.g. hair, clothes, etc.)

    If you mean "better performance" by "faster", then No-GameObjects in most cases will be faster. If you mean which will be faster to implement, it is usually easier and faster to implement using regular GameObjects.
    There are various ways to go at it, best is to try a simplified version and see which suits your needs. And make sure to check the Demos in the package and read the Best Practices for making better decisions.
     
    Abbrew likes this.
  18. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    Thank you! I've already managed to get a simplified version of the No GameObject Flow working with DOTS. Now I'd like to do attachments. Based on your two responses, in order to "attach" SkinnedMeshRenderers to a registered prefab prototype, I would add the attachment's prototype to some sort of list? Is there a demo that does this, or what would be the process of doing so?

    Edit: Is this as simple as adding a CrowdPrototype for each equipment piece, like sword, shield, chestplate, and more? And then baking them with the base Character's animation so that each equipment moves correctly relative to the character? Along with UpdateVisibilityBuffer, these equipment with move with the base Character as if they're one model? Would this cause any performance issues, or be misusing GPUInstancing?
     
    Last edited: Jan 9, 2023
  19. JRRReynolds

    JRRReynolds

    Joined:
    Oct 29, 2014
    Posts:
    192

    Thank you for looking into it. That would be quite a welcome future update. As you know, the performance difference between mecanim vs crowd animator is quite drastic.
     
    Last edited: Jan 10, 2023
  20. Nihil688

    Nihil688

    Joined:
    Mar 12, 2013
    Posts:
    503
    Hello,

    I've put in my prefabs, baked the animations and wrote the code. It all works perfectly on the editor but the moment I do a build only the presets appear, aka the ZomBear and ZomBunny which I've added to do some checks and debug the issue.

    GUIIssue.png

    I've moved prefabs in a Resources folder, nothing. Not sure if there's any place I need to add mine to be included in the build.
     
  21. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    The animations don't loop by default for the No GameObject Flow. I have the following verified:
    • AnimationClips have Loop Time and Loop Pose enabled
    • GPU Crowd Manager has baked the animations
    • In the GPU Crowd Manager inspector UI, isLooping is true for all animations
    • My code performs the same essential actions as the demo scripts
    Do I have to manually handle looping for No GameObject Flows?

    Edit: printing
    Code (CSharp):
    1. var clipData = animator.Instance.GetClipData(runtime.Instance, clip.Instance);
    2.                 Debug.Log(clipData.IsClipLooping() + " " + clipData.IsLoopDisabled());
    3.                
    shows that both isClipLooping and isLoopDisabled are true. I can't even manually set this by iterating through
    Code (CSharp):
    1.  var clipDatas = runtimeData.clipDatas;
    2.                 var numClipDatas = clipDatas.Length;
    3.                 for (var i = 0; i < numClipDatas; i++)
    4.                 {
    5.                     var clipData = clipDatas[i];
    6.                     clipData.isLoopDisabled = 0;
    7.                     clipData.isClipLooping = 1;
    8.                     clipDatas[i] = clipData;
    9.                 }
    What could be the root cause?

    Edit: Apparently this code block is the issue on GPUICrowdAnimationBaker:322
    Code (CSharp):
    1. if (previousClipDataList != null && previousClipList != null)
    2.                     {
    3.                         int previousClipIndex = previousClipList.IndexOf(animationClip);
    4.                         if (previousClipIndex >= 0 && previousClipDataList.Count > previousClipIndex)
    5.                             isLoopDisabled = previousClipDataList[previousClipIndex].isLoopDisabled;
    6.                     }
    Not sure when it was added, or how it's triggered by my current setup. Deleting that block makes the configuration in AnimationClip work
     
    Last edited: Jan 16, 2023
  22. LucasPignataro

    LucasPignataro

    Joined:
    Apr 11, 2019
    Posts:
    2
    Hello, I have a problem in which, when I build my project. I try to instantiate a vfx or transition animations with the GPU crowd manager event system and it doesn't work. It does not spawn the vfx, it does not make the transition, nothing.
    This error occurs only in the build.
    In the editor it works correctly. Any idea why this is happening?
    Basically, in the editor the event system works and in the build it doesn't.
     
  23. FlightFight

    FlightFight

    Joined:
    May 29, 2017
    Posts:
    27
    Hello Gurhan, I sent you an email a week ago. Did you receive it? Is the included repro project alright?
    Thanks for your support!
     
  24. Nihil688

    Nihil688

    Joined:
    Mar 12, 2013
    Posts:
    503
    fyi I sorted this by allowing read/write on the game objects. For some reason the error wasn't coming up at all and at some point it decided to which led me to do the fix. Hopefully this will help in the future but @GurhanH maybe it's interesting to investigate the error msg.
     
  25. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    Crowd Animations currently support attachments only with GameObjects out of the box. No-GO attachments is not a tested or supported feature, so I can not tell what would be needed for it. But we will look into it in the future.

    Looping should work the same way, there shouldn't be anything special for no-GOs. GPUICrowdAnimationBaker:322 is there to keep the same loop setting when your re-bake the animations.
    If there is an issue, please email us a bug report following this guide.

    Hi there,
    Please make sure that you are using the latest version of GPU Instancer and Crowd Animations by updating/importing them from the Package Manager. If the issue is still present with the latest versions, please email us a bug report following this guide.
     
  26. GGTECHENT

    GGTECHENT

    Joined:
    Apr 23, 2021
    Posts:
    2
    Hello!

    Is there anyone who tested this with a Nintendo Switch console?

    Do yo know if its compatible @GurhanH ?

    Thanks!
     
  27. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    Nintendo Switch is not supported because of Compute Shader limitations.
     
  28. GGTECHENT

    GGTECHENT

    Joined:
    Apr 23, 2021
    Posts:
    2
    :( we need to find other solution then

    thanks for your answer!
     
  29. Deiran

    Deiran

    Joined:
    Aug 6, 2014
    Posts:
    6
    Hey!
    How can I modify the base URP/Lit shader so that it works with Crowd Animations? I tried doing that myself with the "Using a Custom Shader on the Character Models" part of the wiki, but haven't been successful. It would be really useful if a URP/Lit shader was included in the package.

    upload_2023-2-15_10-21-44.png upload_2023-2-15_10-22-1.png

    It works out of the box with HDRP/Lit though, not sure what I'm doing wrong
     
    Last edited: Feb 15, 2023
  30. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    There is a replacement shader for URP/Lit shader that is automatically imported during first installation. When you first import GPUI from the Package Manager, it checks the installed packages to determine if it should use built-in, URP or HDRP. Make sure that you have URP package installed and then delete and re-install GPUI. You should see a Console log that says "GPUI detected Universal Render Pipeline." which means it will import the files for URP.
    If you were using HDRP or built-in when you first installed GPUI, there will be issues with demos and some shaders specific for the render pipeline will be missing.
     
    Deiran likes this.
  31. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    Hello, I saw the demo where you had 30,000 humanoid models animated in the same scene. The humanoid model seemed to have a decent triangle count. I'm wondering if lower triangle counts per animated mesh are less taxing on the GPU. For example, if the base "naked" prototype has only around 3000 triangles, and a bunch of "Attachment" prototypes like helmets, shields, clothing, armor are animated alongside it combining to say 6000 triangles, would this be around as taxing as a single prototype of 6000 triangles? I'd like to get an estimate of how this would scale. Since No-GameObject workflows with attachments are not supported, I'm doing a workaround where I animate the No-GameObject prototypes alongside its attachment prototypes. It's functional at the moment, but before I go all in I want to know if this scales well
     
  32. Mic_Emond

    Mic_Emond

    Joined:
    Nov 16, 2016
    Posts:
    45
    Hello, I have question concerning the weight of textures baked for animations.

    I have multiple different enemies (25 ish), that share a common base animator, with Animator Controller Overrides for specific animations. It all bakes well but I do run into the following "problems":

    1. The baked textures have a lot of repeated info between them. Some have the exact same set of animations. Is there a way to go around that? I'm guessing not really since the meshes don't have the same vertex indices?

    2. The output textures in my case are around 256MB "compressed" to RGBA16 SFloat (8192x4096). 512MB uncompressed. Which is A LOT. Is there any way to bring this number down? I can have around 25 different units moving around at one time, which if I'm correct, would mean 256MB x 25 (6.5GB ish) in ram at all times just for animation. It doesn't seem very sustainable. Would greatly appreciate any tip on how to bring this down without too much quality loss.

    EDIT: I should add. I know I can reduce the baked framerate. But right now @60fps it's pretty much the lowest I'm willing to go since this is a "next gen" title
     
    Last edited: Feb 17, 2023
  33. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    GPUI does not have a limit on triangles. The amount of triangles you can render with good performance depends on various things (Quality settings, Shaders etc.) but mainly on the hardware. You should test it on your target devices.
    To improve the performance, you can consider using simpler shaders (For example, if you have 10K vertices with 10K visible instances, the shader vertex method will have to run 100 million times every frame.) and LODs to reduce the amount of triangles for distant objects.

    Hi there,
    Crowd Manager does not bake the meshes/vertices but the bone transforms (position/rotation/scale of each bone every frame) to the texture. So if you have the same bone structure for multiple models, you can share the baked data between them.

    For example if you have 10 characters sharing animations and have the same bone structure like this:

    Character1
    ---SharedBoneStructure
    ---SkinnedMeshRendererForCharacter1

    Character2
    ---SharedBoneStructure
    ---SkinnedMeshRendererForCharacter2
    ...

    You can create a custom prefab for baking all of them like this:
    CombinedCharacterForBaking
    ---SharedBoneStructure
    ---SkinnedMeshRendererForCharacter1
    ---SkinnedMeshRendererForCharacter2
    ---SkinnedMeshRendererForCharacter3
    ...

    Make sure the CombinedCharacter has all the animations of all the combined characters.

    Then copy the Baked Animation Data of this prototype to other character prototypes (Character1, Character2, ...):
    upload_2023-2-20_15-53-57.png

    This way you can use one texture and baked data for all of these 10 prototypes which will save memory.
     
    Whatever560 and Mic_Emond like this.
  34. Mic_Emond

    Mic_Emond

    Joined:
    Nov 16, 2016
    Posts:
    45
    Great pro-tip! Thanks for the quick reply
     
  35. Mic_Emond

    Mic_Emond

    Joined:
    Nov 16, 2016
    Posts:
    45
    Is there any equivalent to the "OnAnimatorMove" function where I can access rootmotion deltas and use them/modify them ? (in the Crowd Animator workflow). I can't seem to find any mention of root motion in the docs other than the "Apply Root Motion" option on prototypes
     
  36. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    No. Root motion is calculated in a parallel Job (see ApplyCrowdAnimatorRootMotionJob in GPUICrowdAnimator.cs) and does not have any callback methods (since it would make it much slower).
    If you need a custom root motion implementation, one option is to copy and modify this Job and run your custom Job instead of the built-in one.
     
  37. Mic_Emond

    Mic_Emond

    Joined:
    Nov 16, 2016
    Posts:
    45
    I guess I don't really need to modify it. I just need the rootmotion data at the current frame (every frame). I know there's runtimedata.rootMotions, which is the data that is being passed to the job and technically contains the rootmotion info, but I'm not quite sure how to access this data properly?
    Looking at the job, it would seem to be something like:
    To get the positionDelta:
    Code (CSharp):
    1. rootMotions[clipData.clipStartFrame + clipFrame].motionMatrix.GetColumn(3)
    Not sure how to get only rotation separate from position since in the example it's either PosOnly or Both. Not sure where to go from here without more documentation on what values are expected to be / used. Might be my weak knowledge of matrixes that is preventing me from figuring it out.

    (while I'm here, some suggestions after implementing the tool in our project)
    It would be a nice to have to have a couple functions just to get whatever is happening in the moment (especially for debugging). Currently playing clip/name and time/frame, etc. There's no way to know when an animation is done playing, or

    Also, having clear accessors to the baked data, I could more easily kinda make my way around and see what the values are "supposed" to be for a specified animation frame. In my situation, I don't actually want the crowdAnimator to apply root motion. I want the rootMotion data that should be applied, then pass that to a pathfinding solution.

    Just something a little less abstract than a bunch of native arrays and matrix.
    Something like this would be great:
    Code (CSharp):
    1.  
    2. int clipFrame = crowdPrefab.GetCurrentClipFrame();
    3. string currentClip = crowdPrefab.GetCurrentClip();//could be AnimationClip or other
    4. RootMotion root = crowdPrefab.GetRootMotionData(currentClip, clipFrame);
    5. root.deltaPos;
    6. root.deltaRot;
    7.  
    I know most of these might not be possible due to optimization issues, but I figured, didn't hurt to ask.
    I'm kind of focusing on rootmotion in my examples here, but a clear way to access all the baked data for a specified clip and frame would be pretty awesome.


    EDIT (to add):
    If I understand correctly, it would also seems like only LOOPING animations (currentAnimatorData.y > 0) are allowed to apply rootmotion inside the crowd animator job. Is there a technical reason for this? You'd obviously want root motion on all animations that haven't been setup as baked in the animation import settings.
     
    Last edited: Feb 27, 2023
  38. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    You can use Matrix4x4.rotation to get the rotation quaternion:
    Code (CSharp):
    1. rootMotions[clipData.clipStartFrame + clipFrame].motionMatrix.rotation
    Thank you for the feedback. We will look into adding API methods to get data from the animator.
    "currentAnimatorData.y > 0" looks like a mistake, it should be "currentAnimatorData.y != 0".
     
  39. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    519
    Hi there,
    Thanks for the plugin, I'm using it in several places already.

    I'm trying to increase some performance. The issue is that I need attachments as some of my characters have hair. I still could work around this and try to merge the hair to the skin mesh, so that could be worked around. As you seem to say the animation data work on bone structure, so I guess I would not need to bake things again even if the skinning changed.

    With this I could then go for the no-gameobject workflow, as my 4k characters are really taking to much time to instantiate. However I'm using GPUICrowdAPI.StartAnimation as to change the individual or group of individual animation at runtime. I don't see how this api works on no-gameObject workflow as I have no direct access to individual GPUICrowdPrefabs.


    Am I missing something there ?
     
    Last edited: Mar 3, 2023
  40. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    Yes, you do not have access to GPUICrowdPrefabs when using No-GO workflow since there are no prefab instances. But you can still control the animations either by using the GPUICrowdAnimator or by modifying the internal NativeArrays directly. Both methods have a demo in the package called NoGameObjectsDemo and NoGameObjectsWithJobsDemo respectively.
     
    Whatever560 likes this.
  41. JRRReynolds

    JRRReynolds

    Joined:
    Oct 29, 2014
    Posts:
    192
    @GurhanH Was wondering if you've gotten a chance to take a look at split screen support yet?
     
  42. Mic_Emond

    Mic_Emond

    Joined:
    Nov 16, 2016
    Posts:
    45
    Hello,

    What is the expected way of starting conventional movement blends (ex: strafing/walking in 4 directions) with transitions?
    It seems that the "blend up to 4 animations" limit is also tied to transitions. So you can't StartBlend with the transitionTime parameter > 0 if you actually have 4 animations in the actual blend. (you can start it, but the transition is forced to 0 / no transition)
    Am I wrong ? This seems like a situation that would be needed in most 3D games

    EDIT:
    I guess I can determine in which quadrant I am and then I really only have to blend between 2 animations at most.

    Would still appreciate any tips or pointers on this for easier ways to handle that !
     
    Last edited: Mar 10, 2023
  43. Eternal-Vision

    Eternal-Vision

    Joined:
    Mar 1, 2022
    Posts:
    1
    Hello, I want to buy the (Crowd Animations Pack) but i have a few questions before I buy it.
    I am trying to simulate hundreds of zombie's in my game the ai need to have multiple hitboxes for the body parts, and when the ai die it should activate his ragdoll, i am just curious if the package support hitboxes for body parts after baking the animation i don't know if that is possible , also for the ragdoll, and does the pack support root motion, thank you.
     
  44. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    I made some tests with split screen setup. Unfortunately we will not be adding official split screen support at this point. The reason is that the base GPUI system does not support multiple cameras and we work around this problem by using multiple managers (see Using a Multiple Camera Setup). However with Crowd Animator, multiple managers becomes an issue since other than rendering there is also the animator data which gets quite complicated to manage with multiple managers.
    However depending on your use case, it might be possible to simply copy or use the same animator buffer for multiple managers which would allow you to use split screen. If you can email us a support request with a detailed description of your use case, I might be able to provide a workaround with some custom scripts.

    Hi there,
    Yes, the total number of animations that can be blend is 4. Since the transition is also a blend, it is also included in this limit. So you would be able to transition between 2 to 2 animations but not 4 to 4 animations.
     
  45. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    519
    Thank you very much, these where the right pointers, I now have a 5k jumping animated crowd popping in an instant and taking almost no perf to display.
     
  46. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    Hello, I'm getting the following error when following the steps at https://wiki.gurbu.com/index.php?ti...Using_a_Custom_Shader_on_the_Character_Models

    Code (csharp):
    1.  
    2. Shader error in 'Collapse/Toon': redefinition of 'SafePositivePow_half' at /Users/vincentli/Local/Collapse/Library/PackageCache/com.unity.render-pipelines.core@14.0.6/ShaderLibrary/Common.hlsl(685) (on metal)
    3. Compiling Subshader: 0, Pass: <Unnamed Pass 0>, Fragment program with <no keywords>
    4. Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_RGBM_ENCODING UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
    5. Disabled keywords: FOG_EXP FOG_EXP2 FOG_LINEAR GPUI_CA_BINDPOSEOFFSET INSTANCING_ON PROCEDURAL_INSTANCING_ON SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_FULL_HDR UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING _FOG _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN _SHADOWS_SOFT _TOON_RECEIVE_SHADOWS _TOON_VERTEX_LIT _VERTEX_COLOR
    6.  
    7.  
    The error is caused by including

    Code (csharp):
    1.  
    2.             #include "UnityCG.cginc"
    3.  
    at the beginning of a shader Pass. Some things to note: this is for a Subshader and HLSLPROGRAM instead of CGPROGRAM is used. Any idea on where I went wrong?

    Edit: it appears that if you're using URP, then "UnityCG.cginc" is replaced by
    Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl
    according to https://developer.arm.com/documenta...stom-shaders-to-the-Universal-Render-Pipeline. Should there be separate instructions for URP?
     
    Last edited: Mar 22, 2023
  47. Mic_Emond

    Mic_Emond

    Joined:
    Nov 16, 2016
    Posts:
    45
    Hello again,
    I've been digging deeper into this now, but I'm not sure how to approach this exactly or the limitations of it.

    What would be the proper way to create the "CombinedCharacter"?
    - Should I have one 3D model in the 3D software with all meshes skinned to the main "boneStructure" then export that and create the prototype from there?

    -Should I just straight up in unity take the MESH from different models, put them all in the same prefab and use that as a prototype? (I'm getting errors with this when baking obviously, since the skinning /bones information is missing on these meshes)

    What about models that have the same structure, but different scales and bone length ?

    Thanks
     
  48. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    My current Crowdanimations setup uses the following
    • No gameobject
    • Material overrides
    And attempts to render 4 different prototypes comprising a single character, each one 4500 times. Each prototype has a 15 FPS animation, and is only around 700 vertices. The Manager shows that there's only 4 draw calls in total. The material override uses a shader that accepts N Textures, and for each GPUI instance, a single integer representing which Texture in the TextureArray to use.

    Yet, the CPU utilization is huge, with the render thread taking around 35ms for "just" 18000 extremely low-poly meshes when I zoom out the camera to look at everything. In addition, Memory usage in total is hovering around 8GB, with around 4GB probably being used by GPU Crowd Animations. Occlusion Culling is enabled, and I've tried minimizing all other graphics settings.

    What else can I do to reduce the memory and GPU usage?
     
  49. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi there,
    Yes "UnityCG.cginc" is for the built-in shaders, you need the Core.hlsl for URP. We will look into adding separate instructions to the documentation.

    Hi there,
    As you also realized mesh needs to have the skinning/bones information, so you should set it up using the 3D software.
    Different scales and bone length will result in different transform data for the bones so they can not be combined.

    I highly doubt that 4GB is being used by Crowd Animations. It might be from the textures. But if you think it is the Crowd Animations, email us a sample project and we can investigate why.
    As for GPU performance, over 12M vertices with skinning might be too much for the GPU. You can try simplifying the shader, finding ways to reduce the vertices (e.g. LODs) and/or reduce the number of visible instances (e.g. culling). Please also note that culling is pointless (possibly even detrimental) when all the instances are visible (e.g. not outside of frustum or occluded by an object).
    Also from my experience, URP is slower compared to built-in when rendering high amount of vertices in most cases. But I do not know enough about their inner workings to say why. If you don't have to use URP, you can try testing the same setup in built-in and see if it changes anything.
     
  50. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    There's an incompatibility between URP, the latest ECS Entities Graphics package, and GPUI Crowd Animations. First, Entities Graphics pre-65 requires

    Code (csharp):
    1.  
    2. Entities.Graphics should be used with URP Forward+. Change Rendering Path on Universal Render Pipeline Asset_Renderer for best compatibility.
    3.  
    However, configuring this causes Crowd Animations to freeze every time it is accessed with baked models, or when it's empty but then you attempt to drag a MeshRenderer into it. Keeping the Rendering Path to Forward instead of Forward+ prevents this freeze.