Jump to content
  • Advertisement
Sign in to follow this  
efoun

OpenGL Depth bound test

This topic is 3936 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!