Unity Frostrum Culling in top-down or isometric view

1k views Asked by At

I've encountered an issue in Unity which prevents it from culling off-camera objects in top-down or isometric views due to shadow-casting.

The directional light is diagonal, so any object outside the camera view in the direction from which the light comes from can potentially cast a shadow in the camera's view. Now, in reality, almost all these objects will only cast their shadows inside the camera view far below the ground, so they don't really need to be rendered. However, Unity doesn't know that, and it renders them anyway for their shadows, decreasing performance significantly.

enter image description here

I tried solving this with Occlusion culling. I created a huge plane at ground level, marked it static, and baked occlusion culling for this object, so that anything under ground will not be rendered. Unfortunately, this doesn't help, all those objects whose shadows could potentially enter the camera view underneath the ground are still being rendered.

Another possible solution would be to limit the range at which shadows are generated for each object. Many of these objects are very low and always on the ground, so I know there is no chance that their shadows would be more than 1-2 meters away from them. But I couldn't find a way to define such a value so that unity can use this for culling.

Any other ideas on how to overcome this issue?

Note: The entire scene is procedurally generated so I can't use static occlusion culling, except for the ground itself.

1

There are 1 answers

0
Dor Ben Dor On

Maybe info on the culling process will help you understand what you need to do:

  1. When an object leaves the frustum Unity culls it Immediately the remaining tris that still exist belong to the shadows.
  2. When an object leaves the frustum it still casts shadows. Internally, Unity turns the object Cast Shadows mode to "Shadows Only". This means the object itself is culled but not the shadows.
  3. Shadows are not culled instantaneously when out of the frustum, they use a combination of the camera's Field of View, Far Clipping Plane and the directional light quaternion to determine when to cull them
  4. Huge objects with no tessellation mess up the occlusion as well
  5. This is all Editor Wise, builds will often exhibit completely different behavior.

In turn, reducing Shadow Cascades, Shadow Distance, less angled directional light, camera perspective, and far clip plane will all help the culling process and \ or reduce tris count from shadows.

Occlusion Culling is a valid solution by the way, its just not that easy to use if not familiar with the system.