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:
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: 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 ?
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!