Depth buffer stores a depth (z-coordinate) of a rendered pixel of a 3D scene. Depth buffer is used in Z-buffering (management of image depth coordinates). Because of this depth buffer is often called Z-buffer.

learn more… | top users | synonyms

9
votes
2answers
5k views

How do I use depth testing and texture transparency together in my 2.5D world?

Note: I've already found an answer (which I will post after this question) - I was just wondering if I was doing it right, or if there is a better way. I'm making a "2.5D" isometric game using OpenGL ...
9
votes
1answer
164 views

What would be a good filter to create 'magnetic deformers' from a depth map?

In my project, I am creating a system for deforming a highly detailed mesh (clothing) so that it 'fits' a convex mesh. To do this I use depth maps of the item and the 'hull' to determine at what point ...
8
votes
4answers
2k views

Shadow Mapping and Transparent Quads

Shadow mapping uses the depth buffer to calculate where shadows should be drawn. My problem is that I'd like some semi transparent textured quads to cast shadows - for example billboarded trees. As ...
8
votes
1answer
890 views

Depth interpolation for z-buffer, with scanline

I have to write my own software 3d rasterizer, and so far I am able to project my 3d model made of triangles into 2d space: I rotate, translate and project my points to get a 2d space representation ...
5
votes
2answers
3k views

In OpenGL Can I Discover the Depth Range of a Depth Buffer?

I am doing a GL multi-pass rendering app for iOS. The first pass renders to a depthbuffer texture. The second pass uses the values in the depth buffer to control the application of a fragment shader. ...
5
votes
1answer
180 views

overlapping 3d particles not blending nicely when at the same z

I'm working on a 3d particle emitter. It's going pretty good but I'm still having a problem with triangle sorting. As you can see in the photos, there are some particles that are not blending ...
5
votes
1answer
408 views

Slow glReadPixels

I have implemented a lense flare for my game, and it looks great. The first draft used individual sprites each with its own draw call. This was very slow, so I reengineered it to use a single draw ...
5
votes
0answers
116 views

How to pass depth buffer from OGRE to CUDA?

I am using OGRE for rendering some objects. At every frame, I would like to pass the resulting depth buffer to CUDA for running some kernels on it and computing a result. How can I achieve this? How ...
4
votes
3answers
489 views

When does depth testing happen?

I'm working with 2D sprites - and I want to do 3D style depth testing with them. When writing a pixel shader for them, I get access to the semantic DEPTH0. Would writing to this value help? It seems ...
4
votes
2answers
623 views

How to deal with large depth buffer values due to extreme distances

Alright, this is semi-related to my last question here So I've got an really big coordinate system and need to handle rendering large astral bodies from extreme distances. My current approach ...
4
votes
1answer
124 views

Forcing early-z with raytracing

I'm working on a GLSL raytracer, and I need to be able to edit gl_FragDepth in the FS. However, doing so disables early-z culling. The scene is rendered front-to-back and the FS can only push points ...
4
votes
1answer
613 views

The Depth buffer and Perspective

I'm having trouble understanding the behaviour of my OpenGL program; and in drawing my Z-Buffer out to the screen. It will probably be best to just start with code, here is my GLSL shader: in vec3 ...
4
votes
1answer
519 views

Can I use the default depth buffer when drawing to FBO?

How to attach default depth buffer to FBO? How to use depth renderbuffer buffer attached to FBO (after drawing to it) as a default depth buffer? Basically I want to use the same depth buffer for both ...
4
votes
1answer
601 views

using heightmap to simulate 3d in an isometric 2d game

I saw a video of an 2.5d engine that used heightmaps to do zbuffering. Is this hard to do? I have more or less no idea of Opengl(lwjgl) and that stuff. I could imagine, that you compare each pixel ...
4
votes
1answer
279 views

How do you display non-cutout transparent 2D textures with a depth buffer? (OpenGL)

I've been able to get my 2D renderer to display transparent cutout textures by testing the alpha of a fragment and discarding if it is less than 1 (or any fraction really). The problem is I want to ...
3
votes
2answers
2k views

computing gl_FragDepth

I am trying to draw spheres using a billboard, so I have a normal map with a z component that I am sampling in my fragment shader. I just need to add this z component to the depth of my fragment to ...
3
votes
1answer
63 views

