Sign in to follow this  
GloW_on_dub

OpenGL [solved]Depth Buffer Configuration

Recommended Posts

GloW_on_dub    102
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. [Edited by - GloW_on_dub on April 1, 2010 8:28:54 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • By markshaw001
      Hi i am new to this forum  i wanted to ask for help from all of you i want to generate real time terrain using a 32 bit heightmap i am good at c++ and have started learning Opengl as i am very interested in making landscapes in opengl i have looked around the internet for help about this topic but i am not getting the hang of the concepts and what they are doing can some here suggests me some good resources for making terrain engine please for example like tutorials,books etc so that i can understand the whole concept of terrain generation.
       
    • By KarimIO
      Hey guys. I'm trying to get my application to work on my Nvidia GTX 970 desktop. It currently works on my Intel HD 3000 laptop, but on the desktop, every bind textures specifically from framebuffers, I get half a second of lag. This is done 4 times as I have three RGBA textures and one depth 32F buffer. I tried to use debugging software for the first time - RenderDoc only shows SwapBuffers() and no OGL calls, while Nvidia Nsight crashes upon execution, so neither are helpful. Without binding it runs regularly. This does not happen with non-framebuffer binds.
      GLFramebuffer::GLFramebuffer(FramebufferCreateInfo createInfo) { glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); textures = new GLuint[createInfo.numColorTargets]; glGenTextures(createInfo.numColorTargets, textures); GLenum *DrawBuffers = new GLenum[createInfo.numColorTargets]; for (uint32_t i = 0; i < createInfo.numColorTargets; i++) { glBindTexture(GL_TEXTURE_2D, textures[i]); GLint internalFormat; GLenum format; TranslateFormats(createInfo.colorFormats[i], format, internalFormat); // returns GL_RGBA and GL_RGBA glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, createInfo.width, createInfo.height, 0, format, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); DrawBuffers[i] = GL_COLOR_ATTACHMENT0 + i; glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, textures[i], 0); } if (createInfo.depthFormat != FORMAT_DEPTH_NONE) { GLenum depthFormat; switch (createInfo.depthFormat) { case FORMAT_DEPTH_16: depthFormat = GL_DEPTH_COMPONENT16; break; case FORMAT_DEPTH_24: depthFormat = GL_DEPTH_COMPONENT24; break; case FORMAT_DEPTH_32: depthFormat = GL_DEPTH_COMPONENT32; break; case FORMAT_DEPTH_24_STENCIL_8: depthFormat = GL_DEPTH24_STENCIL8; break; case FORMAT_DEPTH_32_STENCIL_8: depthFormat = GL_DEPTH32F_STENCIL8; break; } glGenTextures(1, &depthrenderbuffer); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); glTexImage2D(GL_TEXTURE_2D, 0, depthFormat, createInfo.width, createInfo.height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthrenderbuffer, 0); } if (createInfo.numColorTargets > 0) glDrawBuffers(createInfo.numColorTargets, DrawBuffers); else glDrawBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) std::cout << "Framebuffer Incomplete\n"; glBindFramebuffer(GL_FRAMEBUFFER, 0); width = createInfo.width; height = createInfo.height; } // ... // FBO Creation FramebufferCreateInfo gbufferCI; gbufferCI.colorFormats = gbufferCFs.data(); gbufferCI.depthFormat = FORMAT_DEPTH_32; gbufferCI.numColorTargets = gbufferCFs.size(); gbufferCI.width = engine.settings.resolutionX; gbufferCI.height = engine.settings.resolutionY; gbufferCI.renderPass = nullptr; gbuffer = graphicsWrapper->CreateFramebuffer(gbufferCI); // Bind glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); // Draw here... // Bind to textures glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textures[0]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textures[1]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, textures[2]); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); Here is an extract of my code. I can't think of anything else to include. I've really been butting my head into a wall trying to think of a reason but I can think of none and all my research yields nothing. Thanks in advance!
    • By Adrianensis
      Hi everyone, I've shared my 2D Game Engine source code. It's the result of 4 years working on it (and I still continue improving features ) and I want to share with the community. You can see some videos on youtube and some demo gifs on my twitter account.
      This Engine has been developed as End-of-Degree Project and it is coded in Javascript, WebGL and GLSL. The engine is written from scratch.
      This is not a professional engine but it's for learning purposes, so anyone can review the code an learn basis about graphics, physics or game engine architecture. Source code on this GitHub repository.
      I'm available for a good conversation about Game Engine / Graphics Programming
    • By C0dR
      I would like to introduce the first version of my physically based camera rendering library, written in C++, called PhysiCam.
      Physicam is an open source OpenGL C++ library, which provides physically based camera rendering and parameters. It is based on OpenGL and designed to be used as either static library or dynamic library and can be integrated in existing applications.
       
      The following features are implemented:
      Physically based sensor and focal length calculation Autoexposure Manual exposure Lense distortion Bloom (influenced by ISO, Shutter Speed, Sensor type etc.) Bokeh (influenced by Aperture, Sensor type and focal length) Tonemapping  
      You can find the repository at https://github.com/0x2A/physicam
       
      I would be happy about feedback, suggestions or contributions.

    • By altay
      Hi folks,
      Imagine we have 8 different light sources in our scene and want dynamic shadow map for each of them. The question is how do we generate shadow maps? Do we render the scene for each to get the depth data? If so, how about performance? Do we deal with the performance issues just by applying general methods (e.g. frustum culling)?
      Thanks,
       
  • Popular Now