Search Unity

Mesh Animator - Highly efficient animated crowds. For support, please use email.

Discussion in 'Assets and Asset Store' started by jschieck, Dec 7, 2014.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    upload_2020-9-24_12-21-51.png
    Even rebaking the prefabs doesn't solve this.
    material seems alright though
    upload_2020-9-24_12-23-8.png
     
  2. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    bugs of the mesh animator window:
    1. clicking the foldout doesn't change the arrow from horizontal to downward
    2. when selecting a prefab that has GPU Shader animated on it, the gui doesn't refresh. this is required if you want to fine tune the baking parameters
     
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    quick URP benchmark for the road:
    about 20 lightprobes
    1 directional mixed
    light mode = baked
    baked the arena lighting
    arena material = baked
    3000x
    shader mode
    60 fps

    on desktop
    URP simple lit: 80fps
    builtin mobile diffuse: 61-70 fps

    on mobile:

    URP simple lit: 48-60fps+ !!
    builtin mobile diffuse:26-32fps

    notes:
    light probes or no lightprobes don't make a difference, probably because instance breaks, see below
    URP lit doesn't show up
    mobile/bumpedspecular shows up as black
    223 drawcalls.
    this shouldn't happen with the GPU shader, it's as if it renders in snapshot mode:
    upload_2020-9-24_14-54-17.png
    upload_2020-9-24_14-57-1.png
    when I look at the frame debugger i see that same anim frame objects are batched so it seems that shader mode doesn't provide speed advantage over snapshot
    here are 2 drawcalls: as you can see each one has the same animation frame/deformation
    upload_2020-9-24_15-5-35.png
     
  4. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    There is a bug with position compression being set to "None - Best Quality" in the latest version. Set it to Highest Quality (previous default) and it should work. I'm releasing a fix today.
     
  5. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131
    Hello! Is there any way to get exposed transforms to smoothly crossfade as well? Right now my exposed transforms instantly teleports to the subsequent animation's starting point. The mesh crossfades beautifully, but all exposed transforms do not crossfade. Is there a way around this?
     
  6. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    That should not be the case, snapshot or shader mode? May be a bug
     
  7. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131

    It's in shader mode. Uploaded a gif to show you the issue. You can see that the green sword instantly teleports when crossfading animations.

     
  8. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    PM'd a fix.
     
  9. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131
    Received it! Thank you very much again for the fix!
     
  10. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    262
    Hey there I'm having some really hard to track down problems and hoping for a hand.

    Basically, in my project where I want to use MA, when I make a new scene and drag in your Unit_Skeleton example prefab, it draws when we are not in play mode, but once I hit play, it disappears. There are no evident triangles.

    I made an entirely new project and attempted to replicate the same settings, and I cannot repro it in an empty project.

    I'm going to reimport my main project entirely (wipe Library) and see if that fixes things. A different test project I had was showing the same behavior and then when I updated Unity it reimported everything and worked. EDIT: It finished reimporting and is sitll not fixed.

    This is in 2019.4.11f1 LTS. Bulitin renderer.

    If you have any clues or places to look, things to try, I'd appreciate a hand. Thanks!
     
    Last edited: Sep 28, 2020
  11. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    262
    So, I've got my main project and a test project going side by side. I see no differences in configuration between the two, including inside the frame debugger. However the main project just doesn't draw the character once we enter play mode, whereas the test project does. It seems to draw for like one frame and then disappears. The outline of the un-shaderized mesh is visible moving around, just no animated mesh.

    The one discovery I have made is that in the broken main project,
    • if I add the skeleton manually after Play Mode has been entered it works.
    • If a pre-placed Skeleton has its GPU Shader Animated component disabled when entering play mode, and then I turn it on, it works (firing OnEnable)
    • If I deactivate the gameobject of the Skeleton and enter play mode, then activate it, it works.
    • IT DOES NOT WORK when pre placing a skeleton with its GPU Shader Animated component enabled when entering play mode.
    This indicates some kind of race condition in the project. I've walked into MeshAnimatorManager.cs and everything seems to be firing in the same order. I tried also shutting off [ExecuteInEditMode] on the GPU Shader Animated component, but that also did not work.

    The _animators List in MeshAnimatorManager contains the skeleton and is updating it either way.

    Ideas welcome. I'll keep posting updates.
     
  12. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    262
    Ok still no progress on the mesh disappearing. I'll come back to that.

    There is another issue with the Mesh Animator Standard shader. So, if you try to put a normal map in that, you'll get an error:

    Shader error in 'Mesh Animator/Standard': variable 'vertexInput' used without having been completely initialized at Assets/MeshAnimator/Shaders/MeshAnimatorStandardBase.cginc(37) (on d3d11)

    The while this error can be supressed by putting the following on line 28 of that file:
    UNITY_INITIALIZE_OUTPUT(VertexInput, vertexInput);

    It doesn't make the normal map work. The mesh renders all black until you remove the normal map. This is reproduceable on the Skeleton material. It might be only in Deferred, I'm not sure. I'm also on 2019.4.11f1 LTS.

    Would love a fix on that. Cheers
     
  13. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    When I replace the shaders to URP 8.2 in unity 2020.1.6, the animation in AI crowd sample doesn't play properly in MA v2.0.14: many instances play the same frame instead of their own.
    Do I need to rebake all when switching pipeline? If so, how do I do that? The documentation mentions rebake twice but doesn't show how to do that.
    meshanimator urp animation not working.gif
     
    Last edited: Sep 29, 2020
    lin02051 and HenryChinaski like this.
  14. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    does MA work with legacy rig? it does detect the bone, but then display this warning:
    upload_2020-9-28_17-57-0.png
    tested with a generic rig and getting the same warning
    upload_2020-9-28_17-59-33.png
    EDIT: it seems to be just a warning, it works. A debug message left behind perhaps?
     
    Last edited: Oct 1, 2020
  15. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    262
    Just following up on my issue with MA GPU objects disappearing on game start. The workaround is to start them with the GPU Shader Animated component disabled, and then enable it after the first frame.

    I have no workaround for normal maps not working on the MA Standard shader. That appears to be an issue in all projects, not just my weird one. Again that is 2019.4 LTS, Deferred builtin renderer.
     
  16. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    it looks like a bug in the URP shader:
    gradient environment doesn't affect meshanimator simple lit
    upload_2020-9-30_19-59-11.png
    skybox does
    upload_2020-9-30_20-0-50.png
     
  17. edogainc

    edogainc

    Joined:
    Jul 6, 2017
    Posts:
    1
    Just got version 2.0.14. I tried to set up shader mode instancing on a mesh using the Standard shader. I get the following shader compiler error when trying to swap in the MeshAnimator/Standard shader:

    variable 'vertexInput' used without having been completely initialized

    Compiling Vertex program with UNITY_PASS_FORWARDBASE DIRECTIONAL
    Platform defines: UNITY_NO_DXT5nm UNITY_ENABLE_REFLECTION_BUFFERS UNITY_NO_CUBEMAP_ARRAY UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_DLDR_ENCODING


    Using Unity 2019.3.3f1
    Build Target: Android
    Graphics APIs: OpenGLES3

    I tried Re-Import but the results didn't improve.
     
    HenryChinaski likes this.
  18. Radomiej

    Radomiej

    Joined:
    Dec 31, 2015
    Posts:
    1
    Hi, I found a bug with ShaderMeshAnimator in ShaderMode.
    a) If you are using an animation with WrapModel ClampForever there is only about 10% chance that the animation will stop at the end, usually it will fall back to Frame 1.
    b) WrapModel PingPong does not work properly, generally behaves like ClampForever.

    Probably this line in Pause method is the problem:
    Code (CSharp):
    1. Mathf.RoundToInt(Mathf.Min(Mathf.Ceil(timeBlockData.y * normalizedTime), timeBlockData.y - 1));
    I managed to solve this problem by overwriting the Pause method to manually assign currentFrame, but it would also be nice to update transform`s positions

    Perhaps it would be useful to add a method to manually set the displayed frame so that you can better control the currently displayed frame of the animation, as relying on Pause at the moment is unpredictable.

    You could also highlight the note on "Enable GPU Instancing" in documentation, because not being interested in implementing a custom shader, I omitted the information about it.
     
    Last edited: Oct 2, 2020
  19. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131

    I am having this bug too. But it appears to happen as long as the animation is non-looping. Sometimes it'll jump to the first frame, sometimes it'll stay in the last frame.

    Gif showing the issue, all five models use the same settings. Notice random endings of animations:
     
  20. Pixel2015

    Pixel2015

    Joined:
    Mar 10, 2016
    Posts:
    35
    Is this supposed to work on 2020.1? Since 2020.1 the Shader Animator doesn't work at all from my own models, it just stands in the T-Pose all the time even when current frame and animation references seem to be ok.

    In the examples I have the same issue laurentlavigne posted above animators all playing the same animation and sometime even jumping from one animation to another for no reason.
     
  21. niflying

    niflying

    Joined:
    Jul 11, 2012
    Posts:
    108
    Hi, Any good news for HDRP shader mode?
     
  22. GameFDev

    GameFDev

    Joined:
    Jul 13, 2020
    Posts:
    10
    Hello, I'm getting the following errors when I try to create a snapshot:

    Code (CSharp):
    1. Invalid AssetDatabase path: /hard_BounceStep.asset. Use path relative to the project folder.
    2. UnityEditor.AssetDatabase:LoadAssetAtPath(String, Type)
    3. FSG.MeshAnimator.MeshAnimationCreator:CreateSnapshots() (at Assets/ThirdPartyAssets/MeshAnimator/Editor/MeshAnimationCreator.cs:1527)
    4. FSG.MeshAnimator.MeshAnimationCreator:CreateSnapshots() (at Assets/ThirdPartyAssets/MeshAnimator/Editor/MeshAnimationCreator.cs:1442)
    5. FSG.MeshAnimator.MeshAnimationCreator:OnGUI() (at Assets/ThirdPartyAssets/MeshAnimator/Editor/MeshAnimationCreator.cs:891)
    Code (CSharp):
    1. Couldn't create asset file!
    2. UnityEditor.AssetDatabase:CreateAsset(Object, String)
    3. FSG.MeshAnimator.MeshAnimationCreator:CreateSnapshots() (at Assets/ThirdPartyAssets/MeshAnimator/Editor/MeshAnimationCreator.cs:1753)
    4. FSG.MeshAnimator.MeshAnimationCreator:CreateSnapshots() (at Assets/ThirdPartyAssets/MeshAnimator/Editor/MeshAnimationCreator.cs:1442)
    5. FSG.MeshAnimator.MeshAnimationCreator:OnGUI() (at Assets/ThirdPartyAssets/MeshAnimator/Editor/MeshAnimationCreator.cs:891)
    6. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    Code (CSharp):
    1.  
    2. FSG.MeshAnimator.MeshAnimationCreator:CreateSnapshots() (at Assets/ThirdPartyAssets/MeshAnimator/Editor/MeshAnimationCreator.cs:1887)
    3. FSG.MeshAnimator.MeshAnimationCreator:CreateSnapshots() (at Assets/ThirdPartyAssets/MeshAnimator/Editor/MeshAnimationCreator.cs:1442)
    4. FSG.MeshAnimator.MeshAnimationCreator:OnGUI() (at Assets/ThirdPartyAssets/MeshAnimator/Editor/MeshAnimationCreator.cs:891)
    5. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:197)
    Prefab in question is a variant if it makes any difference.
     
  23. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    bug: in urp gpu mesh animation within prefabs tend to disappear
    now you see me (during play)
    upload_2020-10-18_1-5-15.png
    now you don't (before play)
    upload_2020-10-18_1-5-1.png
     
  24. bolatofunmi

    bolatofunmi

    Joined:
    Jan 2, 2020
    Posts:
    1
    Why does the animtion run a bit slow compared to unity skinnedmesh animaion
     
  25. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    I haven't had any issues in 2020.1, you've switched all your materials to the Mesh Animator versions? If so, can you PM your model?

    Is Output Folder populated in the bake window?

    Shader mode requires runtime texture arrays to be created on the materials, this is most likely a result of something being stored in the prefab's material (an empty array or setting). I'll have to make a clear button or something in the inspector so it can clear them out.

    Do you have an example? Are you referring to them not keeping in perfect sync? Have your tried a higher bake FPS?
     
    laurentlavigne likes this.
  26. niflying

    niflying

    Joined:
    Jul 11, 2012
    Posts:
    108
    Hey, you skipped a question ^^

    Hi, Any good news for HDRP shader mode?
     
  27. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Not yet
     
  28. niflying

    niflying

    Joined:
    Jul 11, 2012
    Posts:
    108
    That's sad for me.
    Are there any chance to out it on next month?
     
  29. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131

    Would like to add that this issue is not quite an issue with only non-looping animations in shader mode, but instead is an issue that occurs even with looping animations. I have tried to pause the mesh animator when an animation (both looping and non-looping) is finished by using the "OnAnimationFinished" function provided. Sometimes it pauses on the last frame as it should, sometimes it pauses on frame 1, at times it pauses on frame 0.

    Using playqueued doesn't help either as the mesh itself completely disappears when the current animation is finished and the subsequent animation is played.

    I am completely stuck now and am hoping Mr. developer has a fix or advice for this issue I am facing. :(
     
  30. niflying

    niflying

    Joined:
    Jul 11, 2012
    Posts:
    108
    Hi Guys,
    Long time no see. Any good news for HDRP shader mode?
     
  31. HenryChinaski

    HenryChinaski

    Joined:
    Jul 9, 2013
    Posts:
    108
    Was this issue solved?
     
  32. lin02051

    lin02051

    Joined:
    Nov 10, 2020
    Posts:
    4
    I found a mistake -- error normal data,and I handled it this way
    upload_2020-11-10_20-49-51.png
     

    Attached Files:

  33. lin02051

    lin02051

    Joined:
    Nov 10, 2020
    Posts:
    4
    before:
    upload_2020-11-10_20-53-36.png

    after:
    upload_2020-11-10_20-55-13.png

    That solves the problem,code in MeshAnimator-URP-SimpleLitForwardPass.hlsl and MeshAnimator-URP-LitForwardPass.hlsl
     

    Attached Files:

    laurentlavigne likes this.
  34. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    I don't understand, what did you do and what was it for?

    WOW! Thanks, that worked!

    Do you also get this blinking in edit mode?
    mesh animation VAT blink bug.gif
     
    Last edited: Nov 10, 2020
  35. lin02051

    lin02051

    Joined:
    Nov 10, 2020
    Posts:
    4
    first problem:
    before:
    outputVertexNormal = vertexNormal;

    after:
    outputVertexNormal = GetAnimatedMeshNormal(
    vertexNormal,
    vertexIndex,
    animTextureIndex,
    animInfo,
    animTimeInfo,
    animTextures,
    samplerState);

    second problem:
    Not blinking in edit mode,You can run it on the official demo and see if it's a problem with your resources
     
    laurentlavigne likes this.
  36. lin02051

    lin02051

    Joined:
    Nov 10, 2020
    Posts:
    4
    The baked data was not used, but the raw mesh data was used
     
    laurentlavigne likes this.
  37. Haagndaaz

    Haagndaaz

    Joined:
    Feb 20, 2013
    Posts:
    232
  38. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    Have you folks been able to use URP>lit?
    The object disappears when I do that and I can only use simple lit.
     
  39. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    today, the meshanimator geometry no longer shows up, I hope this won't happen in the middle of a play session or I'll get many upset players.
     
  40. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
    This asset looks incredible, i wonder tho, does it work in HDRP? i'm trying to make a level full of animated spiders, FULL OF THEM.
     
    Last edited: Nov 12, 2020
  41. niflying

    niflying

    Joined:
    Jul 11, 2012
    Posts:
    108
    Hi, Can I use MA's HDRP shader mode by Amplify Shader? Looks like the MA doesn't support HDRP shader mode.
     
  42. HenryChinaski

    HenryChinaski

    Joined:
    Jul 9, 2013
    Posts:
    108
    Do you maybe have an error about "vertex input was used before being initialized" on your shader? Mine is not showing up either.
     
  43. Haagndaaz

    Haagndaaz

    Joined:
    Feb 20, 2013
    Posts:
    232
    Not sure honestly, our project isn't using HDRP
     
  44. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Snapshot mode will, shader mode will not until the HDRP shaders are converted.
     
  45. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Version 2.0.16 has been submitted to the asset store.

    - Fixed exposed transforms not interpolating smoothly when crossfading in shader mode.
    - Fixed shader compiler warnings.
    - Fixed instancing issues with URP shaders. (thanks lin02051)
    - Animation clips are now sorted alphabetically in the bake window.
    - Upgraded base asset Unity version to 2018.4 LTS.
     
  46. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    Don't, we sort clips in a specific way in import for a reason.
     
  47. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    This has no effect on the order of import, only display of the list of animations. You can still sort them any way you like in the baked prefab.
     
  48. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    That's what I'm talking about: this breaks the continuity of the user interface with the importer.
    Also this breaks methodology that went into setting up the animations, many month of work.

    So instead of forcing us to reshuffle 10 animations on 20 characters by hand, you can make sorting an item in the context menu of the component.
     
  49. HenryChinaski

    HenryChinaski

    Joined:
    Jul 9, 2013
    Posts:
    108
    Thanks for the fix but there seems to be something wrong with the package content?
    https://ibb.co/brPJNhn

    Could you maybe send the package by mail as a hotfix?
     
  50. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Your local cached version must be outdated. Update it from the package manager and try reimporting