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?
Asked
Active
Viewed 2,534 times
2 Answers
3
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.

cmannett85
- 21,725
- 8
- 76
- 119
0
Compute the bounding sphere from your bbox and check the center distance from each one of the 6 frustum planes. If one of them is less than the sphere radius include your object in the display list.

abenci
- 8,422
- 19
- 69
- 134
-
Thanks, this is an easier solution ;) – sindney Feb 09 '12 at 09:02
-
1It will also give false positives. If a BB is skinny, the bounding sphere could have a volume hundreds of times the BB's. The BB is (in general) an approximation, now you are approximating an approximation... – cmannett85 Feb 09 '12 at 09:43
-
Yes, you're right, just realized the wrong result when calculating both bbox and bsphere for Plane Mesh. – sindney Feb 09 '12 at 10:06
-
If you are processing thousands of objects this is the best speed/accuracy compromise ... – abenci Feb 09 '12 at 21:32
-
@devdept So for the sake of little more than a couple of extra dot products, you are willing to potentially render many (potentially complex) objects off-screen? There is a reason why I have never seen this approach in a commerical rendering engine. – cmannett85 Feb 10 '12 at 11:25
-
As far as I can understand they are not a couple of extra dot products per object (on the 6 frustum planes). My experience says that an accurate IsInFrustum() evaluation generally slows down everything... – abenci Feb 10 '12 at 15:58