4
\$\begingroup\$

So I am a little bit confused, and hopefully not too far off, about when frustum culling actually occurs. Let's suppose that I already have my objects in camera space, and then I have applied the perspective matrix onto it which puts everything into a cube AKA the canonical volume. From there, do I immediately do the "culling" and then simply drop the "z" axis of each point to draw it on 2D image plane? How exactly do I do the culling in the canonical cube volume?

\$\endgroup\$
  • \$\begingroup\$ Frustum culling happens on the CPU, you first cull your objects with your view frustum and you then draw those objects. I use an octree and cull tree nodes with the frustum and then any object that passes the test I send that off to the GPU \$\endgroup\$ – Justin William Stanley Bryant Mar 15 '17 at 8:00
2
\$\begingroup\$

Frustum culling happens whenever you (or the higher-level graphics engine you're using) implement it.

The idea behind culling is to completely exclude objects from being processed when they will be completely outside the view frustum. As such, the earlier in the rendering process you can discard objects the better. If you wait to cull an object until you've already transformed it through the geometry stages (the vertex shader), you're only really saving the raster costs that the built-in clipping functionality would save you anyway.

Given a combined view-projection matrix, you can extract the equations of the clip planes from it. The extract planes will be in world space. That means you can test your game objects against them before submitting them be rendered at all; all you need to know is where the object is in the world and how big it is in the world, which is information generally readily available to you.

So in short, you should implement frustum culling before you even think about drawing an object.

Often you will want to do frustum culling in conjunction with a broader-phase spatial partitioning system in order to reduce the number of checks. Grids, quadtrees or octrees, as mentioned in the comments, are typical candidates.

(Note of course that if there is any logic associated with an object, such as ticking forward its animation pose, you will still want to do that even if the object is just outside the view and you don't end up actually drawing it.)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.