Normal Vector Using WorldInverseTranspose
shader里面经常看到normal向量是用WorldInverseTranspose矩阵做变换的,有时候也可以用WorldMatrix变换。
原理:
If your object is only ever rotated and translated, you can transform normals using the top left 3x3 portion of the world matrix.
If it is rotated, translated, and uniform scaled, you can do that same
3x3 matrix transform, but must then re-normalize the output vector to
remove the scaling.
But if the transform includes a non uniform scale, shear, taper, etc,
normals would no longer be correct after just a rotation. To get the
right normals in such situations, you must transform them by the inverse
transpose of the world matrix, then re-normalize the output vector.
The math is derived here: http://explodedbrain.livejournal.com/112906.html
Some shaders do this the complex slow way in order to be as robust as
possible. Others figure that nobody in their right mind would ever use a
non-uniform scale in a game, so they don't bother to support that,
which simplifies the shader and makes rendering more efficient (but can
lead to confusion if anyone ever does use an unsupported transform and
gets bogus lighting results).
总结: 如果object没有涉及到x,y,z方向的不统一缩放,就可以直接用WorldMatrix,否则用WorldInverseTranspose.
详细介绍参考:http://www.arcsynthesis.org/gltut/Illumination/Tut09%20Normal%20Transformation.html
Normal Vector Using WorldInverseTranspose的更多相关文章
- Surface Normal Vector in OpenCascade
Surface Normal Vector in OpenCascade eryar@163.com 摘要Abstract:表面上某一点的法向量(Normal Vector)指的是在该点处与表面垂直的 ...
- Surface Normal Averaging
Surface Normal Averaging eryar@163.com 摘要Abstract:正确设置网格面上点的法向,对几何体在光照等情况下显示得更真实,这样就可以减少顶点数量,提高渲染速度. ...
- Vector Math for 3D Computer Graphics (Bradley Kjell 著)
https://chortle.ccsu.edu/VectorLessons/index.html Chapter0 Points and Lines (已看) Chapter1 Vectors, P ...
- 【译】Unity3D Shader 新手教程(1/6)
本文为翻译,附上原文链接. 转载请注明出处--polobymulberry-博客园. 刚开始接触Unity3D Shader编程时,你会发现有关shader的文档相当散,这也造成初学者对Unity3D ...
- CSS3与页面布局学习总结(七)——前端预处理技术(Less、Sass、CoffeeScript、TypeScript)
CSS不像其它高级语言一样支持算术运算.变量.流程控制与面向对象特性,所以CSS样式较多时会引起一些问题,如修改复杂,冗余,某些别的语言很简单的功能实现不了等.而javascript则是一种半面向对象 ...
- CSS3与页面布局学习笔记(七)——前端预处理技术(Less、Sass、CoffeeScript、TypeScript)
CSS不像其它高级语言一样支持算术运算.变量.流程控制与面向对象特性,所以CSS样式较多时会引起一些问题,如修改复杂,冗余,某些别的语言很简单的功能实现不了等.而javascript则是一种半面向对象 ...
- stl文件格式
http://wenku.baidu.com/view/a3ab7a26ee06eff9aef8077b.html [每个三角形面片的定义包括三角形各个定点的三维坐标及三角形面片的法矢量[三角形的法线 ...
- NV SDK 10 (1) Clipmaps
Clipmaps sample: Abstract Clipmaps are a feature first implemented on SGI workstations that allow ma ...
- FreeCAD鼠标操作指南
鼠标控制模式 跳转至: 导航. 搜索 freeCAD鼠标的控制模式由多个命令构成,用于三维空间的视觉导航和控制显示对象.freecad支持多个鼠标导航方式.默认的导航方式是被称为“CAD导航”,非常简 ...
随机推荐
- UVA 10795 A Different Task(汉诺塔 递归))
A Different Task The (Three peg) Tower of Hanoi problem is a popular one in computer science. Briefl ...
- php练习5——简单的学生管理系统(隐藏控件的使用)
要求: 程序:gradeManage.html和gradeManage.php 结果 注意: 1.使用隐藏控件时,得在不同表单下,不能在同一个表单下: 2. ...
- 一个小程序[Socrates]中学到的Perl点滴
1. 抓取网页源文件,只要三行代码 use LWP::Simple; $url='http://music.baidu.com/top/dayhot'; $page=get($url) or die ...
- (转载)与OpenDialog相关的一个问题
OpenDialog的一个问题 有一个功能要求就是[每次打开文件的对话框的默认路径是上一次保存文件的路径],本来这个就是设置OpenDialog控件的InitialDir属性就行了,但是第一次打开的时 ...
- python 数据运算
算数运算:
- 【转】centOS中mysql一些常用操作
安装mysql yum -y install mysql-server 修改mysql配置vi /etc/my.cnf 这里会有很多需要注意的配置项,后面会有专门的笔记暂时修改一下编码(添加在密码下方 ...
- UIImageView 的 contentMode
UIViewContentModeScaleToFill, // 按设置尺寸 - 填充 UIViewContentModeScaleAspectFit, // 按设置尺寸 - 等比例填充, 有边界 U ...
- 两台主机打通ssh
ssh打通基本概念:如果需要通过SSH进行远程登录,我们一般是需要手动输入密码,但如果将SSH之间的权限打通的话,就可以实现无密码登录.这对shell脚本的定时执行有很大的帮助. (一),生成秘钥,先 ...
- java项目打成jar包时引用了第三方jar,此时我们该如何解决呢
Web项目做多了,反而对单纯的java项目陌生了,今天我们在开发项目的过程中,碰到一个这样的需求:需要将java项目放到linux系统上跑起来,当然这个javaSE项目是带main方法的.我们知道在I ...
- Google java编程技术规范
不遵循规范的程序猿,不是好的coder. 学习java有一段时间了,一直想找java编程技术规范来学习一下,幸而网络资源丰富,各路玩家乐于分享,省去了好多麻烦,姑且算站在网友的肩上,砥砺前行. /** ...