模型視圖變換時,法線向量要乘模型視圖矩陣的逆轉置矩陣【轉】

模型視圖變換時,法線向量要乘模型視圖矩陣的逆轉置矩陣

早前一直被這個問題困惑,可是本身推倒了不少遍也沒推出來。
哎,在gameres上搜了3年前的談話,後來在gamedev搜到了答案。
其實在計算機圖形學中,只要是變換,不管平移,旋轉,縮放,都是乘一個矩陣。
在模型視圖變換時,頂點乘模型視圖變換矩陣,而頂點對應的頂點法線向量(或其餘的法線向量)則要乘模型視圖矩陣的逆轉置矩陣。
頂點和法線都是向量,他們的區別是什麼?無非頂點是<x, y, z>表示缺省的<x, y, z, 1>,而法線向量是<x, y, z>表示缺省的<x, y, z, 0>。關於爲何是這樣,不用我說了吧,2個頂點向量減下看看就知道了。
從這點來看,確實不一樣,或許就是這個不一樣,形成了變換的不一樣吧。
法線向量只能保證方向的一致性,而不能保證位置的一致性,因此,全部線向量必須以面的形式進行變換,以下:

Transforming Planes

If we have a plane vector n = [a, b, c, d] which describes a plane then for any point p = [x, y, z, 1] in that plane the follow equation holds:html

nt p = ax + by + cz + d = 0 app

If for a point p on the plane, we apply an invertible transformation R to get the transformed point p1, then the plane vector n1 of the transformed plane is given by applying a corresponding transformation Q to the original plane vector n where Q is unknown. post

p1 = R p
n1 = Q n orm

We can solve for Q by using the resulting plane equation:

n1t p1 = 0 htm

Begin by substituting for n1 and p1:

(Q n)t (R p) = 0
nt Qt R p = 0 blog

If Q t R = I then n t Q t R p = n t I p = n t p = 0 which is given.

Qt R = I
Qt = R-1
Q = (R-1)t get

Substituting Q back into our plane vector transformation equation we get:

n1 = Q n = (R-1)t n it

相關文章
相關標籤/搜索