Search Unity

Advice on Improving Occlusion Culling peformance

Discussion in 'General Graphics' started by hoesterey, Feb 3, 2017.

  1. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Hi,
    I just baked Occlusion culling in my scene and am getting a huge perf hit of up to 3.4ms. About 3 times my drawing ms.

    There are other known optimizations that need to be made on the CPU side but long term I need some of the big cliffs to Occlude. My scene/objects are huge so my "Smallest Occluder" is set very high in an attempt to speed things up but with no luck. I also tried setting smallest hole higher (as we are operating on Airship scale here) but Occlusion often fails to bake.

    My occlusion data size is 13.8 megs.

    Any advice on how to improve this?

    Thanks.

    upload_2017-2-3_8-41-13.png

    (Note most the set pass calls in the below are due to recent unoptimized gui additions that need to be fixed meshes are around 360)
    upload_2017-2-3_8-41-35.png
     
  2. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Note I just discovered unity is in fact baking Occlusion data when larger settings are used. There is a bug where it tells you its not....

    That said I'm seeing even worse performance with large Smallest Occluder values (60). It gets better by about 1/2 at 150 meters but that is about 3x my player ship size.

    Take a look at the below image. If you look at the image from my previous post. The circled objects should not be rendered. They are rendered regardless of settings (unless I go super small). Those occluders are about 150 meters wide so its surprising they are not occluding.

    Camera does have Occlusion checked on.
    Objects are set to be occluders and occludees

    upload_2017-2-3_9-14-40.png
     
    Last edited: Feb 3, 2017
  3. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Ok,
    With values set as low as 30 meters for the smallest occluder (please keep in mind that one of the rocks in the picture below are about 300 meters wide) I'm not seeing proper occlusion and its taking 3.5 ms to cull. Notice how things behind the big rock still render even though no visibility lines are touching the portals.

    Whats the deal?
    upload_2017-2-3_19-28-6.png
    upload_2017-2-3_19-32-53.png
     
  4. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    I'm actually surprised that there are not more topics like this. The earlier version of occlusion culling worked fine, but I've had similar issues with the current version. It's hard to get any performance gain from it and it seems very unpredictable.

    I have the luck of working with real estate scenes, so just turning of layers based on the camera position does offer a performance gain and works in a very predictable way. (If on ground floor, don't render the attic sort of rules.)
     
  5. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    I wish I had evidence to back this up, but I recall Unity 4's occlusion culling working a lot better than the current version. Just seems a bit heavy for 'big' scenes.
     
  6. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    Yeah, the old PVS system gave at least some small performance gains on a mobile project I was working on at the time the system was replaced. We tried switching to the new system, and it seemed a huge CPU hog, so we ended up turning it off.

    But being a mobile project, our scenes weren't very big, and there was never a huge amount that could be culled. Clearly wasn't worth the high CPU cost to cull a relatively small number of objects.
     
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Usually this comes down to people really, really doing it wrong. You want to cull big combined things, not lots of little things. Combine lots of little things in clusters and perf will skyrocket.

    Unity does a poor job explaining it.
     
  8. AlteredPlanets

    AlteredPlanets

    Joined:
    Aug 12, 2013
    Posts:
    455
    yea I had the same issue, so can M2H culling help with this?
     
  9. AlteredPlanets

    AlteredPlanets

    Joined:
    Aug 12, 2013
    Posts:
    455
    "Combine lots of little things in clusters" and how will I go about doing that


    also the scene in the photos above is not shown alot of smaller objects, also in the unity 3 umbra video level has lots of smaller buildings

     
    Last edited: Feb 13, 2017
  10. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    I only have big things currently. There are only 20 some objects in the entire frustum. I'm finding I'm getting much better perf by disabling Occlusion.

    There are lots of Umbra settings we had to tweak on previous projects I've worked on that are not exposed. I'm not sure I'd want to tweak those settings as I remember it being a nightmare, but I'm guessing the current implementation will have an "optimal" use case. I think creating "rooms" with cliffs in an open setting just isn't an optimal case.
     
  11. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hm, perhaps some form of manual culling is best here - zone trigger on off stuff.
     
    AlteredPlanets likes this.
  12. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Yeah I'm moving toward that solution I think. :)