3
$\begingroup$

I had a z-fighting/z-clipping issue with a scene containing some very large objects yesterday in 3ds max. It can be seen in the image below: z-fighting issue

For some reason downscaling the scene significantly (a factor of 100 approx) resolves the z-fighting issues... Please help me understand how reducing scene scale could resolve this issue and why this issue only occurs with very large scenes/objects.

From what i understand z-fighting occurs in this case because the near and far planes are very far apart compared to the minimum and maximum distance of the rendered object(s) relative to the viewport.

Please correct me if I'm wrong, my basic understanding of the z-buffer is as follows:

1) The distance of each rendered pixel of the object(s) is compared to a standard value stored in the z-buffer.

2) if the depth of the current pixel is smaller than the currently stored value for this pixel location in this image...the value for this pixel in the z-buffer is overwritten with the new and lower value.

3) before the z-depth value is stored in the z-buffer it is divided by a certain value (floating point type value), not sure why the number is devided. perhaps to reduce memory usage by storing smaller values...

I managed to fix the z-fighting in the viewports by increasing the near plane (in viewport settings) from 0.1 ish to a larger value.

Please take a look at the image below: enter image description here The red planes are the camera's near and far planes. The green planes I have drawn myself and they indicate the minimum distance of the object relative to the camera and the maximum distance of the object relative to the camera. When scaling the scene by a factor x the ratio between the variables A,B,C,D (please see the dimensions drawn in the image) should stay approximately the same (as in the ratios A/B , A/C, A/D, B/A etc. should be approximately equal before and after the scaling process takes place). Therefore the max and min depth relative to the near and far viewport planes should be approximately equal. And as a result the depth precision of the object should not change when scaling (I think). My understanding is clearly incorrect since the z-fighting disappears when downscaling. Why is it that scaling has any effect on the z-fighting? Does 3ds max automatically adjust the far and near plane distances relative to the viewport when scaling the object/scene?

I've read about something called depth precision (https://developer.nvidia.com/content/depth-precision-visualized). Assuming this (objects(their pixels) that are closer to the camera being stored more accurately in the z-buffer) is true in 3ds max it makes sense that when zooming in really close to the object in the viewport...the z-fighting disappears. however, when I zoom out quite a lot in the viewport, the z-fighting also isn't visible anymore even though it should in my mind get worse since the precision of the depth info stored in the z-buffer is lower for objects further away from the camera. Am I missing something ? enter image description here

PS: the viewport clipping distances are set to the default in the image below and the first image of this post.

If I have been unclear or incomplete about anything please let me know and I will try my best to explain/elaborate. Any help will be greatly appreciated. Thank you very much!

$\endgroup$

3 Answers 3

2
$\begingroup$

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 right track. Z-fighting occurs when there is not enough numerical precision to distinguish two "objects" from the scene rendered at the same pixel. In such cases, the two pixels "fight" one another over which one is closest to the camera and flickering occurs.

These factors influence how a scene is susceptible to Z-fighting:

  • Number of bits used by the depth buffer (typically 24 or 32).
  • Whether the depth buffer uses float values or integers.
  • Whether the Z value 0 is used for the near or far plane (inverted depth buffer).
  • How close objects are to each other.
  • The size of the range between the near and far planes.

Of these, you really only have control over the near and far planes from what you say. It looks like your model is too big for the default way 3ds max handles this so I suggest making the near plane value bigger. An increase of the near plane from 0.1 to 1.0 (*10) will give the same precision increase as dividing the far plane by 10.

For your other question, you usually get less Z-fighting when an object is closer because there is more precision in the depth buffer closer to the near plane.

Also, for your other question: Why do GPUs divide clip space Z by W, for position?

A nice Z precision visualizer: http://dev.theomader.com/depth-precision/

$\endgroup$
1
$\begingroup$

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 causes the flashing, you want to consider the distances as a ratio. There is the distance between the two planes and then the distance between the two planes and the viewer, or the POV, point of view. If the two competing faces are extremely close together and the POV is extremely far from them, it will be as if the two surfaces are overlapping. If changes in distance are so subtle, that the decimals defining those changes are too small to register in the buffer, then it can be as if one face moves in front of the other, after another slight movement, the calculation changes, and the faces revert.

When you scale the model, that ratio changes significantly. Moving the competing faces further apart, will also affect the ratio. Understanding what causes the flashing will allow artists to devise solutions. For example, an object that will always be viewed from a distance, can probably be created such that the faces that might conflict, are spaced farther apart, than would be optimal for close inspection viewing.

$\endgroup$
-2
$\begingroup$

Right Click on the viewport PERSPECTIVE and enable viewport Clipping. On the right of the screen, 2 yellow arrows will appear. Drag the bottom arrow up a little. Worked for me.

$\endgroup$
1
  • 1
    $\begingroup$ Nice attempt, but the question isn't about how to use 3ds Max, but rather how 3ds Max works and why this changes makes the z-fighting go away. Could you edit your answer to answer that question? $\endgroup$
    – Dan Hulme
    Commented May 9, 2019 at 20:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.