Search Unity

[BETA RELEASE] GPU Instancer - Crowd Animations

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

  1. LouskRad

    LouskRad

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

    Thank you for the feedback. We will fix this issue in the next update. For now, you can move the following line in the GPUICrowdManager.cs to solve the problem:

    Remove Line 425:
    425: _lastAnimateTime = Time.time;

    and add it after line 168:
    168 : }
    169: _lastAnimateTime = Time.time;
    170: base.LateUpdate(); // GPUI core rendering
    171: }

    As for the ChangeMaterial method, there is currently no implementation for this in the package, but we will look into this.
     
    Last edited: Sep 3, 2019
  2. Mi_Ramon

    Mi_Ramon

    Joined:
    Oct 5, 2017
    Posts:
    2
    Hey there,
    thank you for creating this package, it's working very well for us so far!
    But we are also having some issues. These are the ones that haven't been mentioned in this thread, as far as I know:

    1. The "transitionTime" parameter of the GPUICrowdAnimator.StartAnimation() function does not work. We fixed this by adding the following to line 78 of GPUICrowdAnimator.cs:
    Code (CSharp):
    1. newClipStartTimes[3] = currentClipStartTimes[2];
    2. newClipStartTimes[2] = currentClipStartTimes[1];
    3. newClipStartTimes[1] = currentClipStartTimes[0];

    2. Sometimes the crowd prototype assets and the crowd settings asset enter a weird state, where Unity thinks the associated script could not be compiled, even though there are no compiler errors. This causes runtime errors, because those assets can no longer be loaded. This usually only happens once per team member and can be fixed permanently by reimporting the GPUInstancer folders. I'm not entirely sure about this, but I think this happens because all the Crowd script files have the "#if GPU_INSTANCER" compiler directive at the top of the file. So during the initial import of the plugin in a teammembers unity project, the assets are imported before the flag is set, so the script files are empty. And I guess unity is still confused even once the script files are recompiled with the flag enabled.
    If my guess is correct, you could fix this by adding dummy classes for those assets for when the flag is not set.


    3. This is the only important issue for us: Blending looks very odd when the blended poses differ too much. Heres a gif of what I'm talking about:
    blending_issue_02.gif
    Please ignore the shrek colors, I'm experimenting with material variants. :)
    Notice how her right arm shrinks as the animations transition. Will this be fixed?
     
  3. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    491
    Hi, I know you mentioned about mobile support in the future but is this something definitely coming or, just a possibility?
    I need to know so that I can pre-plan stuff. If it's coming within 4-5 months timeframe, I definitely include it in the plan.
    Assuming that it's coming, what would be the minimum required spec?
    Many thanks!
     
  4. Elyaradine

    Elyaradine

    Joined:
    Aug 13, 2015
    Posts:
    19
    Picked this up to test for a game we're currently working on. I've had a brief look and like the tools, and does a lot of neat things that our in-house implementation hadn't been lacking. Some things we've been missing that'd make this more complete:

    - Cross-fade animations,
    - add events to animations, and
    - attach objects to a CrowdAnimator object, to avoid still having an active Animator. (I dunno -- perhaps there's a way to pick a specific vertex or triangle, so that transforms that apply to it get applied to an attached object?)

    We can implement all of these manually, but they're things that seem to be preventing the package from feeling fully-fledged. The rest is looking pretty great! Handing off a bunch of stuff to compute shaders looks pretty rad!
     
  5. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    579
    Hi there, and thank you for your feedback.

    We will investigate issues 1 and 2 and add the necessary fixes to the package.

    For 3, we will investigate this issue also; however, it would help a lot if you can send us a sample package that shows this issue.
     
  6. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    579
    Hi there,
    the issue regarding mobile support is not one of implementation but rather one of performance. In comparison with the base GPUI package, Crowd Animations uses the GPU of the target platform even further with bone calculations, which could beat the purpose in low powered GPU systems such as mobile devices. We need to do further testing to answer your question, and we plan to start testing potential mobile strategies after CA is out of the BETA phase.
     
  7. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    579
    Hi there,
    and thanks for the feedback.

    If you mean animation transitions by "cross-fade animations", this is currently supported (up to 4 animations at a time).

    As for animation events and object attachment (in the crowd animator workflow), we are currently investigating potential implementations of these features, we will keep you updated.
     
  8. Elyaradine

    Elyaradine

    Joined:
    Aug 13, 2015
    Posts:
    19
    @LouskRad Oh great, thank you!

    I've been spawning things and being really impressed with how much I can throw at this! I've run into a snag, however -- for some reason I reach a cap of 10,000 and cannot spawn any more? In the demo I saw that there was a restriction to have 100 rows. Bypassing that restriction seems to cap the instance count at 10,900, after which there's massive lag.

    Can you tell me how to spawn even more instances? Is there a point at which additional instances becomes prohibitive or infeasible? (I realise this is likely dependent on hardware, but perhaps there's a maximum buffer size in the compute shaders or something?)

    [edit] It seems that animations loop regardless of what the "Loop Time" variable of the Animation Clips are. It would be useful if the vertex animation took that setting into account, and clamped their time instead of looping.
     
    Last edited: Sep 6, 2019
  9. growling_egg

    growling_egg

    Joined:
    Sep 2, 2012
    Posts:
    56
    I was working along and things were fine, then at one point I encountered this when I try to bake animation data and haven't been able to work around it:

    System.NullReferenceException: Object reference not set to an instance of an object
    at GPUInstancer.CrowdAnimations.GPUICrowdAnimationBaker.AnimationBakerStart () [0x002d4] in F:\Game\Assets\GPUInstancer-CrowdAnimations\Scripts\Editor\GPUICrowdAnimationBaker.cs:178

    I've deleted and re-imported the latest GPU Instancer and Crowd Animations plugins, but when I try to bake animations, it still fails. Unfortunately this log isn't enough info for me to debug it myself. Thanks for any tips!
     
  10. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    579
    Thanks!
    The Crowd Manager in the demo scene defines Extra Buffer Size to 10000, and initializes 900 initial instances - resulting in a 10900 cap. You can increase the slider there to increase this cap as well, but you can also use the API to manually register your instances instead of using the Auto. Add/Remove Instances feature without a limit.

    As for animation loop time, since Crowd Animator has no state machine, we decided that the default behavior would be better if animations were assumed to loop. We will look into adding an option to change this behavior.
     
    Elyaradine likes this.
  11. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    579
    Looks like the problem is related to a missing reference. Can you check the mesh references in your prefabs's skinned mesh renderer and make sure they exist?
     
  12. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    266
    any plans to support for 2018.2.7f1? :)
     
  13. Simunek

    Simunek

    Joined:
    Jul 15, 2016
    Posts:
    19
    Hi, I have a problem, I did nothing much in my project and GPUIcrowd stopped working, the crowd manager compiles, project compiles, but randomizer cannot be loaded and I cannot add prototypes (people)

    I reimported asset and upgraded to the latest versions of GPUI and GPUcrowd... and suggestions? :/ GPUI looks fine. Thanks!
     
  14. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    579
    CA currently works for versions 2017 LTS and up. However, we are officially supporting 2018.3 and up since we have plans to use new Unity features that can require a higher version. Also the Demo scenes are designed for the newer Unity versions.
     
  15. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    579
    I have replied to your mail on this subject, can you please reply back with details of warning/errors.
     
  16. BartekSalata

    BartekSalata

    Joined:
    Jan 23, 2014
    Posts:
    4
    So I'm using 2019.2 with the LW render pipeline and most things are working so far... except for the LOD "test animation" button and the LOD in game button on the built in crow animations scenes (specifically, I'm playing around with the navmesh one). All of the custom shaders that come with the demo scenes fallback to the error purple shader. How would I go about converting them to work on the LWRP?

    I kind of learn by using the demos/examples and this is kinda killing me. I have to manually convert all the standard shaders to LWRP (which makes them show up normally) but any custom shader that came with the demo scenes are just borked...

    Also with regards to ASE, is there a node for it... kind of how there is a node for shadergraph? (note, I haven't looked into what that node is for... but wondering nonetheless if one like it exists for ASE).
     
    Last edited: Sep 19, 2019
  17. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    579
    Hi there,
    and thank you for your feedback.

    The Animations Test shader currently does not have an LWRP version. The reason why GPUI does not come with LWRP and HDRP shaders for its demos and extra tools is that the LWRP and HDRP shaders are currently under constant change by Unity. We are providing essential shaders for GPUI to work, however we will provide provide the demo and tool shaders when Unity stabilizes the SRP shaders.

    Also, there is currently no node for ASE for setting up the shader with Crowd Animations, but this is in our roadmap and we will add this feature in a future update.
     
  18. BartekSalata

    BartekSalata

    Joined:
    Jan 23, 2014
    Posts:
    4
    Understandable, but could you help me out with modifying the LOD view shader to work at least, its very helpful for visualizing and, unlike the demo scenes.... its kinda a good tool to have for any debugging/tweaking situation.

    Glad to hear it, and looking forward to this : )
     
  19. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    579
    The LOD Debugger does not use a dedicated shader, but modifies the "_Color" property of the shader that the instances use for its effect.

    We will look into making this property parametric in the tool, so that you can use the color multiplier in your custom shaders instead of the "_Color" property. However, you can also modify the "_Color" strings (multiple) in GPUInstancerLODColorDebugger.cs to the property your shaders use for the same effect.
     
  20. BartekSalata

    BartekSalata

    Joined:
    Jan 23, 2014
    Posts:
    4
    OK cool... i just want to use the LWRP shader for it.. but it uses _BaseColor now
     
  21. Monil

    Monil

    Joined:
    Apr 24, 2012
    Posts:
    13
    Hello,
    I'm doing some tests on the animation events you've just implemented, how can I add a parameter (string, int, float, bool) to the function?
     
    Last edited: Sep 27, 2019
  22. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    579
    Hi there,
    currently event functions with parameters are not supported. We will look into adding parameters to the event function in a future update.
     
  23. Elyaradine

    Elyaradine

    Joined:
    Aug 13, 2015
    Posts:
    19
    Hi again!

    I started moving our internal animation system across to use Crowd Animations today. Here's a quick gif of it in action:


    In our existing system we've been using MaterialPropertyBlocks quite extensively, both for setting frame data for our animations (which, similar to your solution, were baked to textures), as well as allowing for other effects, like "getting electrocuted" or "burning up", etc.


    • Is there an existing way to do this at the moment? (i.e. have a material property that can have different values per instance. This might be for the life of the instane -- like some minor colour variation -- but might be major and change per frame -- like switching to an electrocuted state and back.)
    • I know I asked for this before, but it would be great if I could have animations optionally not loop, e.g. for things like death animations. (I'm currently considering working around it by having an event at the end of one animation to tell it to play another animation that has data that doesn't move, but it's not ideal.)
    • Being able to trigger events in animation is great! It seems to me that it would make sense to have these be settings under the prototype's settings themselves?
     
    Last edited: Oct 8, 2019
  24. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    579
    Hi there,
    you can take a look at the TextureVariationDemo we have added with the last update for an example of using variations with your crowd instances. The demo showcases texture variation, but you can adapt the same logic for using it with color variations. The fish in the demo use a single draw call:

    CA-Scr-MaterialVariations.png

    We are looking into no-loop animations in the Crowd Animator. For now, you can achieve this by setting the animation speed to zero at the end of your animation.

    As for the event settings location, thank you for your feedback. We will look into providing a custom editor for both these and the loop settings.
     
  25. Elyaradine

    Elyaradine

    Joined:
    Aug 13, 2015
    Posts:
    19
    Hi @LouskRad, thanks for your help!

    For some reason when I set the animation speed to zero at the end of the animation, I get some minor jittering going on.


    [edit] I've manually set the clip to a specific frame with the animation speed at zero, and that fixed that. I wonder if it was somehow between frames, so that it was alternating between one or another or something, but either way it's working now. Thanks anyway!

    [edit2] I've found that any vertex colours that are in my prefab mesh are lost in the instanced versions, so that if my shader relies on vertex colours those no longer work correctly. Is this a limitation in the instancing implementation, or can this be added?
     
    Last edited: Oct 11, 2019
  26. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    579
    Thanks for the feedback,
    There is a method called GenerateMeshWithUVs inside the GPUICrowdUtility class, which recreates the mesh before sending it to the GPU. You can add

    mesh.colors = originalMesh.colors;

    to that method to use your meshs' vertex colors. We will add this in the next update.
     
  27. Elyaradine

    Elyaradine

    Joined:
    Aug 13, 2015
    Posts:
    19
    Thanks again!

    --
    We've got a method for showing the outline of something that's been selected. We currently render the selected object using another camera with a shader that masks the object from the background, and then apply some blur-like post process to create the outline.

    We're currently using CommandBuffer.DrawRenderer() for drawing an individual thing (or group of things) to a different camera with a different material. Is there perhaps an easyish way to draw only a subset of meshes to another camera when they're being deformed with Crowd Animations?
     
  28. LouskRad

    LouskRad

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

    At this point I can't comment on an easy(ish) way to do this. We will look into providing an example on this.
     
  29. LordRobby

    LordRobby

    Joined:
    Apr 4, 2018
    Posts:
    1
    Hello,
    Nice product btw. :)
    I found out how everything works for what I need, except this one.
    How can I stop a CrowdAnimation at the end or don't let them loop, without changing the animation state?
    (For example, an attack or a dying animation)