我正在阅读一篇很棒的OpenGL教程。真的很棒,相信我。我目前的主题是Z-buffer。除了解释它的全部内容外,作者还提到我们可以执行自定义深度测试,例如GL_LESS, GL_ALWAYS等。他还解释说,深度值的实际含义(哪些是top,哪些不是)也可以自定义。到目前为止我明白了。然后作者说了一些难以置信的话
The range zNear can be greater than the range zFar; if it is, then the window-space values will be reversed, in terms of what constitutes closest or farthest from the viewer. Earlier, it was said that the window-space Z value of 0 is closest and 1 is farthest. However, if our clip-space Z values were negated, the depth of 1 would be closest to the view and the depth of 0 would be farthest. Yet, if we flip the direction of the depth test (GL_LESS to GL_GREATER, etc), we get the exact same result. So it's really just a convention. Indeed, flipping the sign of Z and the depth test was once a vital performance optimization for many games.
如果我理解正确的话,在性能方面,翻转Z的符号和深度测试只不过是将<比较更改为>比较。所以,如果我理解正确,作者没有说谎或编造,那么将<改为>对许多游戏来说是一个至关重要的优化。
是作者编造的东西,是我误解了什么,还是确实是这样,一旦<比>慢(至关重要,正如作者所说)?
谢谢你澄清这个相当奇怪的问题!
免责声明:我充分意识到算法的复杂性是优化的主要来源。此外,我怀疑现在它肯定不会有任何不同,我并不是要求优化任何东西。我只是极度的,痛苦的,也许是极度的好奇。