Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Occlusion Culling disabling the wrong objects

Discussion in 'Editor & General Support' started by MarcusOstlund, Sep 11, 2023.

  1. MarcusOstlund

    MarcusOstlund

    Joined:
    May 22, 2020
    Posts:
    3
    I've recently started learning how to use Occlusion culling but found a strange bug where occlusion culling disables everything but a few objects correctly. I instantiate some objects at some point in my game, the objects are NOT static and are not set as occluder or occludee. But for some reason they fade out or gets completely disabled when looking either towards them, or on the side (while still in view of the camera). I have no idea what causes this and it's quite infuriating. Clearing the OC cache fixes this issue but once I bake it again the issue comes back. Any help would be greatly appreciated.
     
  2. MarcusOstlund

    MarcusOstlund

    Joined:
    May 22, 2020
    Posts:
    3
    < Video of it happening.
     
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,113
    I'd recommend turning on the debug view of what occlusion culling is doing, so you can judge what might be occluding things unexpectedly.

    On the Occlusion tab, go to Visualization, and click on Visibility Line to turn on the feature. The green lines coming from the camera will show what the camera "sees" with respect to occlusion culling.

    upload_2023-9-11_21-16-51.png

    This should show you what's blocking/occluding visibility. Try moving the camera around to see how this affects the visibility lines. You can also turn on Camera Volumes on that little window to see how Unity filled in the scene.

    That said, I've also had some pretty inconsistent results with occlusion culling in the past. I've never use occlusion culling in an "outdoor" environment, so I don't know if there are issues with your visibility essentially being infinite in the sky.
     
  4. MarcusOstlund

    MarcusOstlund

    Joined:
    May 22, 2020
    Posts:
    3
    It would appear outdoor OC is not very reliable and tends to bug out. However I don't really know how to improve performance without occlusion culling (which is why I used OC). So what are other options to this ? Only the first scene is actually "outdoors".
     
  5. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,113
    Generally, with open world environments, LOD is used instead of (or sometimes along with) occlusion culling. Basically, for things very far away, you'll render a lower-detail version of the object, and eventually completely stop rendering things if they're extremely far away. It's hard to know exactly what is best for your project without knowing a lot of specifics. You should gather some stats on the specific performance issues you're running into, to better understand what approaches are best. (As in, are you confident that the performance is based on the visual rendering of objects, and not something else, like inefficient logic.)