Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Occlusion culling not working as expected

Discussion in 'Editor & General Support' started by CrashKonijn, Feb 23, 2016.

  1. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    245
    Hi all,

    Last week I've been trying to improve on the occlusion culling in our game, since this not being setup correctly seems to be the heaviest in our game. After trying everything I could think of and readying almost every topic on occlusion culling I could find I'm now asking my question here, since I just can't seem to be able to get it working as I expected.

    Screens of position one:
    ss (2016-02-23 at 03.52.17).jpg ss (2016-02-23 at 03.52.05).jpg ss (2016-02-23 at 03.54.49).jpg
    Screens of position two:
    ss (2016-02-23 at 03.53.26).jpg ss (2016-02-23 at 03.53.21).jpg

    The problem here is that It's still trying to render almost all the object that are in that part of the scene, even though they're not visible from the camera. Yes I've obviously made sure everything is static etc.

    Hopefully someone can help me out with this.

    Kind regards,

    Peter
     
  2. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,760
    Is the greenhouse a single mesh? I found if the meshes are too large, OC will act strangley.

    Also its hard to tell but it looks like the visibility lines are passing under the walls, Are there gaps between the walls and floor?
     
  3. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    245
    No it's actually build up from multiple peaces. The scene is quite big (with the buildings in the distance, but those are just big cubes basically).

    And yes, the lines do go through object. Although there shouldn't be gaps at those places.
     
  4. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    245
    Hi all,

    I wanted to ask again if someone could help with this problem. We've completely rebuild our level, including tools to make sure that all the settings for every object are setup correctly.

    The problem still remains that a lot of object that are impossible to see are not being culled by the OC. Some stuff is but it's mostly just acting as frustum culling right now...

    Does no-one else have these problems?

    Kind regards,

    Peter Klooster
     
  5. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,760
    It's very hard to tell from the screnshots what the issue is.
    Try going to the occlusion window and making sure the "Default parameters" button is clicked.
    Your scene is layed out in a manner that makes OC useless. OC only works for large items that can block like walls and floors and ceilings. In your screenshots, there doesnt look like there's anything that should be being culled.

    You have 10,000 draw calls. Even if the OC was working, from the looks of it the game would still be unplayable. Im not an expert with optimizations, but I think the OC is least of your concerns right now.
    I think you need LODs and simplified meshes and a reduction in materials.
    http://docs.unity3d.com/Manual/OptimizingGraphicsPerformance.html
    I would focus on that first then focus on OC, even though I dont think OC will do much for your scene given the layout of the scene.

    The first thing I would do is go into the 3d modeling software and agressively elimminate excess triangles with the expactation that OC cant be used in your particular scene. In Blender, it is called the Decimate modifier.

    Another thing you can do, which wouldnt be that much work is to add a wall with a door through the middle of the greenhouse to act as the main occluder in the middle of the greenhouse. This would help guarantee that in the view you show, the last half of the greenhouse and meshes are culled.
     
    Last edited: Apr 10, 2016
    CrashKonijn likes this.
  6. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    245
    Thanks for your answer!

    Currently, (with the rebuild) we got the batches down to 3500 and the triangle count to 2-2.5 million, this probably could be lower but I'm working on that :) I must note that there are even more objects in the scene then before so we're on the right track.

    ss (2016-04-11 at 12.45.52).jpg

    The thing with even these number is that probably more than half of it could (and should) be culled by the OC.

    Game view:
    ss (2016-04-11 at 12.57.14).jpg

    OC:
    ss (2016-04-11 at 12.56.31).jpg

    And at least everything selected (which is quite a lot) should be culled, since it's impossible to see (because of the tunnels to access that area)
    ss (2016-04-11 at 12.56.54).jpg

    The rocks still have mesh colliders at this point, but do the objects really need colliders for the OC? All plants for example don't have colliders but are culled correctly (in some areas).

    I've tried multiple settings for the OC, including the standard settings but I just can't seem to be able to get the desired results. There are unfortunately not many settings to play with...

    Edit:
    I did just test what happens if I disable everything I can't see by hand and just noticed something strange: The lighting on the other side of the level changes when I disable these objects... I have no clue why but might this have something to do with it?


     
    Last edited: Apr 11, 2016
    ArachnidAnimal likes this.
  7. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,760
    You don't need colliders for the OC. (I deleted that part from my original post).
    2M triangles is not that bad. The Unity manuals says the typical high-range triangle count is a few million for PC. So it should no longer be a problem for a PC.

    IF your using GI, if you disable parts of the scene it might affect the lighting in other areas of the map because the light bouncing will change in the scene. That could explain why the lighting changes.

    You could keep increasing the height of the rocks in the middle of the greenhouse until the OC does what you want it to do. I found that sometimes the visibility lines are not 100% accurate sometimes. You could have the OC system passing through a small hole even though the line is not visible in the editor (this has happened to me a few times)
     
    CrashKonijn likes this.
  8. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    245
    We do have realtime GI enabled, but I had the feeling it was mainly the reflection that changed (look at the reflections in the glass on the right side, which should only reflect the skybox).

    Anyway, I tried a couple of different settings again and keep getting the same result. The OC just seems to ignore most of my rocks. I hope these screenshots will give a better image of what it's doing.

    OC preview and camera view
    ss (2016-04-12 at 11.18.22).jpg ss (2016-04-12 at 11.18.35).jpg

    OC visibility lines (which almost all go way to the back)
    ss (2016-04-12 at 11.19.05).jpg

    And to show you, these walls are solid rocks going from the floor to the top of our level. (although they are made up of different rock peaces). There's just 2 tunnels to go through.
    ss (2016-04-12 at 11.25.23).jpg
     
  9. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,760
    You could try completely deleting the OC cache from the library.
    I dont know what the issue could be.

    I would add a large temporary wall (Unity plane) through the middle of the green house to see what happens.
    .
     
    Last edited: Apr 12, 2016
  10. DragonRaja

    DragonRaja

    Joined:
    Apr 14, 2017
    Posts:
    3
    I had this probolem in my game,finally I fixed it
    The problem is that I didnt creat OC area in my scenc(I use default),this leads to my main camera is not in the OC back Area(the yellow cube).
    so I create one OC area and include the main camera.....
     
  11. basrianari

    basrianari

    Joined:
    Apr 29, 2020
    Posts:
    1
    this is actually true, i have this problem too i just tried to figured it out for 3 hours, I fount my problem which is I dont actually bake my object instead only the scene, so what i have to do is I select all the object (the object which is static ocluded, etc) and baked them while all are selected. I tried it but it still doesnt work until I reduce the amount of "smallest occluder and the amount of smallest hole until it get smaller (I reduce those numbers) and re-baked my object back and it finally works
     
  12. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    Same problem here, OC has always worked but when I look through my glass I can see things behind it. So I can see through to other parts of the level , very weird. Any ideas? Ive never needed an OC area before.

    edit: actually it does work if I put a large cube behind the window and turn off mesh renderer. I wasnt making it large enough before.
     
    Last edited: Jan 17, 2021