Search Unity

Animation lag in Unity on complex meshes (NSFW)

Discussion in 'Editor & General Support' started by VEIVIEV, Mar 21, 2016.

  1. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
    Hi Unity forum,

    We've been having some serious issues with playback speed with Unity regarding lots of character meshes on screen at once. According to Unity in the Adam demo it's possible to have 100's of complex characters animating on screen at once. We cannot replicate this and it's been a major problem for us, possibly jumping ship to UE4, as UE4 can handle lots of characters on screen at once.

    Unity. Frame Rate Drop



    Here is a prime example. 12x 150k meshes on screen at once, each running the same animation, 160 frames. Fbx files exported from 3DSMax.

    1) Notice when playing on screen we see minimal lag.
    2) When you rotate away from the scene, then rotate back there is a huge drop in frame rate (causing sickness in VR)
    3) This DOES NOT happen when "Maximize on Play" is left unticked, in the VR headset it's super smooth, 75fps. It only happens in full screen mode. In the DK2 headset there is ZERO lag when Maximize on Play is left unticked. Yet when "Maximise on Play" is left on, we get lag.
    4) This also happens in a build. Lag spikes when you rotate back to all characters meshes on screen at once.
    5) Lods have been turned off here because lods have their own frame rate drop issue. When a new lod is drawn on screen at the correct distance we get a frame rate drop. This is another separate issue.

    6) With animations removed we get no lag or frame drop issues.

    Some settings:







    So it is possible to playback 12x 150K animating meshes in Editor at over 75fps in VR without lag under certain conditions but not during build.

    This has been a constant issue in our development and stopped us from utilizing animation and physics on characters in Unity. We are torn between UE4 and Unity because of this but we really want to stay with Unity.

    UE4. No Frame Rate Drop



    As a side note. UE4 has zero problems playing back 20x 150K meshes on screen at once, with or without lods. Same files, same animations. 75fps on the DK2.

    In fact the UE4 scene is more complex because it utilizes forward rendering specular (hack) on the eyes and screen space skin shader with lots of 8k and 4k textures.

    If anyone can offer any advise to further problem solve this issue in Unity it would be most helpful. We love Unity and want to stay with it.

    V
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Do you know what your scene is specifically bound by?
    It sounds SkinnedMeshRenderer from what you are describing as opposed to animation sampling etc.

    Have you tried turning on GPU skinning in the Player Settings?

    It also appears you are using Legacy mode. The most efficent way to sample lots and complex characters is Generic mode + "Optimized hierarchy" in the rig tab.

    It would be great to see a screenshot from the timeline profiler when the spike does happen.
    Does the spike go away if you enable "Always Animate" checkbox on the Animator?

    Best would be if you can share a project folder with your character setup so we can reproduce the spike.
     
    Last edited: Mar 21, 2016
  3. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
    Joachim, many thanks for the reply.

    "Have you tried turning on GPU skinning in the Player Settings?"

    Sorry I should have mentioned, GPU skinning is turned on.



    "The most efficent way to sample lots and complex characters is Generic mode + "Optimized hierarchy" in the rig tab."

    This I have not tried. I will test this now.

    Can you explain why this frame drop does not happen in VR mode in the Editor if Maximize at Play is turned off? Yet does happen if Maximize at Play is turned on, or during a build? It makes no sense. As I can see it can work without a frame drop.

    "It would be great to see a screenshot from the timeline profiler when the spike does happen.
    Does the spike go away if you enable "Always Animate" checkbox on the Animator?"

    I will also try this now and report back.

    "Best would be if you can share a project folder with your character setup so we can reproduce the spike."

    I will send something shortly. Should I PM you the download link?

    V
     
  4. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
    "It also appears you are using Legacy mode. The most efficent way to sample lots and complex characters is Generic mode + "Optimized hierarchy" in the rig tab."

    Can you explain this a little further? I can set to Generic but I cannot see "Optimized hierarchy" in the rig tab. What should I set as the "Root node" to?
     
  5. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
    I've sent you a PM with the project files.

    I would be happy to share my findings here, or if any mistakes were made on our side with setup so others can learn.

    V
     
  6. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Best would be if you can file a bug report with a sample project that produces the slow down and post the case number here.
     
  7. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    http://docs.unity3d.com/Manual/GenericAnimations.html
     
  8. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
    Thanks but I could not see "Optimized hierarchy" listed any where.

    I've just filed a bug report, the example project used the Legacy mode. I would be interested to know if this is a user error on setup or an actual performance issue.

    Case number 782095.
     
  9. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Optimized mode is only supported in generic or humanoid mode, so you need to switch to that first. You also need to switch all animationclips to use generic mode.

    Please switch over to generic rig (mecanim) and use optimized hierarchy mode. If in that setup it still reproduces a performance issue, then please file a bug with the project using mecanim optimized hierarchy mode.

    See here for more information about mecanim:
    https://unity3d.com/learn/tutorials/topics/animation
     
  10. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
    Thanks.

    I've since figured out how to use Generic mode and using Optimized hierarchy. I needed to setup an Animation controller and have Animations set to "Anim. Compression: Keyframe reduction." Unity didn't automatically create the animation controller. No Root node required.

    I still get a frame drop and horrible lag when trying to play 16 meshes on screen at once, even with lods. We also see a frame drop flying through the scene as each lod is loaded.

    UE4 can handle 20 models on screen at once with more complex screen space effects, high resolution textures and shaders. I hope this is a user error rather than performance problem. Let me know if you need any more example data.

    I've filed a 2nd bug report.. Case number 782608

    Example video:

     
  11. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
    Someone mentioned by PM this could be a Reflection probe issue (updating in real-time) To confirm, this animation lag has been happening since Unity 4, with or without reflections probes. On the DK1 it wasn't such an issue as the frame drop to 50fps wasn't so noticeable. On the DK2 the frame drop below 75fps is a killer. Generic or Legacy mode.
     
  12. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Hi there,
    Did you make any further progress with this? I'm also curious as to what the lag might be from - it's correct you should not use realtime reflection probes - better to try SSR in some cases instead, but I will take a look at the bug report you mention.

    Also I'm a little confused as to what I might be missing - in all the videos you posted, nothing seems to be animating - when you refer to skinned meshes animating... what animation do you mean?

    Also thanks for sharing your project and helping us solve potential optimisation issues.

    Cheers

    Will
     
  13. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
    Hi,

    Big thanks for the reply. In the bug report project there are no reflection probes and no SSR. SSR when active totally kills the frame rate, so we try not to use that at all. Although it looks INCREDIBLE. Unity's new built in version is stellar. Waiting on the Oculus ATW and GTX1080 for full realization.

    Reflection probes even when real-time are fine and work really well when the scans are not animating. You can pick up and move the scans around and the reflections update in real-time (reflection probes not SSR!) Quite incredible.

    As seen here a mixture of light probes, reflection probes and SSR combined https://vine.co/v/eIIU0E15Vgt (NSFW)

    But in this bug report the probes and SSR are deactivated because of the animation slow down.

    As I mentioned previously the slow down has been prevalent since Unity 4, it's not reflection related. When compared to UE4, with full screen image effects, complex shaders and animations. Unity seems to struggle.

    If you look very carefully in the latest Vimeo video and uploaded project you will see a 160 frame breathing and idle animation on the girls, just a little life added.

    I hope we can solve this as Unity is really shaping up to be the best real-time solution on the market, beating UE4 hands down. We want to stick with Unity.
     
  14. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
    Has there been any progress with this bug? Has it been officially confirmed?
     
    MrEsquire likes this.
  15. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
    Any word on this bug confirmation or fix?
     
  16. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    579

    (sorry couldnt resist)
     
    DezBoyle likes this.
  17. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
    Well I did have some confirmation by email but nothing publicly. I wonder why?

    On Tue, Mar 29, 2016 at 2:13 PM, Unity QA <bugs@unity3d.com> wrote:
    Hey,

    Yes, I see now. I will definitely report it as a bug.
     
  18. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
    Some Profiler screen grabs of the lag issue. Note this happens with 16 scans on screen at once or 1 scan animating.





     
  19. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    612
    What does the GPU Usage profiler say, and what does a deep profile say?
     
  20. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
  21. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    612
    Well, considering the pic a bit further up all say Oculus.WaitForGPU, and the GPU Usage graph there has a big spike, what is it doing during that spike?
     
  22. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
    If you check out the video you will see. We look at an empty space in the scene, then move the headset to look at an animating scan, either 1 or 16 of them at once, same issue. This causes the spike.
     
  23. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    612
    The profilers CPU graph says the spike is in 'Oculus.WaitForGPU'. This is the program waiting for the video card to catch up. Therefore, the actual issue is the video card being busy with something. The profilers GPU graph has a clear spike frames before this 'Oculus.WaitForGPU' spike. What did the profiler find during this GPU-graph-spike?
     
  24. VEIVIEV

    VEIVIEV

    Joined:
    Aug 3, 2015
    Posts:
    33
    Excuse the late reply. It was confirmed as a bug by Aras and has since been fixed. The fix is now included in Unity 5.3.5p3
     
  25. solarflare_s

    solarflare_s

    Joined:
    Feb 14, 2013
    Posts:
    10
    did u ever get a fix for this?
    I have the same problem, but when trying to capture frame sequences, looks great in game view, but the child objects are ahead of the animation in the frame sequences.