Frustum culling not working?

While optimizing our city builder game with an isometric view I’ve noticed a lot of objects far outside of camera bounds are rendered. I’ve made an empty URP project and on a sample scene, I’ve put a cube with the camera looking straight at the cube. Even as the sample scene objects are far away, according to both editors and build profilers, they are still rendered.

Is there something I don’t understand when it comes to the Frustum culling? Is there some particular setup on the sample scene that prevents Frustum culling from working properly? Light or post-processes that spoils it? I must admit I’m completely baffled by this.

EDIT:
Tested on
Unity 2020.3.10
URP 10.5.0



Maybe it’s still rendering them into the shadow map and Unity’s shadow culling isn’t smart enough to cull shadow casters based on the camera frustum. Use RenderDoc to capture a frame and see exactly what Unity is doing

1 Like

Thank you for the reply. Under further investigation, this does look like a problem with shadows culling. I’ve found out that even with the simplest examples URP behaves very unexpectedly with culling objects with shadows. Objects are very often rendered even if the shadow has no chance to be ever seen by the camera.

There does not seem to be any reasonable solution for that. Our approach will be probably to switch receiveShadows & shadowCastingMode with OnBecameVisible and OnBecameInvisible. That could cause some minor artifacts and will be a pain to maintain, but look like will reduce the rendering time by a substantial amount.

1 Like

Yeah, it’s a problem from built-in that Unity never fixed in the SRP: the camera frustum is not considered for visibility culling when rendering the shadow map.

Even something as simple as calculating the shadow-space bounding box of the camera frustum and culling objects outside of it could potentially skip 50% of objects in a scene made of evenly distributed small objects.

To make matters worse, culling is one of the parts of the SRP which is done by Unity in C++ and cannot be modified or customized since it’s not part of the package. So the only alternative is to toggle renderers/shadow casting on/off via scripting.

3 Likes