Self occluding object and alpha blending

Look at the object I've rendered with my app: It's the same screen twice, above the original and below I've drawn (by hand :P) the shape of the mesh of one of plant's leaves. You can clearly see ...
3
votes
1answer
851 views

Renderbuffer to GLSL shader?

I have a software that performs volume rendering through a raycasting approach. The actual raycasting shader writes the raycasted volume depth into a framebuffer object, through gl_FragDepth, that I ...
3
votes
2answers
455 views

Scan-Line Z-Buffering Dilemma

I have a set of vertices in 3D space, and for each I retain the following information: Its 3D coordinates (x, y, z). A list of pointers to some of the other vertices with which it's connected by ...
3
votes
2answers
130 views

How can I simulate multiple depth channels?

Here's what I'd like to achieve: Rendering a first pass of objects in my scene, using standard depth comparison Rendering another pass of objects in the same scene, but with the following rules: A ...
3
votes
1answer
1k views

What are the valid DepthBuffer Texture formats in DirectX 11? And which are also valid for a staging resource?

I am trying to read the contents of the depth buffer into main memory so that my CPU side code can do Some Stuff™ with it. I am attempting to do this by creating a staging resource which can be read ...
3
votes
1answer
839 views

Drawing a depth map properly

I want to render a depth map by importing it from a file, then creating an array of vertices and indices, and then displaying it using a basic shader (just apply the view and projection matrices on it ...
3
votes
0answers
255 views

Annoying flickering of vertices and edges (possible z-fighting) [closed]

I'm trying to make a software z-buffer implementation (meaning no DirectX or OpenGL, only a 2D library, SDL to be precise), however, after I generate the z-buffer and proceed with the vertex culling, ...
3
votes
0answers
523 views

Copying render target texture loses all depth [duplicate]

I have a render target RenderTargetScene that holds my scene texture with the scene's depth buffer rtScene = new RenderTarget2D( graphicsDevice, ...
3
votes
0answers
814 views

Sampling from depth texture causes shader to stop working [closed]

I'm currently having issues with depth textures. When I sample from a depth texture it causes my other samplers to fail. For example, when I set gl_FragColor manually the depth buffer is correct. I ...
2
votes
2answers
133 views

Direct3D9 depth write without depth test

In OpenGL and Direct3D11 depth write is disabled if depth test is disabled. To enable depth write with out depth test in gl you must enable depth test with depth func always. OpenGL Even if the ...
2
votes
3answers
2k views

Depth Buffer not working in XNA?

I'm stumped. I have been fighting this for about 2 hours now. Here are the interesting parts of my code: protected override void Update(GameTime gameTime) { // Allows the game to exit if ...
2
votes
1answer
39 views

Disable depth testing for only some faces

I have some meshes and I need to be able to draw some part of them without depth test. Is it possible to turn off depth testing from within shader, wo that some parts will be rendered no matter what ...
2
votes
1answer
87 views

How to best utilize depth buffer precision

Are there strategies to minimize depth buffer precision problems with hyperbolic depth buffers, such as the ones resulting from perspective projection matrices, or depth buffers in general? For ...
2
votes
1answer
254 views

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 ...
2
votes
1answer
351 views

My transparent objects overwrite opaque objects depth and always draw on top?

I have set up an 'Order Independent Transparency' method for drawing my transparent objects. The algorithm can be simplified as follows: DrawOpaqueObjects() DrawTransparentObjects() Drawing the ...
2
votes
1answer
440 views

Writing the correct value in the depth buffer when using ray-casting

I am doing a ray-casting in a 3d texture until I hit a correct value. I am doing the ray-casting in a cube and the cube corners are already in world coordinates so I don't have to multiply the ...
2
votes
1answer
274 views

Use depth bias for shadows in deferred shading

We are building a deferred shading engine and we have a problem with shadows. To add shadows we use two maps: the first one stores the depth of the scene captured by the player's camera and the ...
2
votes
2answers
126 views

How scanline rendering finds an intersection with an object

I'm a newbie with graphics and after I read many articles on the web I still don't understand how in rasterizing from a pixel coordinate like (0;0) on the screen the intersection with an object (let's ...
2
votes
1answer
354 views

Position Reconstruction from Depth by inverting Perspective Projection

I had some trouble reconstructing position from depth sampled from the depth buffer. I use the equivalent of gluPerspective in GLM. The code in GLM is: template GLM_FUNC_QUALIFIER detail::tmat4x4 ...
2
votes
0answers
118 views

Best approach to depth streaming via existing codec [closed]

I'm working on a development system (and game) intended for games set mostly in static third-person views. We produce our scenery by CG and photographic techniques. Our background art is rendered ...
2
votes
0answers
191 views

Get Specific depth values in Kinect (XNA)

I'm currently trying to make a hand / finger tracking with a kinect in XNA. For this, I need to be able to specify the depth range I want my program to render. I've looked about, and I cannot see how ...
2
votes
1answer
1k views

Using SpriteBatch with BasicEffects and layerDepth creates negative Z values?

Simply: Why don't all of these sprites draw? What do I need to do to make them draw? I'm trying to use SpriteBatch.Draw with the layerDepth parameter to help reduce overdrawn. However I can't get it ...
1
vote
2answers
438 views

How to clear a buffer to 1.0 instead of 0.0 in OpenGL?

Using glClear() you can set the buffer specified by the parameter to 0.0. This is useful say if you want pixels not covered by models to be black. Because vec3(0.0, 0.0, 0.0) results in black. But ...
1
vote
1answer
1k views

Early Z culling - Ogre

For Ogre experienced people, but also experts in the field: Early Z culling is sometimes quite desirable, and that's what I tried to do in Ogre by using a two pass material. The first one is writing ...
1
vote
1answer
87 views

Drawing sprites messes up my model in XNA4

I have a model which draws correctly in XNA4. However if I try to add a background image (or any sprite), the rendering of my model is messed up. There are two problems with the rendering model is ...
1
vote
1answer
178 views

Why does switching to fullscreen produce this graphical glitch?

I followed this tutorial and things were looking good. However, when switching to Fullscreen from 800x600 using alt-enter, I noticed an error in debug output: DXGI WARNING: IDXGISwapChain::Present: ...
1
vote
1answer
231 views

How do I copy the depth buffer to CPU memory in Direct3D 9?

I have code in OpenGL that uses glReadPixels to copy the depth buffer to a CPU memory buffer: glReadPixels(0, 0, w, h, GL_DEPTH_COMPONENT, GL_FLOAT, dbuf); How do I achieve the same in Direct3D? I ...
1
vote
1answer
602 views

Why are my scene's depth values not being written to my DepthStencilView?

I'm rendering to a depth map in order to use it as a shader resource view, but when I sample the depth map in my shader, the red component has a value of 1 while all other channels have a value of 0. ...
1
vote
2answers
834 views

Disabling depth write trashes the frame buffer on some GPUs

I sometimes disable depth buffer writing via glDepthMask(GL_FALSE) during the alpha rendering of a frame. That works perfectly fine on some GPUs (like the Motorola Droid's PowerVR), but on the HTC EVO ...
1
vote
2answers
55 views

Layer depth problem

I try to create Puzzle JigSaw,and I want to display the selected piece on the first layer, the pieces that are on the original positions(solved) on the last layer and the others on the middle. I ...
1
vote
0answers
71 views

Depth write and depth test in Unity

Scenario: several objects (o1, o2,.., on) have to be rendered with the z test disable, but the z values must be written to the depth buffer. In another pass, some other objects (t1, t2,..., tm) need ...
1
vote
2answers
117 views

IsoMetric Map draw: sort with Topological Sort, Z-Buffer and anchor point

I'm writing an IsoMetric renderer for my html5 isometric game. The isometric renderer should be able to render objects with floating point coordinates. DEMO: http://matt93.altervista.org/game/ ...
1
vote
0answers
111 views

How do you tell OpenGL ES 2.0 to use a texture as the depth buffer?

I want to render a scene with an outline post processing effect in OpenGL ES 2.0. First I render all the opaque objects. Then I use a post processing shader for silhouette detection that uses the ...
1
vote
2answers
192 views

Direct3D9 application won't write to depth buffer

I've got an application written in D3D9 which will not write any values to the depth buffer, resulting in incorrect values for the depth test. Things I've checked so far: D3DRS_ZENABLE, set to TRUE ...