From 0256023f8f8f6a1b35295912a518438941e2ada1 Mon Sep 17 00:00:00 2001 From: 1i9h7_b1u3 <1012796366@qq.com> Date: Wed, 15 Jan 2025 21:57:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E2=80=9C=E6=B7=B1=E5=BA=A6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E2=80=9D=E4=B8=AD=E6=BA=90=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=9A=84=E5=8F=98=E9=87=8F=E5=90=8D=E5=92=8C=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/04 Advanced OpenGL/01 Depth testing.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/04 Advanced OpenGL/01 Depth testing.md b/docs/04 Advanced OpenGL/01 Depth testing.md index 8d906c5..579f916 100644 --- a/docs/04 Advanced OpenGL/01 Depth testing.md +++ b/docs/04 Advanced OpenGL/01 Depth testing.md @@ -136,13 +136,13 @@ void main() 首先我们将深度值变换为NDC,不是非常困难: ```c++ -float z = depth * 2.0 - 1.0; +float ndc = depth * 2.0 - 1.0; ``` -接下来使用获取到的z值,应用逆变换来获取线性的深度值: +接下来使用获取到的NDC值,应用逆变换来获取线性的深度值: ```c++ -float linearDepth = (2.0 * near * far) / (far + near - z * (far - near)); +float linearDepth = (2.0 * near * far) / (far + near - ndc * (far - near)); ``` 这个方程是用投影矩阵推导得出的,它使用了方程2来非线性化深度值,返回一个nearfar之间的深度值。这篇注重数学的[文章](http://www.songho.ca/opengl/gl_projectionmatrix.html)为感兴趣的读者详细解释了投影矩阵,它也展示了这些方程是怎么来的。 @@ -158,7 +158,7 @@ float far = 100.0; float LinearizeDepth(float depth) { - float z = depth * 2.0 - 1.0; // back to NDC + float z = depth * 2.0 - 1.0; // 转换为 NDC return (2.0 * near * far) / (far + near - z * (far - near)); }