Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[BETA RELEASE] GPU Instancer - Crowd Animations

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

  1. Nyphur

    Nyphur

    Joined:
    Jan 29, 2016
    Posts:
    30
    Hey, I'm having real trouble getting one of my shaders to work with GPUI Crowd Animations. It was originally created in Amplify Shader Editor and I edited it manually according to the instructions on the wiki. The GPUI Crowd Manager did accept it as a valid shader but animations don't play. When I hit "Test Animations" the animations do play but the model has a different shader on it, so I suspect I've missed something in my shader. Here's a copy of it, does anything jump out as wrong or missing?

    EDIT: For reference, I'm using the Crowd Animator type workflow, not Mechanim.

    Code (CSharp):
    1. Shader "Plant CA"
    2. {
    3.     Properties
    4.     {
    5.         _MainTex("Albedo", 2D) = "white" {}
    6.         _MetallicGlossMap("Metallic", 2D) = "white" {}
    7.         [Header(Translucency)]
    8.         _Translucency("Strength", Range( 0 , 50)) = 1
    9.         _TransNormalDistortion("Normal Distortion", Range( 0 , 1)) = 0.1
    10.         _TransScattering("Scaterring Falloff", Range( 1 , 50)) = 2
    11.         _TransDirect("Direct", Range( 0 , 1)) = 1
    12.         _TransAmbient("Ambient", Range( 0 , 1)) = 0.2
    13.         _TransShadow("Shadow", Range( 0 , 1)) = 0.9
    14.         _OcclusionMap("Occlusion", 2D) = "white" {}
    15.         _BumpMap("Normal", 2D) = "bump" {}
    16.         _EmissionMap("EmissionMap", 2D) = "black" {}
    17.         _DetailAlbedoMap("Detail Albedo", 2D) = "white" {}
    18.         _DetailNormalMap("Detail Normal", 2D) = "bump" {}
    19.         _Color("Color", Color) = (1,1,1,0)
    20.         _GlossMapScale("Glossiness", Float) = 1
    21.         _Translucence("Translucence", Float) = 1
    22.         _Transmission("Transmission", Float) = 1
    23.         _DetailNormalMapScale("Detail Normal Scale", Float) = 1
    24.         _BumpScale("Normal Scale", Float) = 1
    25.         _OcclusionScale("OcclusionScale", Float) = 1
    26.         _EmissionColor("EmissionColor", Color) = (0,0,0,0)
    27.         [HideInInspector] _texcoord( "", 2D ) = "white" {}
    28.         [HideInInspector] __dirty( "", Int ) = 1
    29.     }
    30.  
    31.     SubShader
    32.     {
    33.         Pass
    34.         {
    35.             ColorMask 0
    36.             ZWrite On
    37.         }
    38.  
    39.         Tags{ "RenderType" = "Opaque"  "Queue" = "Geometry+0" "IgnoreProjector" = "True" "IsEmissive" = "true"  }
    40.         Cull Back
    41.         CGPROGRAM
    42.         #include "UnityCG.cginc"
    43.         #include "./../GPUInstancer-CrowdAnimations/Shaders/Include/GPUICrowdInclude.cginc"
    44.         #pragma multi_compile _ GPUI_CA_BINDPOSEOFFSET
    45.         #pragma multi_compile_instancing
    46.         #pragma instancing_options procedural:setupGPUI
    47.         #include "UnityStandardUtils.cginc"
    48.         #include "UnityPBSLighting.cginc"
    49.         #pragma target 3.0
    50.         #pragma surface surf StandardCustom keepalpha addshadow fullforwardshadows exclude_path:deferred nofog
    51.         struct Input
    52.         {
    53.             float2 uv_texcoord;
    54.         };
    55.  
    56.         struct SurfaceOutputStandardCustom
    57.         {
    58.             half3 Albedo;
    59.             half3 Normal;
    60.             half3 Emission;
    61.             half Metallic;
    62.             half Smoothness;
    63.             half Occlusion;
    64.             half Alpha;
    65.             half3 Transmission;
    66.             half3 Translucency;
    67.         };
    68.  
    69.         uniform float _BumpScale;
    70.         uniform sampler2D _BumpMap;
    71.         uniform float4 _BumpMap_ST;
    72.         uniform float _DetailNormalMapScale;
    73.         uniform sampler2D _DetailNormalMap;
    74.         uniform float4 _DetailNormalMap_ST;
    75.         uniform sampler2D _DetailAlbedoMap;
    76.         uniform float4 _DetailAlbedoMap_ST;
    77.         uniform sampler2D _MainTex;
    78.         uniform float4 _MainTex_ST;
    79.         uniform float4 _Color;
    80.         uniform sampler2D _EmissionMap;
    81.         uniform float4 _EmissionMap_ST;
    82.         uniform float4 _EmissionColor;
    83.         uniform sampler2D _MetallicGlossMap;
    84.         uniform float4 _MetallicGlossMap_ST;
    85.         uniform float _GlossMapScale;
    86.         uniform sampler2D _OcclusionMap;
    87.         uniform float4 _OcclusionMap_ST;
    88.         uniform float _OcclusionScale;
    89.         uniform float _Transmission;
    90.         uniform half _Translucency;
    91.         uniform half _TransNormalDistortion;
    92.         uniform half _TransScattering;
    93.         uniform half _TransDirect;
    94.         uniform half _TransAmbient;
    95.         uniform half _TransShadow;
    96.         uniform float _Translucence;
    97.  
    98.         void vert(inout appdata_full v, out Input o)
    99.         {
    100.             GPUI_CROWD_VERTEX(v);
    101.             UNITY_INITIALIZE_OUTPUT(Input, o);
    102.             UNITY_SETUP_INSTANCE_ID(v);
    103.         }
    104.         float3 MyCustomExpression29( float3 DetailAlbedo , float3 Albedo , float3 Mask )
    105.         {
    106.             Albedo *= LerpWhiteTo (DetailAlbedo * unity_ColorSpaceDouble.rgb, Mask);
    107.             return Albedo;
    108.         }
    109.  
    110.  
    111.         inline half4 LightingStandardCustom(SurfaceOutputStandardCustom s, half3 viewDir, UnityGI gi )
    112.         {
    113.             #if !DIRECTIONAL
    114.             float3 lightAtten = gi.light.color;
    115.             #else
    116.             float3 lightAtten = lerp( _LightColor0.rgb, gi.light.color, _TransShadow );
    117.             #endif
    118.             half3 lightDir = gi.light.dir + s.Normal * _TransNormalDistortion;
    119.             half transVdotL = pow( saturate( dot( viewDir, -lightDir ) ), _TransScattering );
    120.             half3 translucency = lightAtten * (transVdotL * _TransDirect + gi.indirect.diffuse * _TransAmbient) * s.Translucency;
    121.             half4 c = half4( s.Albedo * translucency * _Translucency, 0 );
    122.  
    123.             half3 transmission = max(0 , -dot(s.Normal, gi.light.dir)) * gi.light.color * s.Transmission;
    124.             half4 d = half4(s.Albedo * transmission , 0);
    125.  
    126.             SurfaceOutputStandard r;
    127.             r.Albedo = s.Albedo;
    128.             r.Normal = s.Normal;
    129.             r.Emission = s.Emission;
    130.             r.Metallic = s.Metallic;
    131.             r.Smoothness = s.Smoothness;
    132.             r.Occlusion = s.Occlusion;
    133.             r.Alpha = s.Alpha;
    134.             return LightingStandard (r, viewDir, gi) + c + d;
    135.         }
    136.      
    137.  
    138.         inline void LightingStandardCustom_GI(SurfaceOutputStandardCustom s, UnityGIInput data, inout UnityGI gi )
    139.         {
    140.             #if defined(UNITY_PASS_DEFERRED) && UNITY_ENABLE_REFLECTION_BUFFERS
    141.                 gi = UnityGlobalIllumination(data, s.Occlusion, s.Normal);
    142.             #else
    143.                 UNITY_GLOSSY_ENV_FROM_SURFACE( g, s, data );
    144.                 gi = UnityGlobalIllumination( data, s.Occlusion, s.Normal, g );
    145.             #endif
    146.         }
    147.  
    148.         void surf( Input i , inout SurfaceOutputStandardCustom o )
    149.         {
    150.             float2 uv_BumpMap = i.uv_texcoord * _BumpMap_ST.xy + _BumpMap_ST.zw;
    151.             float2 uv_DetailNormalMap = i.uv_texcoord * _DetailNormalMap_ST.xy + _DetailNormalMap_ST.zw;
    152.             o.Normal = BlendNormals( UnpackScaleNormal( tex2D( _BumpMap, uv_BumpMap ), _BumpScale ) , UnpackScaleNormal( tex2D( _DetailNormalMap, uv_DetailNormalMap ), _DetailNormalMapScale ) );
    153.             float2 uv_DetailAlbedoMap = i.uv_texcoord * _DetailAlbedoMap_ST.xy + _DetailAlbedoMap_ST.zw;
    154.             float3 DetailAlbedo29 = tex2D( _DetailAlbedoMap, uv_DetailAlbedoMap ).rgb;
    155.             float2 uv_MainTex = i.uv_texcoord * _MainTex_ST.xy + _MainTex_ST.zw;
    156.             float3 Albedo29 = ( tex2D( _MainTex, uv_MainTex ) * _Color ).rgb;
    157.             float3 temp_cast_2 = (1.0).xxx;
    158.             float3 Mask29 = temp_cast_2;
    159.             float3 localMyCustomExpression29 = MyCustomExpression29( DetailAlbedo29 , Albedo29 , Mask29 );
    160.             o.Albedo = localMyCustomExpression29;
    161.             float2 uv_EmissionMap = i.uv_texcoord * _EmissionMap_ST.xy + _EmissionMap_ST.zw;
    162.             o.Emission = ( tex2D( _EmissionMap, uv_EmissionMap ) * _EmissionColor ).rgb;
    163.             float2 uv_MetallicGlossMap = i.uv_texcoord * _MetallicGlossMap_ST.xy + _MetallicGlossMap_ST.zw;
    164.             float4 tex2DNode2 = tex2D( _MetallicGlossMap, uv_MetallicGlossMap );
    165.             o.Metallic = tex2DNode2.r;
    166.             o.Smoothness = ( _GlossMapScale * tex2DNode2.a );
    167.             float2 uv_OcclusionMap = i.uv_texcoord * _OcclusionMap_ST.xy + _OcclusionMap_ST.zw;
    168.             o.Occlusion = ( tex2D( _OcclusionMap, uv_OcclusionMap ) * _OcclusionScale ).r;
    169.             float3 temp_cast_6 = (_Transmission).xxx;
    170.             o.Transmission = temp_cast_6;
    171.             float3 temp_cast_7 = (_Translucence).xxx;
    172.             o.Translucency = temp_cast_7;
    173.             o.Alpha = 1;
    174.         }
    175.  
    176.         ENDCG
    177.     }
    178.     Fallback "Diffuse"
    179. }
     
  2. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    455
    Hi again,

    Yeah the main use case I'm thinking of is for hitboxes on NPCs.

    Here's a screenshot of a prototype that I'm making to test CityGen3D compatibility with a variety of assets, as well as showcasing CityGen3D in a game environment.
    It uses GPU Instancer Crowd Anims alongside Opsive Ultimate Character Controller (for player) and A* Pathfinding Project for multithreaded AI.
    The scene is a 1km part of London generated automatically by CityGen3D, and thanks to your asset and Aron's amazing A* Pathfinding, I'm getting over 1000 NPCs running around it, which is lots of fun!

    bad_aim.png

    As mentioned previously, ideally I want to be able to differentiate between head and body collisions (to deal different damage amounts depending on where weapons hit).
    I've not looked that deeply in the Instancing code yet, but is it possible to identify what frame is being played back of the current animation?

    If so, I'm wondering if some sort of solution for the Crowd Anims workflow could be found whereby the bone transforms are stored when baking the anims and then looked up and applied at run-time for accurate hitbox collision tests on Crowd Anim NPCs.

    As I say, I've no idea if that's feasible or if any such solution would end up being too slow, but I just wanted to give a bit more detail about an example use case to keep in mind, as you said you were looking into possible applications and solutions to this.

    Thanks again for a great asset!
     
  3. Nyphur

    Nyphur

    Joined:
    Jan 29, 2016
    Posts:
    30
    If it's a hitscan weapon for a game with thousands of enemies, one highly scalable solution for targeted hits would be to render a special data frame out to a rendertexture when the weapon is fired and then design an instanced shader that encodes the information you want in the colour. For example, you could use the combined red and green channel to encode the instance number (max of 65,535) and then use the blue channel to encode hit location from a texture.

    The main disadvantage of this technique is that it requires an additional draw call to draw the special frame, but you can mitigate that by only drawing it on frames when the weapon fires and limiting the camera area and shader complexity. It would also need some modification to allow you to fire through-shots.

    The advantages are that it's pixel-perfect, scales to bajillions of enemies, and completely eliminates all need for collision detection or rays. You could also look up adjacent pixels in the data texture to add a kind of soft auto-aim or create a hitscan weapon with a cone of effect like a shotgun. I used the technique for a previous game I made, admittedly I built my own engine for that game but the technique should still work in Unity and should work with GPU Instancer.
     
    LouskRad and CityGen3D like this.
  4. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    455
    Thanks for this insight, certainly gives me some food for thought.
    I'd love to see an integrated solution like this in GPU Instancer Crowds in future, because a fast hitbox detection system combined with the already super fast rendering, would be great to see and would extend the usability of the system much further.
     
  5. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    At first glance the issue might be the order in which you do the instancing setup:

    void vert(inout appdata_full v, out Input o)
    {
    GPUI_CROWD_VERTEX(v);
    UNITY_INITIALIZE_OUTPUT(Input, o);
    UNITY_SETUP_INSTANCE_ID(v);
    }

    should be:

    void vert(inout appdata_full v, out Input o)
    {
    UNITY_SETUP_INSTANCE_ID(v);
    GPUI_CROWD_VERTEX(v);
    UNITY_INITIALIZE_OUTPUT(Input, o);
    }

    because the crowd vertex setup function depends on the instance IDs.
     
  6. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    We are working on using async readback on the bones for this, and testing the solution for performance. It looks like this solution will require a job system and burst compiler to get the most out of it. But there will still be some performance impact caused by the readback and applying the translation data back to the transforms.

    This will allow for using colliders (and any game object) attached to the bones in the Crowd Animator workflow; but to clarify we have no plans for developing a further improved hitbox detection system.
     
    CityGen3D likes this.
  7. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    455
    Thanks for the info, it sounds very promising.
    I'll keep an eye out for further developments in this area.
     
  8. OrthrusOliver

    OrthrusOliver

    Joined:
    Nov 7, 2017
    Posts:
    39
    Hi, I'm having some issues instantiating Crowd prefabs from an Asset Bundle.
    When dragged into the scene, or spawned from a reference they are fine, however if I use our normal workflow of spawning from Asset Bundles, first they do not register automatically, then I follow what I think is the correct workflow (or close to?)

    Code (CSharp):
    1. GPUICrowdPrefab prefabInstance = SceneObject.GetComponent<GPUICrowdPrefab>();
    2.         GPUICrowdManager gpuiCrowdManager = GameObject.FindObjectOfType<GPUICrowdManager>();
    3.         if ((GPUInstancerPrefabManager)GPUInstancerManager.activeManagerList.Find(manager => manager.prototypeList.Contains(prefabInstance.prefabPrototype)) == null)
    4.         {
    5.             Debug.LogWarning("Not in ActiveManager");
    6.          
    7.             gpuiCrowdManager.DefineGameObjectAsPrefabPrototypeAtRuntime(SceneObject, true);
    8.             GPUInstancerAPI.InitializeGPUInstancer(gpuiCrowdManager);
    9.            
    10.             Debug.Log($"Added Prefab to Runtime and Initialised {gpuiCrowdManager.prefabList.Count}");
    11.  
    12.         }
    13.  
    14.         GPUInstancerAPI.AddPrefabInstance(gpuiCrowdManager, prefabInstance);
    I see the Assets correctly added to the Manager in Scene
    upload_2020-6-18_0-14-56.png
    (Doubled up because I don't clear the prefabs present in the scene already)

    However, I then receive this error every frame
    Any thoughts or help much appreciated.
     
  9. mau_iida

    mau_iida

    Joined:
    Apr 2, 2020
    Posts:
    5
    Hi, I have updated to latest version form GPUI 1.4.0 and GPUICrowd 0.93 with my current project.
    Then the GPUICrowdPrefab.crowdAnimator got lost, it always been to null.
    I have tried to rebake the animations, and delete the prototype and add them again. it just gets the same result.
    Do you have any idea about this?
     
  10. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    Hi there,

    the method DefineGameObjectAsPrefabPrototypeAtRuntime is designed for the base GPUI and currently it is not tested with Crowd Animations. It might be that additional steps are necessary to make it work with handling the baked animation data. We will take a look at this, but for now you can debug and see what data is missing and set them manually.
     
  11. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    Hi there,

    It might be that once you updated the packages and re-baked the animations, the selected workflow in your manager has switched to the Mecanim Workflow. Please make sure the Crowd Manager indicates that you are using the Crowd Animator workflow and see if this helps.
     
  12. Korsigon

    Korsigon

    Joined:
    Oct 6, 2014
    Posts:
    14
    I'm using the Crowd Animator type workflow and it's all fine until my baked right turn and left turn animations get the sheep stretched out. The faster the sheep turn , the faster the sheep grows and never stops growing. All other animations are okay. There's no issue when using the Mecanim Animator workflow. What could be wrong? Thanks.
    Note: The instanced sheep are from a single prototype. The baked animation gets stretched in the x-z plane. The height remains the same.

    ExpandingBakedAnimation.png
     
  13. DrDraxi

    DrDraxi

    Joined:
    Sep 6, 2015
    Posts:
    3
    Hi,
    I'm making a military strategy game with VR support.
    I'm using optional renderers for weapons on the soldiers. (1 skinned mesh renderer weight painted to the hand for each weapon).

    Issue #1
    When trying to use transitions in the Crowd Animator workflow the weapons are getting delayed by 1 animation.

    For example when I set the animation to run and then set it to crouchwalk, the soldier would transition perfectly from running to crouchwalking but the weapons would keep doing the running animations (floating near the soldier's head).

    I also found the same issue on the optional renderer demo. When I change the GPUICrowdAnimatorRandomizer script, by adding the transitionTime parameter to the StartAnimation method, limbs of the bunnies would start doing the same things as the soldier's weapons.
    Video:


    Issue #2
    When changing between animations the weapons sometimes jump to a different soldier so some of them have no weapons and some have multiple weapons flying next to them. They are playing the animation of the soldiers that are supposed to hold them but they appear at different soldier's transform.

    Each soldier has a script with methods to:
    - change weapon (turn off the active weapon gameobject and turn on the other)
    - change animation by using the GPUI Crowd API

    and there is coroutine that uses these methods and goes through some animations.
     
  14. mau_iida

    mau_iida

    Joined:
    Apr 2, 2020
    Posts:
    5
    Hi, still have the issue.
    Actually the Instance hasn't been created..

    Any idea why GPUInstancerPrefabManager.Awake() won't be called when I play on Editor? but when I stop Awake() is called from editor script. In our project, we have create a prefab for the GPUIManager, and use the reference in the scene. Not sure why the v1.4.0 could work well.
     
  15. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    Thank you for the feedback.

    This could be related to the model's rig. If you can email us a sample project so we can investigate this issue.

    Thank you for the feedback.

    We have not tested the optional renderers feature in such use cases. We will look into these and provide the necessary fixes in a future update.

    It might be related to the new Unity editor features that are under the Project Settings -> editor:

    upload_2020-7-3_19-4-10.png
     
  16. KD_W

    KD_W

    Joined:
    Feb 9, 2015
    Posts:
    4
    Hi is there a way to bake animation which meshes are inside joints and use animation event to hide and display them?
    Capture.PNG
     
  17. growling_egg

    growling_egg

    Joined:
    Sep 2, 2012
    Posts:
    76
    Hey, thanks for creating this wonderful tool!

    I'm still working my way through documentation and examples, but is it the recommended practice to have one separate gameobject/script that handles all the changes to instance animations, as opposed to having a script on each character that handles the transitions individually? I'm hoping to do something similar to what you did in the navmesh demo scene, where I have a bunch of simple characters who just need to be able to move around.
     
  18. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    Hi everyone,

    Crowd Animations v0.9.5 is now available on the Asset Store. With this version, there will be some important changes to GPUI that you can read from this forum post.

    Unity versions: To support the new and changing features of Unity, new Crowd Animations versions from v0.9.5 on will now only officially support Unity 2019.1.10 and later versions. The latest version before this (v0.9.4) will still be available to download and you can use it for Unity versions before 2019.1.10.

    Async Bone Updates: This version brings support for attachment object via async bone updates for the Crowd Animator workflow. Please check the wiki for further information.

    Important: This version requires GPU Instancer v1.4.2 or later. Please note that all animations need to be re-baked after this update. Please also make sure to backup your project if you are updating from a previous version of Crowd Animations.

    Here is the full changelog for CA v0.9.5:

    New: Added Async Bone Updates feature for Crowd Animator workflow
    New: Added Assembly Definition files
    New: Added Depth Normals shader to be able to use post processing effects like Ambient Occlusion in Forward Rendering mode

    Fixed: Transitions not reaching to the end weights in some cases
     
  19. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    Hi there,
    Crowd Animations only bakes Skinned Mesh data, and not data for attached Meshes. If you are using the Mecanim Animator workflow, you can simply enable/disable the game objects that are attached to your bones. If you are using the Crowd Animator workflow, you can now (with CA v0.9.5) use Async Bone Updates for your attached objects.

    Handling your crowd from a single script would generally be more ideal since you will only use a single Update loop instead of per character. This will also result in a more memory efficient solution.
     
    growling_egg likes this.
  20. growling_egg

    growling_egg

    Joined:
    Sep 2, 2012
    Posts:
    76
    Appreciate the quick response and thorough documentation.

    FYI, I stumbled upon a small typo just now in NavMeshDemoSceneController.cs, I believe "SpawnLoacation" was meant to be "SpawnLocation", though it doesn't affect anything functionally and I had no trouble following what to do.
     
  21. OrthrusOliver

    OrthrusOliver

    Joined:
    Nov 7, 2017
    Posts:
    39
    Hi, I sent a support request email about this and haven't heard back.

    Is there a better process I should be following in order to spawn gameobjects (that have already been baked, then added to an Asset Bundle) to work with Crowd Animations?
     
  22. growling_egg

    growling_egg

    Joined:
    Sep 2, 2012
    Posts:
    76
    I'm not the app developer but if you're only wanting to spawn pre-baked GPUICrowdPrefabs, I've had a lot of luck following the NavMeshCrowdDemo.cs (or something along those lines), it's the example where the chomper creatures navigate to where you click on the ground. Specifically check out the AddAgents() method for inspiration. I hope that's helpful, and sorry if I misunderstood your question.

    EDIT: as for Asset Bundles, I haven't done it myself but I'd think if you loaded the crowd prefab into memory before trying to spawn with the crowd manager, you should be okay.

    EDIT 2: One other thing is to make sure your crowd manager has auto-registering new instances enabled, as it's disabled by default.
     
  23. OrthrusOliver

    OrthrusOliver

    Joined:
    Nov 7, 2017
    Posts:
    39
    So looks like I've resolved this.
    Not sure if I was overthinking or misunderstanding, and still not totally sure this is the correct way, but now I load in the Asset from the Bundle that has had its Animation already baked, get the GPUICrowdPrototype from the GPUICrowdPrefab component on the Asset, add that directly to the GPUICrowdManager.prototypeList, and finally disable and then enable the Manager component.

    I'm sure there must be a better way of doing this, or maybe this is just the way to make it work at runtime since it's still Beta?

    So my test code looks something along these lines.
    upload_2020-7-12_16-49-30.png

    Thanks for the tip GrowlingEgg, wasn't directly helpful, but it did lead me to delve a LOT more into the code to figure out the secret sauce. It's wild and whacky and just seems to not be directly/seamlessly supported at the moment, but the workaround works (so far)
     
    growling_egg likes this.
  24. OrthrusOliver

    OrthrusOliver

    Joined:
    Nov 7, 2017
    Posts:
    39
    Run into another issue now unfortunately. Need to be able to turn off Receiving Decals in the HDRP (7.3.1) Material.
    We had to switch to a pure HDRP Lit for the Material as our custom Shadergraph Shader wasn't being recognised as being able to be used for GPU Instancing (although.. Unity said it was?).
    On the Material we can disable Receiving Decals, but when using the Instanced animated Crowds, they receive decals.

    Any help on this would be very much appreciated.
     
  25. pierre92nicot

    pierre92nicot

    Joined:
    Aug 21, 2018
    Posts:
    39
    Hi, I have errors when I enter play mode :
    First

    ArgumentException: An item with the same key has already been added. Key: -214092133
    System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <e1319b7195c343e79b385cd3aa43f5dc>:0)
    System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <e1319b7195c343e79b385cd3aa43f5dc>:0)
    GPUInstancer.CrowdAnimations.GPUICrowdUtility.SetAnimationData (GPUInstancer.CrowdAnimations.GPUICrowdRuntimeData runtimeData) (at Assets/GPUInstancer-CrowdAnimations/Scripts/Core/Static/GPUICrowdUtility.cs:67)
    GPUInstancer.CrowdAnimations.GPUICrowdRuntimeData.InitializeData () (at Assets/GPUInstancer-CrowdAnimations/Scripts/Core/DataModel/GPUICrowdRuntimeData.cs:37)
    GPUInstancer.GPUInstancerUtility.InitializeGPUBuffer[T] (T runtimeData) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:130)
    GPUInstancer.GPUInstancerUtility.InitializeGPUBuffers[T] (System.Collections.Generic.List`1[T] runtimeDataList) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:30)
    GPUInstancer.GPUInstancerPrefabManager.InitializeRuntimeDataAndBuffers (System.Boolean forceNew) (at Assets/GPUInstancer/Scripts/GPUInstancerPrefabManager.cs:184)
    GPUInstancer.CrowdAnimations.GPUICrowdManager.InitializeRuntimeDataAndBuffers (System.Boolean forceNew) (at Assets/GPUInstancer-CrowdAnimations/Scripts/GPUICrowdManager.cs:345)
    GPUInstancer.GPUInstancerManager.OnEnable () (at Assets/GPUInstancer/Scripts/Core/Contract/GPUInstancerManager.cs:204)
    GPUInstancer.CrowdAnimations.GPUICrowdManager.OnEnable () (at Assets/GPUInstancer-CrowdAnimations/Scripts/GPUICrowdManager.cs:107)

    and this one looping

    NullReferenceException: Object reference not set to an instance of an object
    GPUInstancer.CrowdAnimations.GPUICrowdManager.UpdateAnimatorsData (GPUInstancer.CrowdAnimations.GPUICrowdRuntimeData runtimeData) (at Assets/GPUInstancer-CrowdAnimations/Scripts/GPUICrowdManager.cs:485)
    GPUInstancer.CrowdAnimations.GPUICrowdManager.LateUpdate () (at Assets/GPUInstancer-CrowdAnimations/Scripts/GPUICrowdManager.cs:257)

    There is no error in the GPUICrowdManager when I select a prototype.
    I use the mecanim workflow, standard shader and unity 2018.4, the animation are baked and all demo scenes work.
    I have tried to delete GPUI and CrowManager before reimporting GPUI first then CrowManager but without success.
     
    Last edited: Jul 16, 2020
  26. KD_W

    KD_W

    Joined:
    Feb 9, 2015
    Posts:
    4
    Async Bones option is causing memory leaking.
     
  27. niflying

    niflying

    Joined:
    Jul 11, 2012
    Posts:
    75
    I find that the animation not the same as the original.
    Check this out please

    upload_2020-7-18_22-38-36.png

    You could see that the original one is more smoother than others.
    I've change the material but nothing changed.
    upload_2020-7-18_22-39-40.png

    Please help.
     
  28. DrDraxi

    DrDraxi

    Joined:
    Sep 6, 2015
    Posts:
    3
    Hi,
    the new Async Bone Updates work great! It solved my issue with optional renderers. (which I think you should still look into because you can't really use transitions with optional renderers right now)

    I have a question.
    Would it be any more efficient to have an option to update only some bone transforms like you can do with exposing mecanim bones? I feel like it's wasting performance by updating all transforms and not only the ones I need. (for example right hand for holding stuff)
     
  29. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    Thank you for the feedback.
    Currently Crowd Animations does not offer a shader graph node for custom shaders. As for always receiving decals on the supplied lit shader, we will investigate this.

    Hi there,

    CA holds clips and states in the dictionary that you get the error from. It looks like for some reason, a state (or a clip) is not unique when being added to the manager. We can investigate this issue if you send us a sample project showing this.

    If you can tell us the details, we can investigate this issue.

    Hi there,

    We will investigate this, can you please tell us which Unity and HDRP versions you are using?

    Thank you for your feedback.
    We will do more tests and improvements on this feature for the following updates.
     
    pierre92nicot likes this.
  30. OrthrusOliver

    OrthrusOliver

    Joined:
    Nov 7, 2017
    Posts:
    39
    Thanks, if there's any way that the decals issue could be fixed ASAP, that'd be great. Looming deadline I'm afraid
     
  31. pierre92nicot

    pierre92nicot

    Joined:
    Aug 21, 2018
    Posts:
    39
    Hi, I have renamed some redundant animator state and now I have no more errors.
    But now I have this log looping :

    GPUI Mecanim Animator can not find state: UnityEngine.AnimatorStateInfo
    UnityEngine.Debug:Log(Object)
    GPUInstancer.CrowdAnimations.GPUIMecanimAnimator:UpdateDataFromMecanimAnimator(GPUICrowdRuntimeData, Int32, Animator, List`1) (at Assets/GPUInstancer-CrowdAnimations/Scripts/Core/AnimatorWorkflow/GPUIMecanimAnimator.cs:27)
    GPUInstancer.CrowdAnimations.GPUICrowdManager:UpdateAnimatorsData(GPUICrowdRuntimeData) (at Assets/GPUInstancer-CrowdAnimations/Scripts/GPUICrowdManager.cs:485)
    GPUInstancer.CrowdAnimations.GPUICrowdManager:LateUpdate() (at Assets/GPUInstancer-CrowdAnimations/Scripts/GPUICrowdManager.cs:257)
     
  32. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    107
    Hi,

    The "Bake animations" button is broken in Unity 2020.1 ! Probably due to the new Editor Progressbar implementation in Unity 2020...
     
  33. OrthrusOliver

    OrthrusOliver

    Joined:
    Nov 7, 2017
    Posts:
    39
    Any progress on this one?
     
  34. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    It seems that I need to clarify a point. When CA detects that you use the HDRP Lit material on a skinned mesh, it uses its own shader when rendering the mesh. This shader however is a lot more limited that the original Lit shader, and among other things, decals are also not supported by it.

    However, In the next update we will add a ShaderGraph node for crowd animations which will allow you to use your custom ShaderGraph shaders with it. For convenience, I will attach the node here so that you don't have to wait the update to use it.

    You can use the node as follows:

    image_2020_07_28T01_01_06_028Z.png

    For this to work with your existing Crowd Animations, however, you need to make the following changes in the GPUICrowdUtility.cs file:

    Line 373:
    return originalShaderText.Contains("GPUICrowdInclude.cginc") || originalShaderText.Contains("GPUI Crowd Setup");
     

    Attached Files:

  35. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    We can't replicate this in our tests. Please check if any additional packages you might be using is causing this issue.
     
  36. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    Hi everyone,

    I just wanted to let you know that the GPU Instancer team will be on a summer break until September 1st. We will be answering all the questions and support requests after the break.
     
    marcmantraunity likes this.
  37. marcmantraunity

    marcmantraunity

    Joined:
    May 31, 2014
    Posts:
    21
    Hi @LouskRad I'm trying to add the shader code inside my custom shaders done using Amplify and I can't find the solution. GPU Crowd always alert me can't find a correct shader and it try to change the shader. The system goes well using your standard shader, but I can't find a solution using ASE.
    I'm trying on built-in render pipeline, unity 2019LTS and ASE 1.83, I follow step by step but seems I miss something I can't find.
    Is it correct? Thanks in advance

    upload_2020-7-31_19-5-30.png
     
  38. marcmantraunity

    marcmantraunity

    Joined:
    May 31, 2014
    Posts:
    21
    Another update which show me no animation and albedo, black result. But seems to be better as I'm using vertex and normals...

    upload_2020-8-5_12-40-34.png
     
  39. OrthrusOliver

    OrthrusOliver

    Joined:
    Nov 7, 2017
    Posts:
    39
    Huge thank you for this! It's working great
    Hope you all have a good break.
     
unityunity