projectMatrix
第一步
第二步
转到NDC:
因为目前只有 \(-1 \le y' \le 1\),对于 \(x'\)可以除与\(r\)
所以:
matrix
我们可以使用matrix表示,但是上面 \({eq. 5.1}\)不是线性的。需要矩阵(线性表示)表示的话,需要除于\(z\)才能满足线性.所以要将\(z\)放到\(w\)位置上:
因为上面那个式子带有了\(z\)所以不是线性的.我们下面详细讲解:
输入一个三维点 \((x,y,z)\),我们写成4维 \((x,y,z,1)\),然后与矩阵相乘:
这个是严格的线性变换,我们设计矩阵\(P\)的核心诡计:让输出的\(w'\)刚好等于原始输入的\(z\),把需要用来做除法的深度值存起来。后面在最终结果最后取出这个\(w'\)进行除法。
把一个点带入:
After multiplying by the projection matrix (the linear part), we complete the
transformation by dividing each coordinate by \(w = z\) (the nonlinear part):
归一化 z
这个时候三维模型被投影到了二维平面上了,看来是完成了三维到二维的投影,应该算是完了.但是有时候需要深度信息.
Therefore, we must construct an order preserving function \(g(z)\) that maps the interval \([n, f]\) onto \([0, 1]\)
Equation 5.3, that the \(z\)-coordinate undergoes the transformation:
We now need to choose \(A\) and \(B\) subject to the constraints:
Condition 1: \(g(n) = A + B/n = 0\) (the near plane gets mapped to zero)
Condition 2: \(g(f) = A + B/f = 1\) (the far plane gets mapped to one)
Solving condition 1 for \(B\) yields: \(B = -An\). Substituting this into condition 2 and solving for \(A\) gives:
Therefore,
最后得出的矩阵:
posted on 2026-07-17 16:24 Ultraman_X 阅读(5) 评论(0) 收藏 举报
浙公网安备 33010602011771号