Monday, May 30, 2016

Define: Depth Buffer .. z- buffer

Depth-buffer

The depth-buffer is a buffer, a kind of logical buffer of Framebuffer. The depth-buffer is a buffer, just like the COLOR-BUFFER (that stores all the fragment-colors: the visual output), stores information per fragment and (usually) has the same width and height as the COLOR-BUFFER. The Depth-Buffer is automatically created by the windowing system and stores its depth values as 16,24 or 32 bit floats. In most systems you'll see a depth buffer with a precision of 24-bits-floats...When the depth-testing is enabled OpenGL tests the depth value of a fragment against the content of the depth buffer. 
OpenGL performs a depth test.If this test passes, the depth buffer is updated with the new depth valueIf the depth test fails, the fragment is discarded.
Depth testing is done in screen space after the fragment shader has run (and after stencil testing has run which we'll discuss in the next tutorial). 
The screen space coordinates relate directly to the viewport defined by OpenGL's glViewport function and can be accessed via GLSL's built-in gl_FragCoord variable in the fragment shader.  
The x and y components of gl_FragCoord represent the fragment's screen-space coordinates (with (0,0) being the bottom-left corner).  
The gl_FragCoord also contains a z-component which contains the actual depth value of the fragment. This z-component, i.e. z value, is the value that is compared to the depth buffer's content.


[]
..................


No comments:

Post a Comment