Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Occlusion Culling with multiple scenes - is there a better way?

Discussion in 'General Graphics' started by cowtrix, Apr 25, 2022.

  1. cowtrix

    cowtrix

    Joined:
    Oct 23, 2012
    Posts:
    324
    Hello all,

    The Unity manual says that for Occlusion Culling to work with multiple scenes:

    However, this pattern doesn't work when you have a "GameManager Master scene" pattern, where your root scene just has the GameManager and "static"-ish scripts. It seems like to make this work, I would need to load the level by itself, and then load the Master scene again on top, which is not really super convenient as it means I need to save/load all the state I keep there. Is there really no better way to do this?
     
  2. timmehhhhhhh

    timmehhhhhhh

    Joined:
    Sep 10, 2013
    Posts:
    158
    There are a lot of ways to make this work, but recently I was pointed to "Perfect Culling" on the asset store and have loved using it. Straightforward workflow, fast bakes, great performance, and doesn't suffer the long list of issues I've had with Umbra over the years. I highly recommend checking it out.

    Shill out of the way, flow-wise the built-in occlusion culling is similar to the lighting system at both design time and runtime - you bake different sets of scenes where the active scene is the one that Unity will use. For example, if you have a level split into several different scenes (geo, physics, lighting, etc):

    1. Load them additively in the editor (no need for any master scenes, just the ones you wish to work as a 'set')
    2. Set the scene that will act as the root as active (this should be the same one that contains your lighting data if you're also baking lights)
    3. Bake

    At runtime you can load your scenes additively, and when loading has completed set that scene as the active scene, allowing you to keep any master scenes loaded and decoupled from the baking process. In practice this may not always work entirely as expected, but should allow you to use the built-in system with your setup.
     
    eliteforcevn and cowtrix like this.
  3. eliteforcevn

    eliteforcevn

    Joined:
    Oct 25, 2018
    Posts:
    47
    In my case i solved it by steps

    set additive scene camera settings like main's scene cam

    Step 1 bake your additive scene Occlusion data and hide this scene camera (deactive this scene's cam if it only use to bake data)
    Step 2 load your additive scene and active it after it is loaded by
    SceneManager.SetActiveScene(SceneManager.GetSceneByName(addtiveSceneName));

    select main camera and test it visualize