Depth bound test

Started by
1 comment, last by HellRaiZer 16 years, 7 months ago
I would like to ask how use opengl extension GL_DEPTH_BOUNDS_TEST_EXT. I read documentation about this extension and a I try this:

glDepthBoundsEXT(0.3, 0.7);
glEnable(GL.GL_DEPTH_BOUNDS_TEST_EXT);
		
glBegin(GL.GL_QUADS);
	glColor4f(0.0f, 1.0f, 0.0f, 0.4f); 
	glVertex3f( -1.0f, -1.0f, -1.0f);
	glVertex3f(  1.0f, -1.0f, -1.0f);
	glVertex3f(  1.0f,  1.0f, -100.0f);
	glVertex3f( -1.0f,  1.0f, -100.0f);
glEnd();

with projection matrix:

gluPerspective(45.0f, h, 1.0, 100.0);

where h = widht/height. If I don´t used this extension, it render this: If I used extension, it render this: but I expect something like this: (I think that the extension cuts 2 part of polygon, first one is front of the polygon part with depth smaller then 0.3 and second one is back of polygon with depth bigger then 0.7) that is why I ask whether I used this extension correctly or this extension has other correct usage.
Advertisement
that looks about right
depth values in ogl are non linear

try (check the correct syntax)
cout << glReadPixels( cursor_x, cursory, GL_DEPTHCOMPONENT ) << endl;

move the cursor around u will find most values are close to 1.0

GL_EXT_depth_bounds_test works with the depth values already stored in the framebuffer, and *not* the incoming fragment's depth.

Check the specs for more details. They describe its use for attenuated light sources in the z-direction.

Generally this extension can be used as a computational mask. In a depth pre-pass you create a depth buffer in such a way, where values in the range you specify are valid and values outside of it are invalid. In the following passes you can use this test (enable it and set the range) in order to update the framebuffer only where the depth value is in the specified range.

HellRaiZer
HellRaiZer

This topic is closed to new replies.

Advertisement