a technique used in 3D graphics to ensure that only the objects closest to the viewer are drawn in a scene.
Questions tagged [depth-testing]
121 questions
4
votes
1 answer
OpenGL optimizing skybox rendering
I'm learning how to draw skybox using cubemaps from the following resource.
I've got to the part where he talks about how we can optimize the rendering of the skybox. I get that instead of rendering the skybox first, which will result in…

Jorayen
- 1,737
- 2
- 21
- 52
4
votes
1 answer
How do I bring a polygon to the foreground in OpenGL?
The code below creates 2 square polygons, red and green.
I'm trying to place a red square on top of the green, but I can't.
The depth buffer is declared, cleaned when necessary, an orthogonal system is configured correctly.
If I specify a value…

German
- 321
- 1
- 7
4
votes
2 answers
How to use Depth Testing with CAMetalLayer using Metal and Swift?
Recently I decided to learn how to use the Metal framework with Swift. I read some turorials, watched videos, did a few things and finally I got to part where I have to use Depth Testing to make things look good.
I haven't done such low level…

Ivan Todorov
- 41
- 3
4
votes
2 answers
OpenGL: Radeon driver seems to mess with depth testing
I'm having a really weird issue with depth testing here.
I'm rendering a simple mesh in an OpenGL 3.3 core profile context on Windows, with depth testing enabled and glDepthFunc set to GL_LESS. On my machine (a laptop with a nVidia Geforce GTX…

JWki
- 61
- 6
4
votes
2 answers
What are good reasons to enable 2D projection with cocos2d-iphone?
In cocos2d-iphone the default projection type is "3D" projection. But you can also set the projection to "2D" like so:
[[CCDirector sharedDirector] setProjection:CCDirectorProjection2D];
Behind the scenes the 3D projection uses perspective…

CodeSmile
- 64,284
- 20
- 132
- 217
3
votes
2 answers
2D LWJGL with OpenGL - Enabling depth testing for layering 2D textures?
What would I need to add to my OpenGL init method to enable depth testing, and how would I actually use it for texture layering?
I would have to extend the last parameter of glOrtho to something more extreme than -1, and of course glEnable depth…

GlassZee
- 1,117
- 2
- 11
- 22
3
votes
2 answers
OpenGL Depth Testing in Qt not working
I set the format with:
QGLFormat format = QGLFormat(QGL::DoubleBuffer | QGL::DepthBuffer);
setFormat(format);
in the constructor.
Then in initializeGL I set depthTesting on.
void VoxelEditor::initializeGL()
{
glClearDepth(2000.0); …

RobotRock
- 4,211
- 6
- 46
- 86
3
votes
1 answer
Depth testing in GLKit
I'm new to OpenGL/GLKit and having trouble with depth testing. The picture below shows a post with five beams intersecting it. They all meet in the middle (inside the post) but as you can see the parts of the beams that are meant to be obscured are…

Craig
- 8,093
- 8
- 42
- 74
3
votes
1 answer
In OpenGL, is it possible to draw the edges of the unoccluded triangles only?
I have a mesh to render with OpenGL. What I want is to render its edges, but only the ones of the un-occluded faces. However, I realize that this is not possible with only:
glEnable(GL_DEPTH_TEST); // Enable depth test
glDepthFunc(GL_LEQUAL); …

ihdv
- 1,927
- 2
- 13
- 29
3
votes
2 answers
glReadPixels() how to get actual depth instead of normalized values?
I'm using pyopengl to get a depth map.
I am able to get a normalized depth map using glReadPixels(). How can I revert the normalized values to the actual depth in world coordinates?
I've tried playing with glDepthRange(), but it always performs some…

strangelyput
- 33
- 3
3
votes
3 answers
Merging two separate framebuffers onto default framebuffer after depth testing
I have two framebuffers that I am rendering two different objects to. When I use the default framebuffer, I have both the objects rendering on the same one.
I want this behaviour to work when using multiple framebuffers! How do I merge two…

Rathnavel
- 85
- 1
- 15
3
votes
0 answers
Metal API: Improving depth buffer precision
What options does the Metal API offer for increasing the precision of the depth buffer, particularly for objects that are farther away?
I've found that even with the nearZ value set uncomfortably far from the camera and the farZ value set…

llama591
- 453
- 5
- 15
3
votes
1 answer
GL_DEPTH_TEST does not work in OpenGL 3.3
I am writing a simple rendering program using OpenGL 3.3.
I have following lines in my code (which should enable depth test and culling):
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
ExitOnGLError("ERROR: Could not set OpenGL depth testing…

Aleksei Petrenko
- 6,698
- 10
- 53
- 87
3
votes
1 answer
Drawing over terrain with depth test?
i'm trying to render geometrical shapes over uneven terrain (loaded from heightmap / shapes geometry is also generated based on averaged heights across the heightmap however they do not fit it exactly). I have the following problem - somethimes the…

Pawel Klapuch
- 380
- 4
- 15
2
votes
1 answer
Fragment discard and early fragment tests in practice
I understand that hardware can run early fragment tests (https://www.khronos.org/opengl/wiki/Early_Fragment_Test)
In particular for depth test, this means that the depth buffer can be updated already during the interpolation of vertex-shader outputs…

matthias_buehlmann
- 4,641
- 6
- 34
- 76