PDA

View Full Version : Depth Bounds Test ?¿?



speed
04-03-2007, 08:40 AM
How works depth bounds test?

I am trying to use this option, but I can't do an example to understand the behaviour.

This is my code



glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, 0, height, -1.0,0.0001);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glClearColor(0, 0, 0, 0);
glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);


glEnable(GL_DEPTH_BOUNDS_TEST_EXT);
glDepthBoundsEXT(0.0,0.5);


glPointSize(128);

// red
glBegin(GL_POINTS);
glColor4f(1.0,0.0,0.0,0.5);
glVertex3f(128, 128, 0.9);
glEnd();

// blue
glBegin(GL_POINTS);
glColor4f(0.0,0.0,1.0,0.5);
glVertex3f(135, 135, 0.0);
glEnd();I don't understand exactly which z-coords use to compare with zmin and zmax of Depth Bounds.

In this example, I expect to obtain a blue point only in the screen, because the red one is rejected because its z-coord(0.9) is outside the range [0..0.5] of the bound test. But I see a black screen... :eek:

Someone knows what I do wrong? Is there any example of depth_bound_test_ext?¿

PD: I am using a NVIDIA and the driver 97.55

Eric Lengyel
04-03-2007, 09:09 PM
The depth bounds test compares the z value that's already in the z buffer to the min and max depth bounds, not the z coordinate of the fragment being rendered. You see nothing because the z buffer is filled with 1.0, which is outside the depth bounds [0.0, 0.5] that you're using.

speed
04-04-2007, 01:51 AM
Thanks!

I didn't understand this test. Is it applied as an early z-test? before the fragment computation?

Where I can found the whole pipeline of opengl with all this tests? (better if is the real implemented by nvidia)

speed
04-04-2007, 06:37 AM
I am trying to use it, but I can't do it.

The new example is this:



glClearColor(0, 0, 0, 0);
glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glPointSize(128);

glDisable(GL_DEPTH_BOUNDS_TEST_EXT);

glBegin(GL_POINTS);
glColor3f(0.0,1.0,0.0);
glVertex3f(256,256,0);
glEnd();

glEnable(GL_DEPTH_BOUNDS_TEST_EXT);
glDepthBoundsEXT(0.0,0.5);

glBegin(GL_POINTS);
glColor3f(1.0,0.0,0.0);
glVertex3f(240,240,0);
glEnd();
I clean the depth buffer with value 1.0. Then I draw a red point with z-value on 0. Then, if I activate depth_bounds_test with the range [0..0.5] and I render a green point that intersects with the previous one, the only pixels that will be green are those that have the z-value of the red point?
My result is only a red point.

I expect that this test skips pixels that the current depth-buffer has a value outside the defined range.

Some one have an example that works?

Eric Lengyel
04-04-2007, 12:42 PM
Is the depth test enabled? If not, then you're not changing values in the depth buffer, so they're all still 1.0 when you draw the second point.

soso
04-07-2007, 07:49 AM
Did you reverse the order of the red and green in your explanation? Couple questions here. First, what is your zNear and zFar value? And what is your projection mode? Both of these two settings affect the depth value of the point with z coord of 0. So the depth range (0.0, 0.5) might not cover the depth value of the first point. Second, I assume you enabled the depth testing and set the depthFunc to GL_LESS. If that was the case, it is very possible that the second point failed to pass the z-test such that you can't it on the screen.

speed
04-17-2007, 07:25 AM
Thanks for all!

Now I understand how it works clearly.