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
8
votes
1 answer

OpenGL: Can I mask wholly transparent fragments from the depth-buffer?

Is there a way to tell OpenGL not to write the depth of wholly transparent fragments into the depth buffer? Just be be sure, the texture I want to render is never semi-transparent; its alpha values are only ever 1.0 or 0.0, and I use the GL_NEAREST…
Dolda2000
  • 25,216
  • 4
  • 51
  • 92
8
votes
3 answers

Logarithmic Depth Buffer OpenGL

I've managed to implement a logarithmic depth buffer in OpenGL, mainly courtesy of articles from Outerra (You can read them here, here, and here). However, I'm having some issues, and I'm not sure if these issues are inherent to using a logarithmic…
Haydn V. Harach
  • 1,265
  • 1
  • 18
  • 36
8
votes
1 answer

Access depth-stencil texture in a shader program

It seems to be difficult to find information about how to access depth and stencil buffers in shaders of successive render passes. In a first render pass, I do not only render color and depth information but also make use of stencil operations to…
leemes
  • 44,967
  • 21
  • 135
  • 183
7
votes
2 answers

Why is GL_LEQUAL recommended for the GL depth function (and why doesn't it work for me)?

On the GL wiki they recommend using GL_LEQUAL for the depth function. Also, the depth function defaults to GL_LESS. When I use either of these functions, I get strange results. In this picture the red square should be in front of the blue one (both…
user1175938
  • 285
  • 1
  • 3
  • 6
7
votes
1 answer

Linearize depth

In OpenGL you can linearize a depth value like so: float linearize_depth(float d,float zNear,float zFar) { float z_n = 2.0 * d - 1.0; return 2.0 * zNear * zFar / (zFar + zNear - z_n * (zFar - zNear)); } (Source:…
l1994743
  • 73
  • 1
  • 3
7
votes
4 answers

OpenGL es 2.0 Read depth buffer

As far as i know, we can't read the Z(depth) value in OpenGL ES 2.0. So I am wondering how we can get the 3D world coordinates from a point on the 2D screen? Actually I have some random thoughts might work. Since we can read the RGBA value by using…
Brian
  • 735
  • 1
  • 8
  • 14
6
votes
1 answer

Android OpenGL 3D picking

I'm on Android OpenGL-ES 2.0 and after all the limitations that come with it, I can't figure out how to take 2D screen touches to the 3D points I have. I can't get the right results. I'm trying to implement shooting a ray into the point cloud, which…
RedLeader
  • 657
  • 1
  • 15
  • 28
6
votes
1 answer

Blank depth buffer from ARSCNView in DRAW_QUAD pass of SCNTechnique

I'm trying to do depth-testing in a post-processing step of an AR SceneKit demo. I would need the depth map of the rendere ARSCNView for that. It seems impossible to get it using an SCNTechnique. I keep getting blank (full of 1.0-s) depth buffers…
6
votes
3 answers

glDepthMask(GL_FALSE) trashes the frame buffer on some GPUs

I sometimes disable depth buffer writing via glDepthMask(GL_FALSE) during the rendering of a frame. That works perfectly fine on some GPUs (like the Motorola Droid's PowerVR), but on the HTC EVO with the Adreno GPU for example, I end up with the…
EboMike
  • 76,846
  • 14
  • 164
  • 167
6
votes
1 answer

Writing texture data onto depth buffer

I'm trying to implement the technique described at : Compositing Images with Depth. The idea is to use an existing texture (loaded from an image) as a depth mask, to basically fake 3D. The problem I face is that glDrawPixels is not available in…
sharvey
  • 7,635
  • 7
  • 48
  • 66
6
votes
1 answer

Depth offset in OpenGL

What would be the best way of offsetting depth in OpenGL? I currently have index vertex attribute per polygon which I am passing to the Vertex Shader in OpenGL. My goal is to offset the polygons in depth where the highest index would be always…
sabotage3d
  • 435
  • 1
  • 6
  • 15
6
votes
1 answer

Compute 3D point from mouse-position and depth-map

I need to compute 3D coordinates from a screen-space position using a rendered depth-map. Unfortunately, using the regular raytracing is not an option for me because I am dealing with a single geometry containing something on the order of 5M…
Martin Schuhfuß
  • 6,814
  • 1
  • 36
  • 44
6
votes
1 answer

How does WebGL set values in the depth buffer?

In OpenGL, depth buffer values are calculated based on the near and far clipping planes of the scene. (Reference: Getting the true z value from the depth buffer) How does this work in WebGL? My understanding is that WebGL is unaware of my scene's…
rjkaplan
  • 3,138
  • 5
  • 27
  • 33
6
votes
2 answers

Webgl: alternative to writing to gl_FragDepth

In WebGL, is it possible to write to the fragment's depth value or control the fragment's depth value in some other way? As far as I could find, gl_FragDepth is not present in webgl 1.x, but I am wondering if there is any other way (extensions,…
andre
  • 349
  • 2
  • 13
6
votes
1 answer

Why do I need depthBuffer to use RenderTexture?

I think that I don't quite get the Unity rendering engine. I use RenderTexture to generate the screenshot (I need to manage it later on): screenshotRenderTexture = new RenderTexture(screenshot.width, screenshot.height, depthBufferBits,…
Max Yankov
  • 12,551
  • 12
  • 67
  • 135
1
2
3
30 31