Search Unity

  1. Dismiss Notice
  2. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  3. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  4. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Occlusion Culling flashing when moving between Occlusion Areas

Discussion in 'General Graphics' started by RichTufty, Nov 1, 2020.

  1. RichTufty

    RichTufty

    Joined:
    Jul 12, 2012
    Posts:
    13
    I have been getting what I thought was a random white flash when playing, (looks like for a nano second a lot of scene objects turn off and on again). I've been able to realise when this flash happens, it's when the player moves from 1 Occlusion Area to another. The areas are overlapped, so there aren't any gaps, the player is always in 1 or 2 occlusion areas at any one time. The rest of the time the occlusion culling is working great.

    Is this a bug or am I setting up the occlusion areas wrong?

    My understanding is that you place the occlusion areas where the camera is likely to be to reduce the amount of data baked. So I find it strange that moving between areas would have this effect.

    I am using OpenVR / SteamVR with a Valve Index. Any help would be massively appreciated!

    Many thanks,
    Rich
     
  2. RichTufty

    RichTufty

    Joined:
    Jul 12, 2012
    Posts:
    13
    OK so with further investigation, it's a coincidence that the flicker seems to be when moving from one Occlusion Area to the next.

    It turns out, I'm getting a wild cull in 1 eye, as if there is an invisible object in from of one eye causing half the scene to cull, whilst the other eye is rendering/culling correctly. It only happens for a split second whilst moving. I can stand in a single point and see the single eye cull whilst I slowly move my head.

    This happens in a handful of places in the scene. I cleared the culling data, and I don't get the flickers. I've tried multiple culling values for the bake, and I get exactly the same flickers each time I use the occlusion culling.

    Has anyone else experienced this issue? Is it an occlusion culling bug? Using Unity 2019.4.1f1, OpenVR / SteamVR + Valve Index.
     
  3. RichTufty

    RichTufty

    Joined:
    Jul 12, 2012
    Posts:
    13
    I have managed to capture an example of what's going on to help explain my problem...

    I'm displaying the current Occlusion Visualization in the scene view - you can see that the row of houses to the left are visible, and even showing in the Camera Preview. I'm assuming this camera is the left eye.

    In the game view, which is the right eye, the row of houses are culled.

    This happens for a fraction of a second. It happens in a handful of places in the scene.

    I don't see the flash running in single camera or if I clear the occlusion culling data.

    I've tried to bake with different settings, and moving the occlusion areas.

     
  4. TheFluffyMane

    TheFluffyMane

    Joined:
    Feb 8, 2020
    Posts:
    4
    Hello @RichTufty ,

    It looks like it is a VR issue, I found only a few people facing it but they are all using VR in different version and with different tools / headsets

    https://forum.unity.com/threads/occlusion-culling.905579/

    I am facing the same "flashes", where Unity suddenly decides to cull out a lot of objects when they should clearly appear on screen.
    I am personally using Unity 2019.4.3f1, XR Plugin, Oculus Rift.

    However I would like to add two things to what you pointed :

    - The flash happens when the player is moving from a Camera Volume to another (the yellow boxes you can see in the Occlusion Culling visualization window) and not from an Occlusion Area to another.
    It seems like Camera Volumes are generated during bake time, and I have always faced the same Camera Volumes, whatever how many Occlusion Area I had placed in my scene.

    - For me the flash happens in both eyes in the headset, when playing in editor or in build.
    However the scene view and Occlusion Culling Visualization window do not seem to show theses flashes.


    Please let me know if you find a solution to this problem.
     
  5. TheFluffyMane

    TheFluffyMane

    Joined:
    Feb 8, 2020
    Posts:
    4
    Ok,

    So this might sound quite stupid as I thought I had tried playing with the camera values before, and we probably all tried many complicated things, but inscreasing slightly the Near Clipping Planes of my camera solved the issue.

    I set the Near Clipping Planes from 0.01 to 0.05 and the flashes seem to have disappeared. (needed value might differ by a little on your projet).

    Let me know if this solves your issue.
     
  6. RichTufty

    RichTufty

    Joined:
    Jul 12, 2012
    Posts:
    13
    Hey @TheFluffyMane thank you for posting your update here, nice to know it wasn't just me going insane with the issue.
    Yes I realised above that it was a coincidence that the occlusion area edges happened to be in line with the occlusion volumes.
    Because it was such a big problem (making users feel sick) I had to urgently resolve the issue and basically wrote my own culling system. Which now doesn't have the flashes.
    Now... I didn't try changing the Near Clipping Planes, next time I'm in the project, I might give it a try to see if it does fix the issue. As it happens, the new culling system I wrote gives me more control over the scene with what is and isn't shown so I'd stick with it, but for future projects that's great to know you managed to solve it.
     
  7. JorgenFreeman

    JorgenFreeman

    Joined:
    Dec 13, 2012
    Posts:
    2
    Thank you for this, I was having the same issue and this seems to have fixed it for me. I have no idea why this happens, although a too-small near clipping plane does seem to cause a variety of fun issues in Unity.

    It's worth noting that another symptom of this particular problem is that the occlusion culling in the scene view visualisation looks just fine, even when the camera is in a position where the objects are visibly disappearing. So the scene view occlusion and the game view occlusion are different; presumably the near clipping plane is interfering with the calculated culling somehow to affect the render.

    When increasing the near clipping plane gradually from 0.01 to 0.05, I saw more of the incorrectly occluded objects gradually re-appear, while the camera remained in the same position.

    Not sure if this has resolved the issue in all cases yet, I'll check back in if I see it happening again.
     
unityunity