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

Occlusion culling just not working.

Discussion in 'Editor & General Support' started by ooramirez_unity, Nov 6, 2018.

  1. ooramirez_unity

    ooramirez_unity

    Joined:
    Jul 3, 2018
    Posts:
    4
    So, I am sure it does work. I am sure I am doing something wrong or skipping one step. I just cannot make it work. The only elements that get "hidden" are those outside the camera point of view. However, elements do not disappear when they are behind other elements. I created a new scene to test it and I am getting the same result.


    These are the steps I followed:
    1. Create a new scene.
    2. Added the two elements.
    3. Create a material, made it opaque and added to the elements.
    4. Select the elements and tagged then as Occluder Static and occludee static.
    5. On the window Occlusion selected Occluder and Occludee in the Object tab for both elements.
    6. Select the elements.
    7. Bake them.
    It is supposed the start working for such a simple scene, but it is not. Any ideas on what I am doing wrong?
     
    NEVER-SETTLE and Marlon_Braga like this.
  2. Marlon_Braga

    Marlon_Braga

    Joined:
    Sep 28, 2014
    Posts:
    1
    Do you find the solution for that?
     
  3. ooramirez_unity

    ooramirez_unity

    Joined:
    Jul 3, 2018
    Posts:
    4
    No mate. I had to put this project aside. But I did look hard and could not find what was the problem. Are you facing exactly the same issue?
     
  4. NEVER-SETTLE

    NEVER-SETTLE

    Joined:
    Apr 22, 2018
    Posts:
    30
    I'm facing the same, and the moderators deleted my comment when I posted it. They also ignore all the numerous threads showing this issue with concrete example.
     
  5. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    328
    check out my signature :D
     
  6. IAndrewNovak

    IAndrewNovak

    Joined:
    Nov 29, 2013
    Posts:
    104
    BUMP
    I have Same Problem. Any comments from devs?
     
  7. Skeketor23

    Skeketor23

    Joined:
    Apr 6, 2019
    Posts:
    49
    same Problem here. It just doesn't work
     
  8. binho123

    binho123

    Joined:
    May 28, 2019
    Posts:
    18
    Here is one thing: if you have dynamic/static batching and/or GPU instancing enabled this can happen because the meshes get batched (so they effectively become one mesh) and therefore are not culled.
     
  9. binho123

    binho123

    Joined:
    May 28, 2019
    Posts:
    18
    ...and here's another thing: frustum culling uses OBB (oriented bounding box) to check if the object is inside the frustum but occlusion culling uses BB (not oriented volumes!), so depending on how your camera and objects are rotated it may think that one thing is in front of the other!

    You can understand/see this happening by enabling Camera Volumes and Visibility Lines and rotate all your objects together, notice that as they move the camera volumes do not rotate together and things get weird (things that are further away from the camera gets inside of a camera volume that is nearer the camera).

    Not sure if this - or a similar problem - is what's happening in the OP example, though.
     
  10. Bandinopla

    Bandinopla

    Joined:
    Feb 2, 2018
    Posts:
    21
    any solution for this? i have that same issue... loaded a new scene... add a bunch of cubes, then put a bigger cube in front of the camera, flag all cubes as occlusion static and bake occlusion... on visualization, all cubes are being rendered... even the ones behind the big cube in front of the camera...
     
  11. HunterAhlquist

    HunterAhlquist

    Joined:
    Oct 6, 2013
    Posts:
    127
    same problem
     
  12. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,444
    The solution is, your camera needs to be within the 'bounding box' of the occlusion culling bake, it is a voxel based system, and it won't create many voxels far away from the geometry if there is no geometry there (for example where the camera is.

    The 'smallest occluder size' value in the bake settings for Occlusion is also, this is the size of the smallest thing that will occlude, try setting the value to '1' or lower and work your way back up to a value that suits you.

    Try bringing your camera within the baked occlusion region while in play mode (you will see a yellow square) this is also visualised as blue squares when you are in edit Occlusion mode

    upload_2020-10-8_18-0-35.png
     
    Last edited: Oct 8, 2020
  13. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,444
    This gif may help to show better, OP's visualize scene view mode does not show the yellow boundary for occlusion because their camera is not within the occlusion zone. Try bringing your camera near to the occlusion area or put some static geometry to be baked with occlusion near to it to make the zone larger!

    The 'smallest occluder size' value in the bake settings for Occlusion is also, this is the size of the smallest thing that will occlude, try setting the value to '1' or lower and work your way back up to a value that suits you.

    cubes.gif
     
    Last edited: Oct 8, 2020
  14. amitDklein

    amitDklein

    Joined:
    Apr 10, 2017
    Posts:
    20

    To add on that, you basically need to be in the area that unity makes when you bake, if you want the area to be bigger you can add more objects or do that the right way with 'occlusion area'

    for more you can check this video for more information
     
    drewvancamp likes this.
  15. Harold_83

    Harold_83

    Joined:
    Nov 25, 2014
    Posts:
    44
    I know this is an old topic but how do you increase the range of that yellow box?
     
  16. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,444
    You edit the occlusion region itself to do that, should be on the component
     
  17. Harold_83

    Harold_83

    Joined:
    Nov 25, 2014
    Posts:
    44
    Can you do a screengrab? Are you talking about on the camera? Component where?
     
  18. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,444
  19. amitDklein

    amitDklein

    Joined:
    Apr 10, 2017
    Posts:
    20
    You can also put other object on the sides, the size of the yellow box is the min size for all of your object to fit into
     
  20. Harold_83

    Harold_83

    Joined:
    Nov 25, 2014
    Posts:
    44
  21. Harold_83

    Harold_83

    Joined:
    Nov 25, 2014
    Posts:
    44
    When the yellow box his the mesh, the objects on the other side disappear but I'm trying to find a way to extend that because the meshes are rendering too far away.
     
  22. ronjart

    ronjart

    Joined:
    May 16, 2013
    Posts:
    100
    I had this issue and the solution for me was to apply a default material to the occluder mesh before baking. You can apply whatever material afterwards.
     
  23. RHSn

    RHSn

    Joined:
    Jan 27, 2023
    Posts:
    4
    Just based on OP's GIF I think the problem OP had was simply that the camera was outside any camera volumes.
    When baking, Unity tries to infer locations where the camera could reasonably be located, but in this example scene with no floor, and no walls and just infinite limbo, Unity seems to only compute camera volumes that are 1 occlusion size away from occluders or occludees. If the camera is then just outside of any camera volume, occlusion culling just doesn't happen.

    If you want to test occlusion culling, I recommend giving it at least a plane representing a floor, and making it a static occluder.

    That said, even making sure the camera is within a camera volume, occlusion culling still behaves very weirdly for me.
    Changing the material did not help.

    It looks like it actually finds holes in the mesh of a simple cube (note that I took this screenshot before I added a floor, but you can see the camera is inside a camera volume):


    Changing the baking parameters (smallest occluder, smallest hole) does have an effect on it, but it seems kinda random. At one point 5 and 0.1 worked perfectly. Then I try moving an occluder just a little bit before baking and suddenly those same parameters result in holes and I need to set it to 2 and 0.5 to work...

    And sometimes it looks like clicking "Bake" just doesn't do anything at all and occlusion data is not actually updated.