Search code examples
3dfrustumculling

Frustum culling when Bounding Box is really big


see

When bounding box's all 8 vertex is out side the frustum, it won't be rendered. But if sth happened like shown above. That object should be in the display list. Any idea?


Solution

  • Because you are calculating the intersection as if the box is bunch of points, instead of a bunch of lines. This is how I do it in pseudo-code:

    inter = Inside
    for ( plane : frustum ) {
        verts[2] = findOpposingPointsMostPerpendicularToPlane( box, plane )
        near = plane.signedDistance( verts[0] ) > 0.0
        far = plane.signedDistance( verts[1] ) > 0.0
    
        if ( !near && !far )
            inter = Outside
            break
        else ( near ^ far )
            inter = Intersecting
    }
    

    If your box is an AABB, you create a static array of vertex indices for findOpposingPointsMostPerpendicularToPlane() and then map to them using the sign of the plane normal components.