Search Unity

  1. Unity 2019.2 is now released.
    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:
    1,851
    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:
    609
    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:
    1,851
    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:
    609
    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:
    1,851
    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:
    1,851
    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:
    1,851
    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.