Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How do I use occlusion area correctly?

Discussion in 'General Graphics' started by knas01, Dec 21, 2019.

  1. knas01

    knas01

    Joined:
    Feb 24, 2018
    Posts:
    233
    I have read about this but I can't figure out the concept of how to actually set it up properly.

    My scene is 99% empty and will be filled by moving prefabs once it's running. Some prefabs make a tunnel, some just walls and floor. Now, how should I set it up so only object behind solid walls are occluded correctly while everything is moving around?
    Which objects should have the component on them, only one or several or should it be on a static one?
    What area should be covered by the component, the whole thing where the prefabs will be moving or just part of each prefab?
     
  2. knas01

    knas01

    Joined:
    Feb 24, 2018
    Posts:
    233
  3. knas01

    knas01

    Joined:
    Feb 24, 2018
    Posts:
    233
    Bump, is this feature that obscure?
     
  4. knas01

    knas01

    Joined:
    Feb 24, 2018
    Posts:
    233
  5. kerry-unity

    kerry-unity

    Unity Technologies

    Joined:
    Apr 11, 2016
    Posts:
    4
    Sorry for the slow reply on this!

    We recently reviewed the documentation for occlusion culling, and found that it's very old and, in places, actually incorrect. We're fixing this right now - the new docs are in review at the moment, and should be live in a couple of weeks. In the meantime, I can answer your question.

    - Only static GameObjects can act as occluders at runtime. To enable this, you must flag them as Occluder Static and then bake your occlusion culling data.

    - Dynamic GameObjects can be occluded by static occluders at runtime. To enable this, you must enable the Dynamic Occlusion property of their MeshRenderer component.

    - The documentation for the Occlusion Area component is incorrect. This component does not have anything to do with occluding dynamic GameObects. An Occlusion Area component lets you define a View Volume, which is an area where the Camera is most likely to be at runtime. Within View Volumes, Unity generates higher fidelity occlusion culling data and performs more performance-intensive calculations.

    If you don't define any View Volumes in your Scene, Unity will automatically generate one around your Scene geometry at bake time. If the Camera can't travel to all parts of the Scene, this can lead to unnecessarily large occlusion data file sizes and wasted runtime calculations. If that's the case, you should define View Volumes around the areas where you expect the Camera to be at runtime.

    Hope that helps!
     
  6. knas01

    knas01

    Joined:
    Feb 24, 2018
    Posts:
    233
    Ah I see, thanks for the info.

    Just to make one clear, when you say "where the camera to be" you actually mean its position and not its far plane point and everything between?
     
  7. kerry-unity

    kerry-unity

    Unity Technologies

    Joined:
    Apr 11, 2016
    Posts:
    4
    Yes, that's right - the position of the Camera. I'll make that clear in the docs, too.
     
  8. knas01

    knas01

    Joined:
    Feb 24, 2018
    Posts:
    233
    Thank you.
     
    LILA_Games likes this.
  9. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,268
    What does a Occlusion Area do if "is view volume" is disabled?
     
  10. kerry-unity

    kerry-unity

    Unity Technologies

    Joined:
    Apr 11, 2016
    Posts:
    4
    It seems that the property is exposed for legacy reasons, and (in terms of occlusion culling) it essentially does the same as disabling the component. For clarity:

    If Is View Volume is enabled, the Occlusion Area component defines a View Volume in the occlusion culling data. If Is View Volume is disabled, the Occlusion Area component does not define a View Volume in the occlusion culling data.

    I can't see any use case for disabling this property, but there may be one I haven't thought of. The behaviour is covered in the updated docs.
     
    Last edited: Feb 4, 2020
  11. kerry-unity

    kerry-unity

    Unity Technologies

    Joined:
    Apr 11, 2016
    Posts:
    4
    awsapps, OwlBoy-, Torbach78 and 2 others like this.
  12. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,593
    I cant work out what an occlusion area does, can it be used so that if you look out of a window you dont see any of the geometry out there? It doesnt seem to do that for me. The only way I can achieve this is with an opaque renderer outside the window but then you cant see into the skybox which is what I want. Spent 2 hrs messing, very confusing.

    edit: Occlusion portal works as expected, I got confused between them, still not sure what an Oclusion area is though :)
     
    Last edited: Jan 17, 2021
  13. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,009
    I'm missing information about light and Occlusion Culling.
    And I assume that light behavior cannot be controlled in any way.
    Light marked static or dynamic makes no difference. (I assume I cannot disable light from being an occludee)

    What about occlusion culling and transparency, right now it looks like setting object to transparent will disable object from being an occluder. What if I want my transparent object to be occluder ?
     
  14. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,009
    When you don't add occlusion area It is created by default during baking process. It encapsulate all scene.
    But then you have a big occlusion tree (and memory usage) for algorithm to traverse.
    But when you know that your camera will never trespass some regions you can minimize this burden by placing your own occlusion areas in places where your camera can be.
     
    radiantboy likes this.
  15. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,009
    When I place some Occlusion Areas what will happen when my camera is outside this areas. Since as documentation says volume around scene is created only when there is no Occlusion Areas in scene.

    There is also a question. If I got a scene where camera can free-fly everywhere is there a point in creating Occlusion Areas in some places ?
     
  16. amitDklein

    amitDklein

    Joined:
    Apr 10, 2017
    Posts:
    20

    For what I could find out, if you have an area on a part of your scene it will fill out the other parts but you would probably want to to put areas even with free-fly camera
    "Unity performs higher precision calculations when the Camera’s position is within a View Volume"

    That means, areas help make the occlusion better at the places you put areas in (for example in a free world like let's say a Minecraft server, you would want it in the lobby of your scene to make it preform better but for the other parts you don't need it as much).

    Hope it helps, I am in the process of making a tutorial about those things so I will share it here when I'm finished
     
  17. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,009
    So what it is doing under the hood so it performs better than scene without Occlusion Area ?
     
    OwlBoy- likes this.
  18. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,593
    lol still cant get these to work,
    thanks I finally understood it today.
     
  19. amitDklein

    amitDklein

    Joined:
    Apr 10, 2017
    Posts:
    20
    Hey,
    I just made a tutorial that explains everything you need to know about how to use the occlusion culling
    Let me know if this helps you
    Link to the video
     
    radiantboy likes this.
  20. sdb7

    sdb7

    Joined:
    Apr 8, 2013
    Posts:
    23
    can we define some arbitrary convex volume for occlusion area, my level is consist mesh generated at runtime from point cloud data?