Shadow caster frustum culling

In this article I will describe a simple approximate method how we can cull objects that are casting shadows.

Culling of objects that do not cast shadows is trivial. We just check if object AABB is inside or intersects camera frustum planes.

1. The problem

However, shadow casters have also their shadow volume, which goes outside the object AABB.

frustum_sceneCulling only against object AABB will lead into object shadow popping into view. To solve this problem, we need to merge object shadow into the object AABB.

frustum_2Calculating real shadow bounding volume is problematic and cannot be solved trivially, as shadow can be cast on different objects or terrain that is not simple plane, but has bumps, valleys etc. However, we can approximate the shadow bounding volume by using only light direction, object AABB and a ground collider.

2. Constructing light rays

At the first step, we will construct light rays. Their origins will be at the 4 top corners of the object AABB and direction will be the same as the sun light direction.


frustum_4After we have these 4 rays defined, we collide them with the terrain, or simply the bottom plane of the object AABB. After that we have 4 intersection points.

In this example, for simplicity, ground is defined as simple plane at the bottom of the object. However, we can improve the algorithm by Raycasting to the terrain collider.

3. Constructing combined bounding volume

Combined bounding volume is defined by merging object AABB and the 4 light ray intersection points.


frustum_5After combinedBounds are computed, we can frustum cull against these Bounds using:



This solution works only for single directional light. However, we can compute combined bounding volume for each shadow casting light on a single object, and then Encapsulate them all.