模型视图变换时,法线向量要乘模型视图矩阵的逆转置矩阵
来源:互联网 发布:dnf辅助源码官网 编辑:程序博客网 时间:2024/05/21 00:48
模型视图变换时,法线向量要乘模型视图矩阵的逆转置矩阵
早前一直被这个问题困惑,但是自己推倒了很多遍也没推出来。
哎,在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:
nt p = ax + by + cz + d = 0
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.
p1 = R p
n1 = Q n
We can solve for Q by using the resulting plane equation:
n1t p1 = 0
Begin by substituting for n1 and p1:
(Q n)t (R p) = 0
nt Qt R p = 0
If Qt R = I then nt Qt R p = nt I p = nt p = 0 which is given.
Qt R = I
Qt = R-1
Q = (R-1)t
Substituting Q back into our plane vector transformation equation we get:
n1 = Q n = (R-1)t n
哎,在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:
nt p = ax + by + cz + d = 0
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.
p1 = R p
n1 = Q n
n1t p1 = 0
(Q n)t (R p) = 0
nt Qt R p = 0
Qt R = I
Qt = R-1
Q = (R-1)t
n1 = Q n = (R-1)t n
0 0
- 模型视图变换时,法线向量要乘模型视图矩阵的逆转置矩阵
- shader中法线向量为什么要乘以模型视图矩阵的逆转置矩阵
- shader中法线向量为什么要乘以模型视图矩阵的逆转置矩阵
- 法线向量为什么要乘以模型视图矩阵的逆转置矩阵
- OpenGL: 模型视图矩阵变换
- 理解OpenGL中的模型视图矩阵变换
- 理解OpenGL中的模型视图矩阵变换
- 理解OpenGL中的模型视图矩阵变换
- 逆转置矩阵来变换法线
- 模型视图矩阵
- 投影矩阵 视图模型矩阵
- 模型矩阵、视图矩阵、投影矩阵
- 法线的归一化和法线视图变换矩阵的正确设置
- opengl入门系列2- 模型视图矩阵变换
- OpenGL(五) 三维变换之模型视图矩阵
- OpenGL 入门教程 模型视图投影矩阵 变换光线
- 关于OpenGL模型视图矩阵的研究
- 关于模型视图矩阵的相机
- jQuery.attr() 函数详解
- 使用surfaceView制作视频播放器
- 微课堂第12期:移动互联网测试——你应该要掌握的技能树
- NYOJ 78 圈水池 (凸包输出路径)
- Oracle SQL性能优化
- 模型视图变换时,法线向量要乘模型视图矩阵的逆转置矩阵
- 关于不使用appStore版本更新的问题
- 定义枚举
- 设计模式之单例模式(Singleton pattern)
- Eclipse工具详解及配置信息
- 第一次写文字之Markdown编辑器
- 生成推送的P12证书
- eclipse优化
- Python-ConfigParser常用操作示例