How to check the visibility of a box


I’m new on 3D graphics, so I’m yet understanding all that stuff.

As far as I learned, I prefer octrees (for an easy view frustum culling). I feel comfortable with that structure (BSP is a bit confusing for me).

Now I’m thinking on how to minimize overdraws, so I was thinking this way:

1 Check what octrees comes inside frustum.
2 Push those boxes onto a stack sorted by distance.
3 Start drawing from front to back. I’d start with the box where the camera lies.
4 Pop the nearest box from the stack.
Before drawing polys from a box, check his visibility(not draw it). If the box is not visible at all(i.e. completely occluded), I don’t draw the polys inside it.
5 Remove that box from the stack.
6 Check if the entire screen is drawn. If yes, we stop the render.
7 Goto 4.

This way, I supposely don’t need PVS (render stops when all the scene is draw).

My questions are:
+It’s possible to do that?
+That strategy will be fast enough?
-It’s better a PVS?
+Is there any OpenGL method to do points 4 & 6 ?
Coding point 4 maybe can take much CPU time. Point 6 is not critical.

Thanks in advance.

yes you are right - points 4 & 6 could be very difficult…

6 is easier because you can just count “new” pixels drawn to the screen buffer (assuming whole screen has to be filled and there’s no mistake) - anyway i don’t find it a good approach

and point 4 is possible using ray tracing along edges of already drawn boxes and BSP or your octree but it’s not easy and you could end up in 0(n*n) or even more complex algorithm…

>+Is there any OpenGL method to do points 4 & 6 ?
don’t think of OpenGL like of magic box being able to do everything - then it wouldn’t be as good as it is

try to get familiar with PVS, portals, sectors etc, which is used by all professional games where speed is very important


I found on Delphi3D a demo with something like I thought.
It’s with the GL_HP_occlusion_test. But it’s only for NVidia cards

If anyone have used that, it improves the rendering speed? How much?