Using colliders to handle large scene visibility

Hi,

The platform tutorial mentions that in very large scenes, its useful to hide far objects, because culling them out each frame is expensive.

I tried implementing this method in the following way :

  • Created layers for my objects and 3 visibility layers.
  • Created three children on the camera, giving them each of the visibility layer, with a sphere collider of different sizes.
  • Used the collision matrix to control which object layers become visible at which distance
  • Attached a script to the spheres that enables object renderers on OnTriggerEnter, and disables the renderers in OnTriggerExit.

Also, in the beginning of the scene, all objects have their renderers disabled.
So, when an object enters its visible range, I’ll get the OnTriggerEnter and enable its renderer, and the parallel thing when leaving the range.

The problem is : I need to attach a rigidbody to the spheres or I don’t get the trigger messages. When I do that, my performance gets a huge hit - Physics.Simulate takes about 50% of the frame time (up from 6-8% before this technique).

I tried doing it the other way around - attaching rigidbodies to the objects in the scene, but then I didn’t get the trigger events in the right places. (According to Unity - Manual: Mesh collider component reference I should get triggers, but I don’t)

Does anyone know if this trick can be performed in large scenes without paying a big performance hit in Physics.Simulate? Are there any other methods?

Another technique is to use more than one camera at the same location with the clip planes and culling masks set up to ignore unimportant objects when they are at a certain distance. This is explained in more detail in this thread.

That looks like it can also be done with 1 camera using the layer cull distances, which is what we currently use.
However, we still get a performance hit due to culling.

The initial solution was to use Umbra’s occlusion culling, but it culls out some visible objects (I opened a bug but it was not addressed yet).

So, I wanted to do some simple culling on my own, and disabling/enabling objects once every X frames based on distance, so that they wouldn’t have to be processed each frame. But that didn’t drop the performance hit of the culling either…