Search Unity

  1. 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
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

ProBuilder Occlusion issue with ProBuilder

Discussion in 'World Building' started by dgoyette, Apr 6, 2019.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,673
    I reported FogBugz report #1143875 on this, but I figured I'd post it here. The bug report contains a repro project, but the basic idea is that Occlusion Culling seems to be flaky with PB objects. I can start with a single static PB object and everything's fine. But when I start adding additional objects to the scene, the Occlusion Culling bake starts seeing through the PB objects. Here's an example from the repro project showing how the camera can see out of the room on the left, despite it being static. Some of the visibility lines are blocked, but many of them make it out.

    I'm not 100% this is necessarily PB related, but I've only been able to reproduce this behavior on PB objects. Other Unity primitive meshes, or other FBX meshes, seem to work fine. I'm not sure whether this behavior is a weird interaction between PB and the occlusion culling system, or whether this indicates something else is going on.

    upload_2019-4-6_19-27-10.png
     
  2. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    712
    Hi! I tried some tests just now, and it appears that using a "inside-out" shape requires a higher level of occlusion detail - in my tests, setting the "Smallest Occluder" value to 2 worked well in shapes like this. I tried with both a PB object, and an identical OBJ object. Can you give that a try?
     
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,673
    In general, a single PB object in the scene works fine. I made a complex inside-out shape, and if it's the only thing in the scene, occlusion works as expected on it, and none of the visualization lines get out.

    Things get weird when there are multiple PB objects across multiple occlusion areas. I made a video showing what I'm seeing, since it's probably hard to explain. This is a video of the repro test project I included in the bug report, by the way.



    In the video, you can see that occlusion for "Room1" works as expected. despite the weird shape. But when I move the camera to Room 2, it starts behaving weirdly. Visualization lines escape, or get blocked by empty space. It seems that the exact behavior depends on how many other occluder-static meshes exist in the scene.
     
  4. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    712
    Hey! Sorry for the long wait - I'm not an occlusion expert, but from watching it seems to me that the occlusion zones are too large, and overlap with inside/outside positions. So as the camera nears the wall/ceiling/floor, it enters a zone that is partially inside and partially outside, which makes the occlusion "fail". Sorry if I'm misunderstanding, but perhaps you can try upping the occlusion resolution?
     
  5. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,673
    More details on this, as I understand it better.

    First, I turned off the Occlusion Areas, as they're irrelevant to static occlusion culling, and I forgot those only apply to dynamic objects.

    If I don't use any Occlusion Areas, it appears that things work fine with default settings. (Smallest Occluder = 5, Smallest Hole = 0.25) None of the visualization lines escape. See how nice the Camera Volumes look under default settings. (The camera volumes are those white lines that seem to hug the surfaces really well. I'm not really sure what they do, but they look good here!)

    upload_2019-4-17_15-51-6.png


    Anyway, as soon as I start changing those settings, the camera volumes start looking really messed up. Here's the same thing with Smallest Occluder set to 4 instead of 5:

    upload_2019-4-17_15-53-11.png

    Those camera volumes are all messed up now.

    It's important to note that this is the 3rd PB object in the scene. The other two objects have good camera volumes on them. If I disable the other two, and bake again with Smallest Occluder = 4, now the camera volumes look fine:

    upload_2019-4-17_15-58-9.png

    I'm going to see how things go just using the default occlusion settings. I don't know why it seems to work with Smallest Occlusion = 5. Maybe I'll find this also fails in some cases, and it's just a coincidence why it's working right now. But the camera volume generation definitely seems weird in the screenshot above...
     
  6. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,673
    Unity QA just closed out my issue (1143875):

    "Upon further investigation, we have discovered that this is not a bug. The visibility lines are aligned with the Game View. To fix your issue, just change resolution in the Game View Window."

    I've replied asking that the issue be reopened. This is still an issue in 2019.1. QA's response that I should change the resolution in the game view doesn't make any sense, and I'm assuming they missed the point of the problem.

    Is there anything else I can provide to make this more clear? Can someone explain just how broken the Camera Volumes look in the second screenshot in my previous reply in this thread?
     
  7. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,673
    This issue is, unfortunately, still open, and unresolved. In the meantime, I abandoned efforts to use occlusion culling, since it empirically just doesn't work properly when the scene contains three or more static PB objects. However, I figured I might try again, because maybe in some cases it might behave properly, and would hopefully be no worse than no using occlusion culling at all.

    However, upon reinstating occlusion culling in my scenes, I've found another problem with occlusion culling and PB objects, this time related to using Occlusion Areas to cull dynamic objects. In short, the presense of an Occlusion Area in my scene is causing static occlusion to be baked differently resulting in erratic/random static culling behavior.

    Here is a view of one of my scenes. The part is red contains the only Occlusion Area in the level. This is quite far away from the area in circled in blue, where the "problem" is occurring.

    upload_2019-8-11_10-38-12.png

    So, now the problem. If I disable the Occlusion Area and bake occlusion, I get the following results:

    upload_2019-8-11_10-40-41.png

    Now that's actually fairly terrible, as all of the visibility lines are cutting right through the probuilder objects, and essentially not occluding at all. But that's the issue described in 1143875, which hopefully someone will look at. But the new issue here occurs when I enable the Occlusion Area half way across the level, and rebake occlusion:

    upload_2019-8-11_10-42-12.png

    Note that there is now effectively what seems to be an invisible wall right in front of the player, occluding static objects behind it. So the addition of the Occlusion Area for dynamic occlusion has broken static occlusion even worse. It's a combination of two really bad results: First, the visibility lines still cut through the ProBuilder geometry, which causes far away objects not to be occluded, and second, this weird Occlusion Portal behavior is now occluding static objects that are directly in front of the player, causing them to pop in and out of view as the player moves slightly forward and back.


    In short, occlusion culling with ProBuilder objects in the scene just seems to be a real mess. I haven't seen anyone else complaining about this, so I don't know if people generally don't use occlusion culling, or whether if they do, they just don't use PB objects.

    I would like to be more actively involved in a solution for this, as I use PB for level geometry in most of my levels, and this behavior is really killing me in terms of performance.
     
  8. icefallgames

    icefallgames

    Joined:
    Dec 6, 2014
    Posts:
    47
    Slightly old thread, but you're right, occlusion culling is really broken in Unity, and no one who works at Unity seems to understand it. It's strange more people don't complain about this, so I can only assume few people use this feature.

    We have several levels where occlusion culling just doesn't work at all (it just behaves completely randomly, occluding objects right in front of the player), and on the levels it does "work", it frequently sees through probuilder objects (most of our walls/floors are pb objects). I just realized this now because of finding this post - and I just tried placing extra "walls" (just Unity cubes) behind the pb walls, and lo and behold... occlusion culling actually worked as expected. Walking around our levels now and looking at the view lines, it's really obvious it doesn't work well with pb objects - another example of two Unity features not playing well together.

    As for OcclusionAreas, they seem to have no effect whatsoever. I don't believe the Unity documentation on them is correct - I don't think they have anything to do with dynamic objects. Intel's documentation doesn't mention that anyway. As far as I can tell, they are used to limit occlusion baking to those regions of the levels that are covered?
     
    Last edited: Feb 7, 2020
  9. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,673
    Unity QA went back and forth with me forever on this issue. Their final response was:

    This is despite having given them three videos showing the incorrect behavior, including super easy ways to reproduce this in just a few steps:


    However, the reason I finally dropped this was because, at least so far, it seems that the issue doesn't occur in my normal level setup, where the geometry is generally fairly regular in terms of units. So, even though this is easy to reproduce at a small scale, I have several large levels containing dozens of static PB objects for the geoemetry in each, and occlusion isn't misbehaving in any of those levels.

    In short, I don't know what's up with this weird occlusion bug, but in my actual levels, it's not causing me any problems.

    I do remember occlusion areas messing everything up, so I stopped using them. Maybe I'll revisit that in the future. I believe occlusion areas are just to address dynamic objects. I don't use any at all right now, and my static geometry occludes just fine. They also don't appear to limit the baking to just their volume, at least not in my simple test. Here you can see a couple of occlusion areas on the top left of this volume, but after baking, the bake takes into account all of the level geometry, even that part not in one of the occlusion areas:

    upload_2020-2-7_9-56-11.png

    Anyway, occlusion culling is still a bit mysterious to me. There are definitely some weird scenarios that can pop up, but maybe the issue is less known/understand because under typical circumstances, things generally work.
     
  10. icefallgames

    icefallgames

    Joined:
    Dec 6, 2014
    Posts:
    47
    I can actually repro all these issues in a very small level. Just having some probuilder cubes "nearby" is causing all sorts of occlusion errors.

    I have a regular "room" composed of 6 flattened unity cubes on the left, and then 3 probuilder cubes nearby:

    Cubes.PNG


    Baking occlusion for this level, and placing the camera in the room on the left, occlusion is just completely broken. The visibility lines extend out beyond the room:

    Visibility.PNG

    Now it would be one thing if things were just "leaky" and rendering too many things, but depending what direction I face, the walls of the room I'm in vanish. There is some invisible wall within the room I'm in:

    TooMuchOcclusion.PNG

    TooMuchOcclusion2.PNG

    All the problems go away if I delete the 3 probuilder cubes (or actually any single one of them) - even though they are further away than the granularity of the occlusion bake.
     
  11. icefallgames

    icefallgames

    Joined:
    Dec 6, 2014
    Posts:
    47
    In short, occlusion baking can just be completely broken when there are probuilder objects in the scene.

    for reference, the room is about 20x20 units across, the cubes are about 14 units each side. The smallest occluder is 2, smallest hole is 0.25

    It's interesting to note that the "occlusion voxels" generated have a resolution of 4x the smallest occluder. I would think they would be the same size as the smallest occluder?
     
    Last edited: Feb 12, 2020
  12. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,673
    What you've shown is nearly identical to the case I reported. You can look at the videos I linked in my previous post and see basically the same kind of thing. And I agree that it's really easy to reproduce this. That made me think occlusion was completely unusable.

    However, what I've found is that in my actual levels, where the geometry is usually more regular, I have no occlusion problems at all. I have several large levels with dozens of static PB rooms in them, and occlusion bakes just fine. So, even though it seems easy to cause these occlusion problems, do verify whether it's actually a problem in your real levels.
     
  13. icefallgames

    icefallgames

    Joined:
    Dec 6, 2014
    Posts:
    47
    Oh, it's definitely a problem. We have several sections in a number of our levels where occlusion completely flakes out (as if you're inside a solid object, just like my little repro). To get around this, we currently have regions where we need to turn occlusion culling off on the camera when you're inside them, and try to shrink the farplane as much as possible. It's really tedious.

    And it's not any one object that's causing the problem... it's only when you have a sufficient number of "bad" pb objects somewhere nearby that it starts happening.
     
  14. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,030
    I've encountered a similar problem in an archviz scene. Occlusion culling is working, but I have an occlusion portal that once worked but suddenly has been ignored since making some changes to a PB object that the portal is supposed to pierce. I don't know what triggered the portal to become ignored, but I'm probably going to have to just run without occlusion culling on the main camera.
     
unityunity