Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

What's wrong with Occlusion Culling

Discussion in 'Editor & General Support' started by Hotsun, Jan 13, 2012.

  1. Hotsun

    Hotsun

    Joined:
    Aug 11, 2010
    Posts:
    122
    Hi,
    I made a big scene with more than 4 million triangles so I baked the whole scene at extremely high quality but occlusion Culling is just working like frustum Culling and even I am behind a static box with 12 triangles it is rendering about 1.4 million triangles and it is very bad :mad:
    I checked manual but I couldn't solve my problem:
    http://unity3d.com/support/documentation/Manual/Occlusion Culling.html



    I can make a little project to show you what is going on but I can't show the original scene.
     
  2. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    I'm facing the same situation. Everything within the frustum of the camera is rendered... It's as if the occlusion culling doesn't work but is a simple frustum culling.

    In my scene I'm currently facing several thousand objects and that's only 10% of the level...

    Several posts in the forum suggest that this is the way the occlusion culling is behaving. I'm even thinking of implementing my own system to turn on/off the rooms in my scene...
     
  3. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    Occlusion works perfectly for me. The only reason I can think of - for it not working - is if the level has been modeled without taking into account how meshes need to be split.

    For instance each room needs to be a separate object from the rest. The floor should be separate too, because the character is always touching it, so whatever is attached to it doesn't get culled.

    Can you show how your level models are split up by moving the separate room pieces apart and taking a screenshot.
     
  4. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    Setting up Occlusion Culling

    In order to use Occlusion Culling, there is some manual setup involved. First, your level geometry must be broken into sensibly sized pieces. It is also helpful to lay out your levels into small, well defined areas that are occluded from each other by large objects such as walls, buildings, etc. The idea here is that each individual mesh will be turned on or off based on the occlusion data. So if you have one object that contains all the furniture in your room then either all or none of the entire set of furniture will be culled. This doesn't make nearly as much sense as making each piece of furniture its own mesh, so each can individually be culled based on the camera's view point.
     
  5. NTDC-DEV

    NTDC-DEV

    Joined:
    Jul 22, 2010
    Posts:
    593
    If you want an alternative, search for M2H culling, it's a free plugin made by a unity user that is extremely easy to implement and gives pretty good results. It also gives more flexibility as of what you want to cull / show.

    But the basic principle is the same as Koyima said, you need to break you scene down into smaller pieces.
     
  6. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    Well it doesn't matter which solution you use if you are doing something else wrong in the first place, right?

    Occlusion culling has been working correctly for years now and if you have access to it you have Pro, which means you have paid for it. Why not use it then? It's built-in, updatable etc and it works and everytime I see a thread on occlusion like this I do a facepalm.

    One guy is even complaining it isn't working correctly on his massive multiple terrain scene (which is not supported out of the box) and says he found a work-around (when he is already using a work-around to do something) and he expects Unity to fix this, he even calls it a bug. So if someone is using a work-around and that work-around isn't compatible with normal operations it's still a bug? Anyway same person says it's a bug if you can'y have more than 70.000 trees on a terrain when a terrain looks full at 40.000 trees...

    I can keep going on about things that people think are bugs, but they actually don't know how to setup correctly... I'll stop here.
     
  7. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    OK... 3.5 enables you to show the rays that are used to determine the occlusion culling determination. I see some of them go through a wall (I have the same project in 3.4 and 3.5; and 3.5 behaves better than 3.4).

    I have put each room into a separate object (so, the room and all it's objects are sub-objects of that room). And I can manually hide the entire room by disabling the room parent object.

    I set up the occusion areas to only include one room with an intermediate occlusion area in the door area (in order to connect the 2 rooms because otherwise, if the occlusion areas aren't connected, they would (should) disappear when the door is opened). Nevertheless, in the scene view I see objects in an adjacent room that are clearly behind a wall (wall between object and camera) and which only disappear when they get out of the frustum of the camera.

    But perhaps I have a wrong understanding of the occlusion areas?
     
    Last edited: Jan 13, 2012
  8. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    can we see a sceenshot with wireframe or file. Just the walls (floor and ceiling) would be fine, no textures.
     
  9. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    Hi,

    sorry for the delay... Week-end time :)

    You can see the shots of the first 2 rooms here.

    Please share your thoughts about how to improve this for a better occlusion culling.

    Thanks.
     
  10. larvantholos

    larvantholos

    Joined:
    Oct 29, 2009
    Posts:
    668
    Hey I didn't know this, awesome, this makes so much more sense for some of the modular stuff I am doing, thanks for taking the time to write this out.
     
  11. runner

    runner

    Joined:
    Jul 10, 2010
    Posts:
    865
    bootcamp-postmortem Video talks about the view fulcrum culling and baked occlusion culling, Interesting watch
    the bootcam demo project is in the asset store.

    and the documentation

    hopefully you will find something of use i mention the bootcamp demo because of the culling scripts contained
     
  12. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    It's pretty diificult to troubleshoot occlusion from screenshots. On first glance I would move the rooms further apart. Generally the occlusion system works on a grid system, you have to give it some space to work with as in the screenshot.

    You see Umbra will create a bunch of boxes

    it hides/unhides whatever is in the boxes. It generally understands how to create the boxes, but if two things are on the border it won't hide them as you want or expect, it will do it based on math (overlap mean it will show)

    Basically walls have thickness, take advantage of that fact.
     

    Attached Files:

  13. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    It is pretty simple to write a custom script that would hide/unhide rooms based on your setup though
     

    Attached Files:

  14. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    Hi...

    actually, I take advantage of the walls since I set up my occlusion areas in a way that the doors between them are the connecting passage (the occlusion areas of the rooms do not touch).

    And I also understand that the entire room mesh is drawn, when the red room is even barely visible through the door.

    My problem is, that objects, that are behind a wall (and not visible by the camera) are still drawn.

    I've made tests with Unity 3.5 and it behaves much better in the exactly same scene.

    But I think that I will need to include a enable/disable script, because lights are not culled (at least, they don't seem to) and I have A LOT of them...
     
  15. NTDC-DEV

    NTDC-DEV

    Joined:
    Jul 22, 2010
    Posts:
    593
    I'm sorry but I don't get your point here. First things first, I do say that he must follow your advices... so why are you re-iterating that?

    Secondly you are wrong about Umbra; it doesn't work that well in complex scenes and you can't even do scene compositing with it which is simply horrible if you are trying to stream/integrate content from scenes packed into asset bundles or just use LoadSceneAdditive. We did pay for it and it didn't work and it was very frustrating. Don't try to sell it as a perfect solution, it isn't. Also it has only been out as an integrated Pro feature since 3.0... which came out a little over a year now, not "years".

    For more info about it shortcomings you can look at this thread, there are many more around the forums for which users just stopped asking Unity for help as Umbra was almost completely unsuable until 3.5, this one is about the current beta version.
    http://forum.unity3d.com/threads/116784-Occlusion-still-with-some-problems-it-seems...

    M2Hculling addresses a lot of these problems, though it is not perfect it is a good alternative and worth looking at if Umbra doesn't suit you.

    @Metron; 3.5 has a completely re-writen Umbra integration so it will behave differently than 3.4. Though we don't know when 3.5 will come out, I would suggest you focus your efforts to make you project work with Umbra in 3.5. Like I say above, pre-3.5 Umbra has serious problems.
     
    Last edited: Jan 16, 2012
  16. Hotsun

    Hotsun

    Joined:
    Aug 11, 2010
    Posts:
    122
    After all I managed to do everything by my hands and I made lots of triggers with scripts which will disable the mesh renderer of other objects in other places but I will replace them with new oc in Unity 3.5 after it's final release.
     
  17. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    There should be a workflow to do this, it might not be the best, but it's not the default scenario either. I have seen the other threads, I have yet to see a normally setup scene that doesn't work. If you are trying to do something different than normal procedure (make scene, bake OC), then you obviously have to change how you do things.

    Umbra is a system, doing things in the right order is important, especially when you are not doing what is expected behavior.

    You see when you use a method like asset bundles or loadadditivescene it makes perfect sense that where the baked info is stored is very important. This means you have to do things in a certain order so the Umbra info is where you need it (in your main scene).

    Now I understand that figuring out this order should be documented (especially under asset bundles and loadadditivescenes) so that all your frustration would not exist, but this is a tool and as with any tool, using in it for normal procedures is usually succesful, but doing something "slightly" different like "loading additional scenes with conflicting data" should take into account the complications of this "slightly" different scenario.


    It's like say:
    trying to merge characters in a scene, but everything has the same name (bones,rigs etc) , if someone hasn't anticipated that everything will have the same name and code is based on names (GameObject.Find("Mario") you will have two characters doing the things you want only one to do, right?

    How can you understand that this scenario is NOT the fault of Unity, but in a similar situation in which you have to merge similar data it's Unity's fault for NOT anticipating what you want to do.

    As with any data merging, steps have to be taken in order to make sure that said data can work, I think a workflow for these situations should be explained or made into a wizard to avoid further rage/rant posts.
     
  18. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    Actually I'll mention the steps here (there a few ways to do this).

    - First you need a scene in which everything you have made and want to load is in - Master Scene

    - Bake Umbra Occlusion (now this data is baked and is saved in master scene) - Make sure it works, as expected.

    - Deciced how you want to divide your mega scene up - Usually in big even chunks 2x2, 3x3

    The idea is to keep the Umbra data in the main scene and only have the objects in the scenes to be added

    So in the end you will have :

    - master scene (something like a raw file)

    - initial scene with all umbra data and all chunks deleted, this also has your system for loading areas (be it triggers or whatever)

    - 1 scene per additional chunk, this chunk won't contain Umbra data, if it does, clear it. These are copies of the Master Scene, but we have only kept what we want in that chunk, the rest is deleted.

    - as you move from area to area and the chunks are loaded the data from Umbra is in the initial scene and works with the loaded assets, even if they aren't in the scene now, they once were and we baked that

    - umbra data isn't touched with LoadAdditive and such, it is neither loaded or unloaded with these command, it just has to be there from the start.

    This is not a workaround, it's just common sense and I have tried it and it works, although I didn't try on a massive scene with 8x8 terrains, since I haven't got one lying around. Maybe i will make one during the weeked (with trees and some mokup buildings)

    Of course some of you may argue that baking umbra for each scene and then loading it up would be best, but that would mean that occlusion data woould be modified, which is not all that nice technically.

    Now a great addition to this would be a "Save Selected" button, when you press it everything selected is saved in a new scene, but I guess the Save Selection feature can work just the same.
     
    Last edited: Jan 18, 2012
  19. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    And thats actually where you fail to understand the fundamental problem from start to end on why Umbra is not what the PR implied since pre 3.0.
    Umbra fails to build even single halfway visually appealing and complex scenes, its totally unthinkable to assume it would be possible to bake geometry worth multiple complex scenes in a single scene to overcome the streaming problem.

    And the standard first hint you normally get from smarty pants to overcome it, 'make your cells larger' would be a reason to add someone to the block list. If I didn't want to use occlusion culling on a workable scale, wanted to see and render by far too many polygons, I wouldn't have wasted hours baking OC, would I?
    I don't configure the stuff I do it cause I love waiting for hours before I can switch scenes again, I do it cause its needed to work well enough to run on the target hardware smooth at all.
     
    Last edited: Jan 19, 2012
  20. NTDC-DEV

    NTDC-DEV

    Joined:
    Jul 22, 2010
    Posts:
    593
    @Koyima ( with response to dreamora)

    (By the way, I know it "works", I tried it too and it's in the link I posted above but it seems you didn't read it so let me go into details)

    Optimization: The thing is, it is not practical at all to use Umbra in such a matter. First it is not optimized for optional data. By that, I mean projects where you want to have on-demand data/scenes which aren't ALWAYS used. Baking all OC data in a master scene which can only "Potentially" load other scenes is like saying: I'll load ALL the textures of ALL my scenes into memory IN CASE I use them. I don't need to explain how bad that is.

    Feasibility: What dreamora said plus... That master scene will be extremely complex by definition. You'll have indoor, outdoor, complex, simple all put together even though your scenes are made to separate this. Let's say you created your project so that the main scene is an outdoor environment that has multiple complex indoor scenes. In terms of optimization, workflow, asset management, loading time and I can go on... this makes perfect sense. Yet it complicates Umbra's baking for no reason to the point it doesn't work well at all.

    Workflow: Rebaking everything for each small little change by each developer. Really?... I think you just wrote the worst workflow idea ever created; I don't understand how you can be serious about something like that. Even baking lightmaps is per scene.

    So, lets recap all of this. Right now, with Umbra in Unity you cannot practically use OC if your project:
    - Contains complex environments (simple all indoor = fine, simple all outdoor = fine... mix of both is terrible)
    - Implements an effective multi-developper workflow (because any changes requires complete re-bake/re-compilation due to the centralization)
    - Dynamically loads scenes; not all content is in 1 scene (because it requires to have a master scene)

    The fact is, people who WANT Umbra's OC are people who want OPTIMIZATION. Thus, they separate content in an intelligent way, stream it and make logical decisions in terms of workflow because it's mostly big projects and they want to be productive.

    Yet Unity advertises Umbra as a good professional solution for such projects. I have to say, though it has improved tremendously in 3.5, I can't imagine this being the case yet. And all of that is because you can't have scene composition...
     
    Last edited: Jan 28, 2012
  21. Hotsun

    Hotsun

    Joined:
    Aug 11, 2010
    Posts:
    122
    I was working with Occlusion Culling but after baking all of my scene it made lots of problem for me,While I am walking in my scene which is a very big city sometimes some models won't render and in an area just everything goes off except the skybox.

    http://s2.picofile.com/file/7275477418/OCC_problem.jpg
     
  22. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    My explanation didn't require you to load all the textures into memory for runtime, but only for baking Umbra. As you know a computer doesn't know anything, you have to feed it with information.

    Expecting an Umbra bake to know if you will potentially load something - it has no knowledge about - is ridiculous at best.

    You have to give it that information somehow, now this is possible with the workflow I explained, it will also require
    you to re-bake when people make changes, but that's why there are weekly builds, daily builds etc. You have to streamline your workflow when projects become large, tools only do part of the job, organizing yourself and the team is the rest.

    If you want to Optimize, you have to understand the current rules or write a tool that behaves as you want it too. Just because you don't like it or it doesn't fit your current project doesn't mean it's not professional.
     
  23. NTDC-DEV

    NTDC-DEV

    Joined:
    Jul 22, 2010
    Posts:
    593
    The texture example was that, just an example. It's just comparing a similar lack of optimization in two situations. I wasn't implying this specifically was what you were talking about but just that it is generally a very bad practice to put all the eggs in the same basket.

    Now, I am not expecting Umbra to magically detect and bake potential content. It is ridiculous and you misunderstood me. However, a good thing that Umbra already have is the portal implementation that allows OC to be somewhat controlled.

    (Maybe expending on that portal implementation) I wish Unity can help implement PER-SCENE PVS Baking. That way, it:
    1) Makes Umbra baking a lot more efficient because scenes separate content logically (exterior, interior, closed, open, ect). Simply put; Umbra has problems with complex environments

    2) It creates a very flexible workflow by default; the dev team isn't hostage to one technology not working with something that is fundamentally a core feature of Unity: Scenes (I think it is the only one in Unity that isn't scene-based really?... as Beast is scene based too)

    3) It's extremely scalable, thus is easy to optimize (bake OC on what you want... Just give the control to the user to either show/hide objects not part of that PVS "set" when he enters the portal)

    Right now, any type of project that uses scene composting/multiple scenes will not see any ROI implementing Umbra's OC unless it is a very small project, which mostly defeats the huge potential of OC. That is why I believe it's unprofessional.
     
  24. Deleted User

    Deleted User

    Guest

  25. Millipede

    Millipede

    Joined:
    Feb 28, 2013
    Posts:
    23
    I agree completely... it's not usable at ALL because of these limitations.. I only just discovered this recently:
    http://forum.unity3d.com/threads/21...th-loaded-scenes-levels?p=1457888#post1457888
     
  26. Millipede

    Millipede

    Joined:
    Feb 28, 2013
    Posts:
    23
    ^ That doesn't have everything I need.... it assumes that all scenes you'd ever want to bake are all in one giant seamless world. What If I have multiple scenes that are completely different environments, how am I meant to bake all of that OC data for all environments into one master scene... thats ridiculous!
     
  27. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    641
    Losing the old PVS system was really bad news for the mobile project that I'm working on. It was far from perfect, but gave us at least a bit of a performance gain.

    The new system might be more effective in some situations, but on mobile it's very easy end up with *worse* performance with occlusion culling on, as the CPU cost is very high, and you need to be culling a significant percentage of your scene to cover this cost.

    If you've got a fairly low-detail and not-too-big scene, where you're not occluding a huge percentage of it, you can end up with a big performance drop, in cases where the old PVS system was at least a small performance gain.

    In cases where very little is culled, I've seen 20ms of CPU time spent culling (and about 20ms spent rendering) on a Nexus 7. Yes, adjusting the bake parameters does help in some cases, but not enough to turn a big loss into a gain.
     
  28. musicartslao

    musicartslao

    Joined:
    Nov 9, 2013
    Posts:
    13
    I receive an error message :
    "Loading deprecated Occlusion Culling is not supported. Please rebake the occlusion culling data."
    trying to open the "Tutorial Start" to follow this:

    Any clue ? I am on version 455f1/Win XP SP3

    Thanks for any help.
     
  29. musicartslao

    musicartslao

    Joined:
    Nov 9, 2013
    Posts:
    13
    I just solve my problem by: rebaking the occlusion culling data:
    1 -Window/Occlusion Culling/
    2 - Object/Scene Filter/All
    3- Bake/Bake

    Hope this help someone else out there !
     
  30. Hotsun

    Hotsun

    Joined:
    Aug 11, 2010
    Posts:
    122
    I started this topic about 3 years ago and now new versions of Unity have really good occlusion culling and I have no more problem with it.

    Thanks everyone.
     
  31. msklywenn

    msklywenn

    Joined:
    Nov 28, 2014
    Posts:
    67
    I know of something very wrong with occlusion culling : it would be nice if m_PVSData wasn't stored in the .scene file but in a separate file. My computer froze twice while trying to merge two scenes with different occlusion data... (Core i5 4690K, 8GB, sourcegear diffmerge which has inline merging...)