Search Unity

Occlusion Culling - problem (lots of examples)

Discussion in 'Editor & General Support' started by bhaal, Feb 16, 2012.

  1. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
    Greetings

    After many months fighting with the Occlusion Culling I give up!
    I was spend so many hours to make it work correctly with no luck.
    This doesn`t seems to work as it should be. I tried about milion
    configurations and options with the same results. The object
    are not dissapearing as they should be or not at all.
    I tried it on few version of unity and with the latest release 3.5
    final too. Ok, so now I will show You a few screens what is going on.

    First: this is the scene I tried to make it work with OC. As
    You can see it is a market with separated meshes. For the test
    I put 2 huge cube boxes to hide some part of the scene.
    My camera is on the right side.



    So here You can see that when I move my camera the Statue
    on the middle of the market (behing the big box) is
    flickering (and some other objects too). As I start rotate
    is is showing and hiding.






    Another example: I moved back the camera. As soon as I start
    to move the camera towards the big box the second behind him
    is flickering with no reaseon. It is complety blocked and
    should be invisible.






    Another example. My camera is looking into space and the roofs
    are flickering too as I rotate it. The shoud be OFF all the time
    but they are visible.






    Another strange things: when I look just into the ground or sky
    there shoud be visible only the ground (if camera is pointing down),
    or nothing (if it is pointing up). But the buildings are visible.




    Strange things also happens when I go back down below my scene. Some
    objects are visible.



    I tried to make one big occlusion area, a few smaller areas or let
    Unity make the whole level a big one area. I tried different combinations
    with the cell from very small to very large. It is no difference.
    The objects are marked as Static. All is done as it should be.

    Here is a very simple scene with the Unity primitives.



    As you can see when I start to rotate or move the camera the small
    box is some times visible and it should not be.









    Here my camera is pointing up and the ground is visible. It dissapears
    just when I move my camera way up.



    So I don`t have any idea why there are this problems and also with so simple
    settings like 3 boxes. If any one know what is going on with the OC I would
    be very happy because it is a powerful option that I would like to implement
    with my games.

    Cheers,
    Lucas
     
    Last edited: Feb 27, 2012
  2. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
    Well, nobody knows? I thout that occlusion culling is a fundamental function to use almost in every game for optimization purpose. Do only I have such problems? Maybe I am making something wrong?
     
  3. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Please submit a bug report and attach a reproducible project.
     
  4. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    I am having similar problems.

    Although I noticed that occlusion works well when I am on the ground.
    When I go to fly mode (within the boundaries of the occlusion area) everything goes nuts...
     
  5. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Are you using 3.5?


    The most common problem causing occlusion culling to go wrong is if you have backfacing geometry.
    For example if you have backfacing triangles that are visible from behind from a valid position of the camera.



    If you are then please send the project folder as a bug report and post the case number here so we can investigate.
    I would appreciate if you put the camera in a location where it is clear that occlusion culling is not working as expected.
     
    Last edited: Feb 18, 2012
  6. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
    Well, the simplest way to reproduce the problem is to use just the Unity. Make 3 primitive boxes as I made above. Without any extra geometry from other app. Put the camera behind the box and and there will be flickering. Look at my scene with the boxes and try to reproduce it. The camera has no scripts at all. The boxes are from Unity. There is a occlusion are that coveras the whole are where camera can go (as shown above). The settings You can see above. The models are marked as STATIC. Then in the Vizualizatic mode You will see my problems. Also the ground will not dissapear when You look up the camera.

    Well, the backfacking should not be the problem because the camera is not even looking at the models. They are wey back from the camera and even that sometimes they are visible or are flickering. First I divided my meshes by Shaders after that I splitted every single model into a separate mesh - same results. I tried it from the first time You implemented Occlusion Culling into Unity.

    After that I gave me a break with it. A few days ago I tested it with the New 3.5 Final Release because I read that You have rewritten the engine. But I is still the same.

    If You would not be able to reproduce the bug with the simple boxes I will send You my project files.

    Cheers,
    Lucas
     
  7. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Your screenshots say nothing cause you disabled the visualization (all dots gray in the occlusion visualization - select them and they will show their visualization)

    If you enable visualization, they will be much more representative on what is going on.
    Also as you don't use any dynamic objects for occlusion (portals), setting occlusion baking to static without portals (2nd option) will yield the best performance, far lower bake times and less trouble (you use the autogenerate portal baking, which will yield a lower runtime performance than pre 3.5 PVS cause portals didn't exist then, option 2 comes closest to pre 3.5 baking)

    I know that the old as well as the new OC sometimes have their small to big problems as I hammered on that rather constantly since 3.0 already, but in situation like yours it in my test scenarios definitely worked when setup correctly, as such I assume that something is setup in a strange way.
    For example the roofs at worst are a single object in your model in which case they will be visible permanentely as their bounding box surrounds the camera (pvs works on mesh base, not on triangle base -> seperate objects and use static batching, never use the combine children script stuff)
     
  8. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
    Well, as You told me I made these changes to my test boxes. I used now only PVS and market the dots in vizualization mode. You can see that when I slightly move the small box showing up but it should not. Also when I start to rotate the camera everything seem to working fine, the groung dissapear, later the big box, but at certain point the ground is showing up.








    Also some strange things happens when I move the camera far outside the Occlusion area. As far as I know the models should be all visible since I am outside the area but the filickering appears also here:


     
    Last edited: Feb 18, 2012
  9. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    When you are outside the view area, actually the whole world should disappear normally (the same happens if you move the camera inside of static objects which are 'out of world' technically).

    Whats though going wrong in your case is beyond me. I've seen fishy and troublesome things which I reported, but so far never anything like your case.
    How do the same situations look if you remove the View Area? (just to ruleout anything related to that)
     
  10. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
    You mean when I remove the Occlusion Area that I defined and leave the default? Well, when I leave the Unity to default to make the area for me it happens the same.
     
  11. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
    Just tested it on another machine (laptop) - this same happens.
     
  12. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
    Has someone else problem with just the simple boxes or is it happening only to my ? Could someone attach his own screen shots from such simple scene with his own settings, please?
     
  13. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    @Joachim.

    Case 444620. I have inluded an example project.

    In visualization mode, after the camera goes a certain height above the ground (within the boundaries of the occlusion area) , unity crashes to desktop.

    When in release mode, after that same height, although it doesn't crash it goes like 1 fps and most of the objects are blinking randomly.
     
    Last edited: Feb 21, 2012
  14. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
    I read that the Occlusion Culling requires GPU with Occlusion Query support. Well, maybe my graphic card is not good for it? I have a laptop with 9700M GT card and the latest nVidia drivers. Could it be the problem?
     
    Last edited: Feb 23, 2012
  15. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
    I tested it on 2 other machines (one laptop, and one workstation with quadro fx 3450 SDI. It is the same problem.

    It seems that the occlusion culling is not workin at all in Unity3D.
     
  16. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
  17. Neogy

    Neogy

    Joined:
    Mar 13, 2010
    Posts:
    20
  18. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
    Yes, but it is very strange. Even with the Unity primitives with no extra models, scripts or anything. I have tested it on 3 different machines and on every is exactly the same problem.

    But as I see, we are the CHOSEN ONES that have the problem and it doesnt seems to be common issiu because there is no respond from other users. So I guess that it is working for everyone properly.

    Neogy: Could You try to recreate what I have done on Youtube and tell me what is going on on Your computer?
     
  19. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    Last edited: Feb 28, 2012
  20. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
    It is the same problem if it let it automatically.
     
  21. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    I do exactly what you do and it works.
     
  22. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
    So if it works on your computer there must be a bug in Unity. What graphic card do You have? Maybe it is because of it or the drivers?
     
  23. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
    I have tested it on addition 2 more machines (together it was 5) and it was the same... no idea what is going on. On different OS... I have made some boxes in the UDK engine and Dark Basic and the occlusion culling works fine there. So it is not the problem with my card but something with Unity is wrong...
     
  24. Neogy

    Neogy

    Joined:
    Mar 13, 2010
    Posts:
    20
    I am bumping this as I still have issues with the culling and hope somebody out there will have a way of solving this.
     
  25. bhaal

    bhaal

    Joined:
    Apr 18, 2009
    Posts:
    35
    3.5.1.f2 bump
     
  26. krlozadan

    krlozadan

    Joined:
    Sep 18, 2011
    Posts:
    11
    I have the same problem!!! and I can't find a solution, I did make it to work with a new scene with only boxes, but not in my scene!! and it's biutl the same way, only it is bigger. I'm desperate :(
     
  27. bkazour

    bkazour

    Joined:
    Dec 7, 2011
    Posts:
    98
    I am having similar issues on a bigger scene...Plenty of objects are being visible when they shouldn't be.
    In addition, the OnBecameInvisible is not triggering correctly.
    In a test i was doing, i had lights On in a room and i marked the window as static so occlusion culling would not display the elements of the room. and Soft shadows were enabled with no baking.
    If i look at the room from the window, I can see the shadows of the objects but not the objects. Also this should not be happening, the time needed to calculate the shadows when the objects are occluded is a waste.
     
  28. bkazour

    bkazour

    Joined:
    Dec 7, 2011
    Posts:
    98
    I have a funny issue that happens yesterday regarding occlusion culling.
    I added a room to my scene and tested it in gameplay, the frame rate was around 40 fps.
    I extended the occlusion area to cover the room and marked the objects as static and baked the occlusion.
    The frame rate in the room dropped to 14 fps.
    I have no idea why :(
     
  29. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    I've been searching on google because I have this problem to and came across this post.

    I'm have trouble getting Occlusion Culling to work I've read the tutorials, googled it and watched the youtube videos but still can't get it to work at all.

    I tag all my static objects Occluder Static in the Inspector, I've tried setting my own occlusion area and also letting it set one up automatically, like the documentation says - NOTE: By default if you don't create any occlusion areas, occlusion culling will be applied to the whole scene.

    Then I've baked trying it with all 3 settings, PVS only, PVS and dynamic objects and Automatic Portal Generation.

    Then when I run with a window set to Occlusion Culling so I can watch whats going on when I select the main camera and walk around anything out of the field of view disappears as expected, but nothing behind objects disappears, even when I stand right behind a building facing the wall everything the other side is still there.
     
  30. herbie

    herbie

    Joined:
    Feb 11, 2012
    Posts:
    237
  31. herbie

    herbie

    Joined:
    Feb 11, 2012
    Posts:
    237
    My occlusion culling problem is solved.

    There was a game object that messed up the occlusion area. I don't know why.
    Since I removed that game object the occlusion culling is working great.
     
  32. GizmoBradwell

    GizmoBradwell

    Joined:
    Dec 27, 2010
    Posts:
    67
    Yep, generally find the occlusion culling is flakey despite doing it by the book, there's only so many HOURS you can spend with it and remain sane. I'm betting there's a lot more people who have trouble.

    It seems odd that even though it's been re-written it still doesn't function reliably (in my experience).
     
  33. RonHiler

    RonHiler

    Joined:
    Nov 3, 2011
    Posts:
    207
    Another problem with Occlusion Culling: If you have LOD levels on your environment (like I do), it doesn't work at all. It seems only LOD0 will show up, everything else is culled by the occlusion system.
     
  34. Nirvan

    Nirvan

    Joined:
    Nov 16, 2013
    Posts:
    134
    Digging up post but I am so frustrated on Occlusion Portals, they working so random, maybe because I making it on unity beta. I making simple scene with corridor and putting few portals one behind other and when I add 2/3 everything work but when I add more everything starting to mess up, open/close doing nothing etc. many hours wasted :/

    I managed that this is 75% because of beta (not sure because I can't get my level from beta to unity 5.4)
     
    Last edited: Nov 19, 2016