Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Occlusion Culling Performance When Turning Quickly

Discussion in 'General Graphics' started by WildStyle69, Apr 12, 2019.

  1. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Hi Devs,

    TL;DR: I'm getting performance spikes when turning ~180 degrees in outside areas, am using occlusion culling and zones.

    More detailed version, please read on...

    I'm working in a VR project where I've created a custom zones system for internal and external areas. Basically loading lots of sub-scenes additively async to make up the whole game area. When you enter a zone, the system loads the connected zones, and disables any others that are no longer connected (indirectly). Enabling / disabling a zone runs routines to incrementally start/stop animations, sounds, disable lights and objects etc. I've also configured all zones internal / external to use Unity occlusion culling, plus baked / combined meshes and have done material atlases by zone / sub-area.

    Performance wise this has worked really well overall -- on the internal scenes I'm way under my target MS for hitting 90 FPS and on the external scenes, things are fairly solid too. However as there is terrain (MegaSplat) and vegetation (VS Pro) on the external areas I am pushing the limits in terms of tris / verts for a VR project, definitely at the high-end of things. That said I'm mostly 2-3 MS under my 90 FPS target on the external scenes as well... apart from areas that can see the whole level, where I still need some more LOD and impostors.

    Occlusion Culling issue -- in VR you can turn quickly, basically there is no limit on how fast, apart from your personal fitness. :) This means that you can spin 180 degrees pretty quickly, and this is causing fairly large performance spikes. My guess at what's happening - is that the Occlusion is hiding / showing large number of objects when you turn and it takes time for the rendering to catch-up? The faster you turn the bigger the performance spike it seems.. then once things have rendered, we go back into the green again.

    Questions - is this behavior expected? Does anyone have any idea how I can improve and smooth these occlusion spikes?

    Any help / pointers greatly appreciated, thanks!

    // WildStyle
     
  2. ryan_unity

    ryan_unity

    Unity Technologies

    Joined:
    Dec 28, 2014
    Posts:
    11
    Hey!

    It's difficult to know at the moment why these frame spikes are occurring.

    Are you able to use the Unity profiler to profile this, save the profiler data out to a file and upload it here? This should help show what's taking so long during the frame.

    Also, what version of Unity are you using? And is this occurring in the Editor as well as in standalone player builds?
     
  3. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Hi @ryan_unity -- thanks for the reply here!

    After debugging this issue for a while I found that it was indeed the rendering taking time when turning quickly. unfortunately the profiler didn't give me the exact issue, just that a lot of instructions where queued for the GPU and so the frames were hitching and getting delayed.

    I already knew that my tris / verts whilst on the high side for VR should no be causing a problem like this, so I started looking at additional optimization, other settings and model textures etc. I found a few things that helped improve performance considerably:
    • Added more mesh baking, texture atlas, LOD and impostors.
    • Terrain texture resolution was too high I lowered it to 1024 and 512.
    • Switch aniso texture filtering per texture and manually adjusted all models / textures settings.
    • Some of my texture atlas were 8096, so I rebaked and split things down to a max of 4096.
    • On some models the texture resolution could be lowered without much change being noticed visually.
    • Also on some models I lowered the resolution for metallic and occlusion by half, keeping the diffuse and normal at a higher resolution, and again this was not very visible but helped.
    • Lowered my global shadow resolution to low with 4 cascades, it was on medium before.
    The result of these changes means the spikes have lessened to a degree where they don't hitch the rendering, and only happen in certain areas of the level. So now they are more like frame-rate dips and the FPS recovers quickly, so it should hopefully be acceptable.

    I'll keep looking for additional optimizations.. hopefully can find some more along the way!

    // WildStyle