zbuffer notice....

Hi,

(I have a celeron 416/geForce II MX 32, test resolution 800x600x32)

I’m on OpenGL learning curve and lately i’ve found that drawing 480 gouraud cubes at THE SAME place actually kills the frame rate : 3/4/5 FPS.
Drawing those same cubes at DIFFERENT places is, on another side, safe for the frame rate : 75 FPS.

Tell me if i’m wrong : what kills the frame rate is, in this case, zbuffer test. If the camera is close to the 480 cubes at the same place then there may be chance that there will be nearly 800x600x480 zbuffer tests for ONE display !!

Am i clear ??

Trust me, but I think the zbuffer test is made for each fragment anyway. This sounds very strange to me.

Oh, did you mean with at different places that they were still all visible? Which percentage of screen is drawn in either case?

I am trying to optimize the drawing of my scene and I’ve run into the same problem.

If I draw the same cube 100 times onto itself my fps is very low. If I draw it 100 times at different locations the fps is much higher.

Well the fact was that, obviously, if you fill nearly all the screen something like 480 times the screen in ONE frame you could have A LOT OF zbuffer tests that would actually kill your framerate…

This may seem obvious for many coders, but it takes me 2 day of coding to understand this simple law

I don’t think that explains the drop in fps, though. The depth test is performed in any event, whether there’s an object rendered at a specific location or not.

In fact, if you draw the same object over itself 400 times OpenGL performs 1 test for the incoming object, not 400. There really should be no difference if the objects are in the same place or scattered around the scene.

I’ve run a lot of tests and I found that most of the drop (in my case it is about 25%) is due to anti-aliasing when the objects are rendered at the same location.

try using an orthogonal projection matrix and then draw your cubes

maybe also try disabeling the Depth Test and note what the diff is (of course it will be faster but by how much?)

U’r 100 cubes are all the same color ??

If yes, try to put different colors to different cubes and let see if it switches from a color to another one. I don’t know why u draw hundred times the same cube at the same place but you shouldn’t… Maybe the depth buffer test look with an offset wich pixel is in front of wich another one (so if they are at the same Z, it must be difficult)

Was it clear (i’m not sure)

ooops i forgot to mention something, what function do you use as a depth func ??
If it’s GL_LESS, try GL_LEQUAL…