Questions tagged [depth-buffer]

Depth buffering(Z-buffering), is the management of image depth coordinates in three-dimensional (3-D) graphics.

In computer graphics, z-buffering, also known as depth buffering, is the management of image depth coordinates in three-dimensional (3-D) graphics, usually done in hardware, sometimes in software. It is one solution to the visibility problem, which is the problem of deciding which elements of a rendered scene are visible, and which are hidden. The painter's algorithm is another common solution which, though less efficient, can also handle non-opaque scene elements.

Resources

454 questions
17
votes
1 answer

Why do we have to clear depth buffer in OpenGL during rendering?

I was trying to run an OpenGL code, it didn't have GL_DEPTH_BUFFER_BIT cleared in glClear(), because of which I couldn't render my scene. I added this bit, and the scene was rendered. Why is it necessary to use this clear bit? I may know the reason…
2am
  • 699
  • 1
  • 7
  • 25
15
votes
2 answers

Android OpenGL ES Framebuffer objects - rendering depth-buffer to texture

I am using an Android device running Froyo supporting OpenGL ES 1.1 and OpenGL ES 2.0 I want to render the depth buffer to a texture. Having seen a number of examples for OpenGL, OpenGL ES on other platforms (including iPhone) I have tried a number…
Graham
  • 321
  • 1
  • 2
  • 7
14
votes
4 answers

How to render depth linearly in modern OpenGL with gl_FragCoord.z in fragment shader?

I read lots of information about getting depth with fragment shader. such as http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=234519 but I still don't know whether or not the gl_FragCoord.z is linear. GLSL specification…
tomriddle_1234
  • 3,145
  • 6
  • 41
  • 71
13
votes
3 answers

OpenGL, how to use depthbuffer from framebuffer as usual depth buffer

I have frame buffer, with depth component and 4 color attachments with 4 textures I draw some stuff into it and unbind the buffer after, using 4 textures for fragment shader (deferred lighting). Later i want to draw some more stuff on the screen,…
ShPavel
  • 962
  • 1
  • 10
  • 17
13
votes
1 answer

Meaning and usage of the factor parameter in glPolygonOffset

I am having difficulty understanding the meaning of the first parameter in glPolygonOffset function. void glPolygonOffset(GLfloat factor, GLfloat units); The official documentation says that factor Specifies a scale factor that is used to create…
Armen Tsirunyan
  • 130,161
  • 59
  • 324
  • 434
12
votes
2 answers

OpenGL ES2 Alpha test problems

I am rendering in 3D multiple objects with textures that have alpha. All the textures load fine but when I try to render them in front of each other I get the following: Left is what I have. Right is what it should be. The grid is just to help…
sgtHale
  • 1,507
  • 1
  • 16
  • 28
11
votes
2 answers

Depth of Field: combining a point shader with a blur shader (Processing 3)

I would like to display thousands of points on a 3D canvas (in Processing) with a Depth of Field effect. More specifically, I would like to use a z-buffer (depth buffering) to adjust the level of blur of a point based on its distance from the…
solub
  • 1,291
  • 17
  • 40
11
votes
2 answers

Direct2D Depth Buffer

I need to draw a list of shapes and I am using Direct2D. I get the list of shapes from a file. The list is sorted and the order of the elements inside the file represents the order these shapes will be drawn. So, if for example the file specifies…
Nick
  • 10,309
  • 21
  • 97
  • 201
10
votes
4 answers

How to correctly render coincident polygons in OpenGL (ES)

I understand that by setting the depth function in OpenGL ES one can control how overlapping geometries are rendered in a 3D scene. I use gl.depthFunc(gl.LEQUAL) (webgl) in my code. However when two sets of polygons are coincident and are of…
Jayesh
  • 51,787
  • 22
  • 76
  • 99
10
votes
1 answer

How to use depth testing when rendering to an offscreen buffer then onto texture

I'm rendering my scene to a texture. This works fine except that depth testing does not work. How do I enable depth testing if rendering to an offscreen texture? I'm using the FrameBuffer class…
user491880
  • 4,709
  • 4
  • 28
  • 49
10
votes
1 answer

World-space position from logarithmic depth buffer

After changing my current deferred renderer to use a logarithmic depth buffer I can not work out, for the life of me, how to reconstruct world-space depth from the depth buffer values. When I had the OpenGL default z/w depth written I could easily…
RamblingMad
  • 5,332
  • 2
  • 24
  • 48
9
votes
5 answers

How can I read the depth buffer in WebGL?

Using the WebGL API, how can I get a value from the depth buffer, or in any other way determine 3D coordinates from screen coordinates (i.e. to find a location clicked on), other than by performing my own raycasting?
Kevin Reid
  • 37,492
  • 13
  • 80
  • 108
9
votes
3 answers

How do I Z-sort triangles for a 3D engine?

I'm building a small 3D engine for a game I'm working on. I've got my basics sorted: textured triangles with backface culling. However depth sorting is proving to be a difficult problem. I'm calculating the face Z by averaging out the 3 points that…
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
9
votes
1 answer

Early Z-test / depth-test in DirectX 11

As a DirectX noob i'm trying to wrap my head around depth buffers and specifically how pixel shaders are called for obscured pixels. From what i understand, the rasterizer calls the pixel shader for each pixel that is covering the primitive beeing…
aL3891
  • 6,205
  • 3
  • 33
  • 37
8
votes
2 answers

Can't get depth testing to work in OpenGL

I use SFML to create the window. In this screenshot the cube should be behind the pyramid but it just doesn't work. Here is the minimal code I used: #include #include #include #include…
RadicalRaid
  • 996
  • 9
  • 17
1
2 3
30 31