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

Occlusion Culling not Working in one area??? Help!!!!

Discussion in 'Universal Render Pipeline' started by Immersive-Matthew, May 15, 2020.

  1. Immersive-Matthew

    Immersive-Matthew

    Joined:
    Mar 24, 2020
    Posts:
    137
    Everything I have read about Occlusion Culling indicates that static objects that the camera cannot see, should not render. I have an area that no matter what I seem to do, impacts my GPU despite it all being behind a wall. I even tried baking an Occlusion Area to no effect. All my objects are static and have dynamic occlusion culling checked off. It is like the wall is just not there at all. Any ideas as to why this is happening? I have spent days trying to discover what is causing this issue and am flat out of ideas. It is not a single object but rather the sum of them that causes the issues which ultimately impacts my frame rate in an unacceptable way. I welcome any tips you may have as maybe I missed a little option somewhere. I am using the Universal Render Pipeline on 2018.3.13f and my target platform is Android.
     
    ROBYER1 likes this.
  2. sgthale

    sgthale

    Joined:
    Mar 10, 2018
    Posts:
    11
    Same. It's been broken for a while for some reason. I even tried to upgrade to 2019.3 from 2018.1 and it still doesn't even look coherent. Already checked all my flags and objects.
     
  3. IgorBoyko

    IgorBoyko

    Joined:
    Sep 28, 2020
    Posts:
    90
    Might be necroposting but I'll post it here instead of making another thread.

    I have the same issue, but running both Unity 2020.3 and 2021.2, URP 10/12 respectively. Occlusion culling does not seem to work on mobile devices (Android/iOS). How I found this out:
    * Used a device without opaque sorting mode (e.g. Pixel 4A does not sort by default) OR disabled opaque sorting mode if the device used it by default (e.g. Galaxy S21 Ultra)
    * Enabled URP debugger (double three-finger tap on screen)
    * Ticked "Overdraw" checkbox

    What I'm seeing is, the device still renders everything behind walls, even though occlusion culling is baked properly with default settings (tried changing them and nothing).
    Even stranger, editor seems to not have this issue, objects behind walls are hidden properly (both seen in Overdraw mode and Visualzation mode of Occlusion window).
    Dynamically occluded objects are properly occluded both in editor and mobile platforms. So it's only when there are multiple static objects and all of them have static occluder and occludee options enabled.

    My current setup:
    * Unity 2021.2.16f1
    * Additive scenes are loaded fully according to https://docs.unity3d.com/Manual/occlusion-culling-scene-loading.html
    * Baking is done with default parameters
    * All additive scenes are confirmed to be saved, occlusion data is attached there according to files delta
    * Everything is loaded via addressables (even though it has no effect if addressables is not used for testing)
     
  4. IgorBoyko

    IgorBoyko

    Joined:
    Sep 28, 2020
    Posts:
    90
    Update to the post above, but as a separate message so whoever is subscribed to this thread may get a notification.

    The source of all issues with occlusion culling is using Addressables in general. After moving all scenes to main build and loading everything with SceneManager, all the occlusion culling issues are gone. Apparently, as I've researched, it is affected by Asset Bundles, not Addressables itself.

    Currently I have not found any solution to bypass this issue some other way, because moving everything into build means no submission to Play Store as of build size limit.

    Does anyone have any ideas?
     
  5. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    679
    The occlusion system works by baking data to a scene data file, so it makes sense that you cannot use it with assets loaded from an asset bundle. Have you tried making the scene itself an asset bundle asset? I haven't tried this, but maybe it would bring in the occlusion data to the bundle.

    Otherwise, you're better off finding a different occlusion culling system. We ended up rolling our own (it's even burst-compiled!) for dynamic baking and occlusion queries and it's a lot faster than unity's solution. I recommend trying something like that, if something like it doesn't already exist on the asset store.
     
  6. IgorBoyko

    IgorBoyko

    Joined:
    Sep 28, 2020
    Posts:
    90
    Thanks, I've just started developing custom one too. Are you using RaycastCommand by any means? I've noticed that it syncs with physics no matter what I do (Physics.SyncBatchQueries), e.g. can't let the job go to the next frame. If you're using the same method, could you maybe give a hint or two? Thanks a lot.
     
  7. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    679
    I'm not using physics at all for ours. Our game is using a tile based proc gen, so I have useful information such as bounding boxes and the actual readable mesh data at runtime. So my system simply takes the triangles of the lowest lod of all LODGroups under a static prefab and pastes them into the 'occluded' data (a big boy nativearray, organized as an octtree, or mips if you want to think about it like that). This process is fully burst compiled and jobified. The visibility is later done by marking another big native array driven octtree's cells as visible or not by tracing rays thru the occluder native array (this is all jobified too). At reasonable resolutions, I've got this whole process running per-frame on quest 2 without any issues, saving us a lot of rendering time.

    To answer your question about physics queries tho: any time unity's physics needs to do anything related to anything, it WILL sync things, so its possible your batched queries will get called at a seemingly random time. For our project, I have a jobified raycast manager which we just submit queries to and get a response back next frame, and the manager handles the timings of this kind of stuff.

    For a hint as to when you should run it, open up your profiler in the timeline view and see which anything orange (physics) happens. Submit your batched queries after that, and you probably won't need to worry about it until the next orange block in the timeline.
     
    IgorBoyko likes this.