PDA

View Full Version : minkowski sum frustum cull

ugluk
08-11-2010, 02:27 PM
I've been experimenting with an extremely simple frustum cull algorithm I've developed. The frustum is approximated as a Minkowski sum of the center line of the frustum and ever increasing spheres (since the frustum also expands), truncated by near and far planes. The intersection test between this frustum approximation and a sphere costs just 2 dot products:

returns true if sphere s intersects frustum approximation:

GLfloat frustum[6]; // L, R, B, T, N, F of the frustum
Sphere s; // a struct of center and radius
Vector <GLfloat, 3> view_origin; // origin of the viewing system
Vector <GLfloat, 3> frustum_d; // negated view_matrix's 3rd column
GLfloat frustum_r(std::sqrt(GetR(frustum) * GetR(frustum) + GetT(frustum) * GetT(frustum)) / GetN(frustum));

GLfloat da(dot(sphere_center - view_origin, frustum_d));

if ((da + s.radius < 0) || (da - s.radius > GetF(frustum)))
{
return false;
}
else
{
Vector<GLfloat, 3> dc(s.center - view_origin - da * frustum_d);