przemyslawzaworski/Unity-GPU-Based-Occlusion-Culling

Managing occlusion on Additively loaded scenes

Opened this issue · 1 comments

Hello i've been using this Occlusion culling utility and it's been working quite good.
However i've ran into an issue when wanting to use the script in multiple scenes, them being loaded additively.

The issue is the following, i'll try to explain.

  1. Upon starting the game, a scene called "GameScene" and "TunnelArea" are loaded. (GameScene contains the player with the Main Camera, then TunnelArea contains the occlusion culling script, cause thats where all the props are).
  2. Upon reaching a trigger, i additively load more scenes, as the map is quite big and i had to split it into areas.
  3. When the new area is loaded, the occlusion script from the "TunnelArea" which was loaded at first stops working, and the one from the new area works. But not both at the same time.

The result is upon loading an area all the props from the scene get culled, which is not the result i would need.

Here's a gif:
https://gyazo.com/583785cfa8ef1d56c740641b8e658d9a (player enters trigger, new scene is loaded additively, culling breaks)

While i try to find a solution by myself i wanted to post in case there's a workaround available :)

EDIT: Currently trying another approach, using the script in the main scene then filling the array with objects from the loaded scenes.

Any help is appreciated in helping make the scripts better. As of now its most likely leaking gpu memory, it shows multiple garbage collector computebuffer warnings in the inspector.

Main Script: https://pastebin.com/D269Lg4F (goes on the scene that's always enabled)
Objects to cull Script: https://pastebin.com/frZR6Fvz (add to each scene, fill the array with the objects to cull)
Editor script: https://pastebin.com/ETgGaZSm