[solved]Depth Buffer configuration

Hello all.

I’m now implementing Depth peeling algorithm.

So i check my depth buffer. and i observed a strange comportement.

i try to draw (deferred) this :

     glBegin(GL_QUADS);
glPushMatrix();

            colorConvert(1001);
glVertex3f(-10, 0, -2 );
glVertex3f( 10,0, -2);
glVertex3f( 10,-10,-2); 
glVertex3f( -10,-10,-2); 

glPopMatrix();*/
glPushMatrix();

            colorConvert(1002);
glVertex3f(-15, 1, -3 );
glVertex3f( 15,1, -3);
glVertex3f( 15,-15,-3); 
glVertex3f( -15,-15,-3); 

glPopMatrix();
glEnd();

with this openGL configuration


glEnable(GL_DEPTH_TEST);
	glClearColor(255,255,255,255);

	// S e t t h e p r o j e c t i o n t r a n s f o r m
	glMatrixMode (GL_PROJECTION ) ;
	glLoadIdentity ( ) ;
	gluPerspective( 45, 100/100,1,100 ); 


	// S e t t h e camera o r i e n t a t i o n :
	glMatrixMode (GL_MODELVIEW) ;
	glLoadIdentity();	
	gluLookAt(0,0,5,0,0,4,0,1,0);

and i obtain this results ( only the important part)


row =0 :column =0 :0.865801
row =0 :column =1 :0.865801
...
row =49 :column =98 :0.865801
row =49 :column =99 :0.865801
row =50 :column =0 :0.882877
row =50 :column =1 :0.882877
...
row =50 :column =98 :0.882877
row =50 :column =99 :0.882877
row =51 :column =0 :0.882943
row =51 :column =1 :0.882943
...
row =51 :column =98 :0.882943
row =51 :column =99 :0.882943
row =52 :column =0 :0.883009
row =52 :column =1 :0.883009
...
row =52 :column =98 :0.883009
row =52 :column =99 :0.883009
row =53 :column =0 :0.883075
row =53 :column =1 :0.883075
...
row =53 :column =98 :0.883075
row =53 :column =99 :0.883075
row =54 :column =0 :0.883141
row =54 :column =1 :0.883141
...
row =54 :column =98 :0.883141
row =54 :column =99 :0.883141
row =55 :column =0 :0.883207
row =55 :column =1 :0.883207
...
row =55 :column =98 :0.883207
row =55 :column =99 :0.883207
row =56 :column =0 :0.883272
row =56 :column =1 :0.883272
...
row =56 :column =98 :0.883272
row =56 :column =99 :0.883272
row =57 :column =0 :0.883338
row =57 :column =1 :0.883338
...
row =57 :column =98 :0.883338
row =57 :column =99 :0.883338
row =58 :column =0 :0.883404
row =58 :column =1 :0.883404
...
row =58 :column =98 :0.883404
row =58 :column =99 :0.883404
row =59 :column =0 :0.883470
row =59 :column =1 :0.883470
...
row =59 :column =98 :0.883470
row =59 :column =99 :0.883470
row =60 :column =0 :0.883536
row =60 :column =1 :0.883536
...
row =60 :column =98 :0.883536
row =60 :column =99 :0.883536
row =61 :column =0 :0.883602
row =61 :column =1 :0.883602
...
row =61 :column =98 :0.883602
row =61 :column =99 :0.883602
row =62 :column =0 :0.883668
row =62 :column =1 :0.883668
...
row =62 :column =98 :0.883668
row =62 :column =99 :0.883668
row =63 :column =0 :0.883734
row =63 :column =1 :0.883734
...
row =63 :column =98 :0.883734
row =63 :column =99 :0.883734
row =64 :column =0 :0.883800
row =64 :column =1 :0.883800
...
row =64 :column =98 :0.883800
row =64 :column =99 :0.883800
row =65 :column =0 :1.000000
row =65 :column =1 :1.000000
...
row =99 :column =98 :1.000000
row =99 :column =99 :1.000000

As you can see there is a “first” part from row 0 to 49 where the depth correspond to the first quads (index 1001).

after that there is as increasing part from row 50 to row 65. this correspond to the 2nd quads.
After a first drop of 0,017076.
Each row the depth increase of 0,000066.

so i guess there is a linear depth “blur” or something like that.

I try to find out how to fix that but i cannot find it on internet.

To check my conjecture i’ve tried with only one quads ( the second index 1002) and i obtain the following results :


row =0 :column =0 :0.883838
row =0 :column =1 :0.883838
...
row =64 :column =98 :0.883838
row =64 :column =99 :0.883838
row =65 :column =0 :1.000000
row =65 :column =1 :1.000000
...
row =99 :column =98 :1.000000
row =99 :column =99 :1.000000

so i can conclude my conjecture is good.

so my question is : how to configure the depth buffer not to averaging the value.

thx.

What’s odd is OpenGL does not have a “depth blend/blur” function. Are you sure you’re not doing a blur on this buffer yourself?

Do you have multisampling enabled? If so, disable it (i.e. do not allocate a multisample render target and do not enable GL_MULTISAMPLE). Remote possibility that this might be related.

Also, make sure you have:

glDepthFunc( GL_LESS )
glDepthRange( 0, 1 )
glEnable( GL_DEPTH_TEST )
glClear( GL_DEPTH_BUFFER_BIT )

enabled before you draw anything. And just for good measure:

glDisable( GL_ALPHA_TEST )
glDisable( GL_BLEND )

I tried to produce your Z buffer numbers but didn’t, so I would guess your DepthRange wasn’t set to the defaults.

I’m not using any multisampling anywhere.

I’ve added what you purpose but not any effects on numbers.

so here is my complete code if you want to try it.

edit : I’ve found why it’s not working.
Only because before calling glbegin(GL_QUADS) , i forget an old glbegin(GL_TRIANGLES)

thx for helping :smiley: