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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Occlusion Culling issue (works like Frustum Culling)

Discussion in 'Editor & General Support' started by ANTARES_XXI, Jan 8, 2016.

  1. ANTARES_XXI

    ANTARES_XXI

    Joined:
    Dec 23, 2014
    Posts:
    141
    Hello everyone!

    I have a scene with procedural generated maze (at runtime) composed of cubes (wall prefab, marked as static) and large plane (floor, also static). The scene (initially with plane only) is baked (for occlusion) with default parameters.

    And now I don't get what am I doing wrong, because Occlusion Culling works like Frustum Culling in my case (please see attached screenshots).

    Unity OC Issue Image 1.png Unity OC Issue Image 2.png

    Using Unity 5.3.1f1 (Personal)

    My original post is here but maybe in this forum I'll find the answer:)
     
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,614
    Occlusion culling can only calculate occlusion from things that are present in the scene at the time you bake it. If the only thing present in the scene initially is the floor plane, then that's the only thing that will be an occluder. The fact that your prefabs are marked as static doesn't matter - they have to actually be in the scene to count for anything.

    If your procedural level is always going to be generated according to a regular grid or something, then what you could try doing - I've not tested this, so it might not work - would be to place an OcclusionPortal on every grid square (possibly a pair of them forming a cross over the square), and baking them. Then, at runtime, when a particular square has a wall in it, you set the occlusion portals to 'blocked', and when a square is empty you set the portals to 'open'.
     
    ANTARES_XXI likes this.
  3. ANTARES_XXI

    ANTARES_XXI

    Joined:
    Dec 23, 2014
    Posts:
    141
    Sorry for not answering so long, I had a lot of work. OcclusionPortal works perfect for me, thank you so much!!!
     
    superpig likes this.