2 minute read

I was looking into simple frustum culling algorithms that I could apply to some software I am making. I found the Radar frustum culler to be a quick to implement culling that should work “OK” for most cases. Its a CPU-based culling method, and implemented in C#.

Quick Visualization of the Approach
2D Simplified Visualization of Frustum Culling, red spheres are not in the camera frustum and can be excluded from further calculations

In this post I describe the method, and share the final code. The code is ported from Lighthouse3D at http://www.lighthouse3d.com/tutorials/view-frustum-culling/radar-approach-testing-points/. I really suggest you check out the original series.

A radar frustum culler uses spherical bounding boxes, so it can be a quick pre-pass for deeper checking. But the main idea of the method is:

  1. Setup Initial Camera Parameters
  2. Each Frame
    1. Update the camera position and orientation (assuming the camera has not changed)
    2. Check every part in the scene for intersection with the frustum

Below you can see the C# code for the implementation.

The script should be self-explanatory, it has some helper methods for both spheres and coordinates. Its very quick, and can be frequently used to avoid batches drawn to the GPU this frame.

The end

Using a simple approach like this may give some extra performance at very little cost. Most game frameworks already implement this automatically, so please profile before actually implementing this. For my little example this helped, but leaving culling to the framework may often be more beneficial. Profile!

That’s it for this time!

// Nils Henrik

Tags:

Categories:

Updated: