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导航”,非常简 ...
随机推荐
- 第一个wxWidgets程序
wxWidgets的安装方法网上有一大堆,可以参照http://wiki.codeblocks.org/index.php?title=WxWindowsQuickRef 这里解压并编译 ,也可以参照 ...
- EntityClient 介绍
System.Data.EntityClient 命名空间是 实体框架的 .NET Framework 数据提供程序.EntityClient 提供程序使用存储特定的 ADO.NET 数据提供程序类和 ...
- Scala - 处理时间(nscala-time - Joda Time的scala封装)
GITHUB : https://github.com/nscala-time/nscala-time MAVEN : (注意选对scala版本) <dependency> <gro ...
- tomcat server.xml配置文件 解析
把服务拆分出来了. 前几天我也进行了拆分.可是当时服务起不来所以我想会不会有什么设置,使得这个服务在主机中只能启一个.然后我又找了一台服务器,也把代码放了进去.结果仿佛是我料想到的样子, ...
- 自己动手丰衣足食,h5手机端jquery弹窗插件(事件冒泡、单例模式、遮盖部分禁止默认滚动)
感谢浏览,欢迎交流=.= 公司开发微信网页多处需要使用弹窗,使用jquery-ui的定制化下载仍需要150多kb,想来有些奢侈(最终下来只有11kb,压缩后2kb,啊,我的神), 手机端弹窗方式与pc ...
- docker的基本使用
docker 基本的使用命令docker pull centos:latestdocker images centosdocker run -i -t centos /bin/bash //也可以使用 ...
- PL/SQL学习(二)条件和循环语句
原文参考:http://plsql-tutorial.com/ PLSQL条件语句 IF THEN ELSE STATEMENT 1) IF condition THEN statement ...
- 犯这个错误的肯定不止我一个 关于File
File.Create(string filePath)这种用法所有人都知道,这两天用到的时候却发现一个问题. 需要先判断文件是否存在,如果不存在则创建文件,然后向该文件写入数据,后续定时Append ...
- css3 标题超过长度自动省略号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- php中mysqli 处理查询结果集的几个方法
最近对php查询mysql处理结果集的几个方法不太明白的地方查阅了资料,在此整理记下 Php使用mysqli_result类处理结果集有以下几种方法 fetch_all() 抓取所有的结果行并且以关联 ...