Skip to main content
10 votes
Accepted

What modern real-time rendering applications still use fragment shader depth writes / late-Z?

Any techniques that involve raytracing in the fragment shader might want to write Z in order that the depth buffer contain an accurate representation of the raytraced surface. For example: Distance-...
Nathan Reed's user avatar
  • 25.1k
6 votes

How will the z-buffers have the same values even if polygons are sent in different order?

If you use alpha blending, then the order of rendered polygons matters even if you use depth writes & tests. E.g. imagine you render two triangles A (red) and B (blue) with 50% opacity where the ...
JarkkoL's user avatar
  • 3,636
6 votes
Accepted

How will the z-buffers have the same values even if polygons are sent in different order?

What your teacher means is that at the end of the frame, once all polygons in the scene have been drawn, the z-buffer will have the same values. This is because the z-buffer keeps the minimum Z within ...
Nathan Reed's user avatar
  • 25.1k
5 votes
Accepted

How to solve Z buffer artifacts

Short answer: Move your near clip plane further away. Depth buffer precision is very sensitive to the near clip plane distance. Complicated answer: Use different math in your view projection. There ...
Chifti Saidi's user avatar
4 votes
Accepted

Perspective correct interpolation z-buffer

Yes, that's correct. Perspective-correct interpolation works by (for some quantity $u$ to be interpolated) calculating $u/z$ and $1/z$ at each vertex, linearly interpolating those values in screen ...
Nathan Reed's user avatar
  • 25.1k
3 votes

Correct way to interpolate 1/z?

You are right. In the examples you provided you only seem to render "pre-transformed" triangles which is why I think you were missing the point made in the article. Which depth testing is ...
Michele M.'s user avatar
3 votes

How to understand Z-Fighting?

The camera does not need to move for this problem to exist. You can see the mixed polygons as in your linked image even with a static camera. Things are worse with a moving camera because it makes ...
Olivier's user avatar
  • 1,585
3 votes
Accepted

How to implement Z-buffering?

The values for each pixel in the Z-buffer are interpolated from the values at the corners of the triangle during rasterization. To make this work, the projection matrix produces depth values that are ...
russ's user avatar
  • 2,402
3 votes
Accepted

Z-buffering implementation with small triangles

Assuming the small triangles form continuous surfaces, although many of the small triangles "fall through the gaps" (so to speak), some should still cover the samples. If on the other hand, they are ...
Simon F's user avatar
  • 4,306
2 votes
Accepted

3ds max: Z-fighting when working with Large Objects

Unfortunately, I don't know how 3ds max handles its Z-buffer or its near and far planes so I can't give a definite answer. There are many ways the software could handle this. However, you are on the ...
bernie's user avatar
  • 830
2 votes
Accepted

A solution to sprite visibility in a raycasting engine with variable wall heights?

Congratulations for having progressed so far. Context, first analysis Your explanation: I am using a z-buffer, with one stored length to a wall for the x coordinate of each ray. Means the z-buffer ...
Stéphane Gourichon's user avatar
2 votes
Accepted

Objects in depth buffer are always black (0.0)

That's how I used to initialize viewport (CD3DX12_VIEWPORT). But I didn't realize that there are two additional fields minDepth and maxDepth. Therefore, I have min/max depth set to 0.0 and objects ...
DirectX_Programmer's user avatar
2 votes
Accepted

What does the z-buffer look like in memory?

The Z buffer used to be specialized memory set aside for a single purpose, some web sites still explain it like that, but no longer. Now the Z buffer is just a chunk of memory you allocate, or an API ...
pmw1234's user avatar
  • 3,239
2 votes
Accepted

OpenGL in CodeBlocks with GNU GCC compiler not recognising some constants

It sounds like your version of the opengl.h header is too old, and doesn't include the declarations for functions and constants from newer versions. Despite that ...
Nathan Reed's user avatar
  • 25.1k
1 vote
Accepted

Understanding gluUnProject

With your question you have basically identified a core problem in your assumption of "how the OpenGL's gluUnProject works", namely that this function isn't actually part of the OpenGL. The ...
Christian Rau's user avatar
1 vote
Accepted

Why we calculate z buffer value from plane equation $AX+BY+CZ+D=0$?

You are talking about two different planes. The website is talking about the plane of the quadrilateral being rendered. It uses that plane to compute the Z for a particular X,Y point. Basically, the ...
Nicol Bolas's user avatar
  • 9,842
1 vote

OpenGL transparency - object behind is not rendered

It depends on the order of rendering. When first rendering the object which is far away and then rendering the closer object, the transparency will work. Otherwise when first rendering the close ...
Thomas's user avatar
  • 1,295
1 vote
Accepted

Generate Hi-Z buffer using single PSO and single UAV

The code for mip1 and mip2 (and higher mips if you have them—SSR ray marching can benefit a lot from higher mips) is identical except for which mip is being read and written; you don't need separate ...
Nathan Reed's user avatar
  • 25.1k
1 vote

Problem using Decaling with Stencil to avoid Z-fighting

It sounds like this code is using the stencil buffer to mask off the locations to draw the line. This isn't a "typical" decal approach. Normally the decal is draw directly into the scene and ...
pmw1234's user avatar
  • 3,239
1 vote

Layer rendering in Vulkan

I think you may be overcomplicating things with your idea of using the stencil. In 2D graphics layers, we usually do not need to use the depth buffer to resolve depth order between 2D elements (their ...
Nathan Reed's user avatar
  • 25.1k
1 vote

3ds max: Z-fighting when working with Large Objects

FYI, the first answer is very close to explaining the causes of Z-fighting, or Z-flashing. It is about decimal places and it does relate to distance, or the simulation of distance. To understand what ...
Rick Keller's user avatar
1 vote

How to understand Z-Fighting?

As others mentioned, z-fighting/stiching occurs even if the camera is not moving. However, when the camera is moving and you're getting z-fighting, it will appear as though the polygons are ...
boni's user avatar
  • 11
1 vote

How to understand Z-Fighting?

Z-fighting is not related with camera movement. But this issue can be avoided by moving the near plane of the view frustum a little further away from the viewer. As you know, depth testing is the ...
videogamechef's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible