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的更多相关文章

  1. Surface Normal Vector in OpenCascade

    Surface Normal Vector in OpenCascade eryar@163.com 摘要Abstract:表面上某一点的法向量(Normal Vector)指的是在该点处与表面垂直的 ...

  2. Surface Normal Averaging

    Surface Normal Averaging eryar@163.com 摘要Abstract:正确设置网格面上点的法向,对几何体在光照等情况下显示得更真实,这样就可以减少顶点数量,提高渲染速度. ...

  3. Vector Math for 3D Computer Graphics (Bradley Kjell 著)

    https://chortle.ccsu.edu/VectorLessons/index.html Chapter0 Points and Lines (已看) Chapter1 Vectors, P ...

  4. 【译】Unity3D Shader 新手教程(1/6)

    本文为翻译,附上原文链接. 转载请注明出处--polobymulberry-博客园. 刚开始接触Unity3D Shader编程时,你会发现有关shader的文档相当散,这也造成初学者对Unity3D ...

  5. CSS3与页面布局学习总结(七)——前端预处理技术(Less、Sass、CoffeeScript、TypeScript)

    CSS不像其它高级语言一样支持算术运算.变量.流程控制与面向对象特性,所以CSS样式较多时会引起一些问题,如修改复杂,冗余,某些别的语言很简单的功能实现不了等.而javascript则是一种半面向对象 ...

  6. CSS3与页面布局学习笔记(七)——前端预处理技术(Less、Sass、CoffeeScript、TypeScript)

    CSS不像其它高级语言一样支持算术运算.变量.流程控制与面向对象特性,所以CSS样式较多时会引起一些问题,如修改复杂,冗余,某些别的语言很简单的功能实现不了等.而javascript则是一种半面向对象 ...

  7. stl文件格式

    http://wenku.baidu.com/view/a3ab7a26ee06eff9aef8077b.html [每个三角形面片的定义包括三角形各个定点的三维坐标及三角形面片的法矢量[三角形的法线 ...

  8. NV SDK 10 (1) Clipmaps

    Clipmaps sample: Abstract Clipmaps are a feature first implemented on SGI workstations that allow ma ...

  9. FreeCAD鼠标操作指南

    鼠标控制模式 跳转至: 导航. 搜索 freeCAD鼠标的控制模式由多个命令构成,用于三维空间的视觉导航和控制显示对象.freecad支持多个鼠标导航方式.默认的导航方式是被称为“CAD导航”,非常简 ...

随机推荐

  1. HDU 4294 A Famous Equation(DP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4249 题目大意:给一个a+b=c的表达式,但是a.b.c中部分位的数字丢失,并用?代替,问有多少种方案 ...

  2. HTML教程:link标记

    开发php语言的网站,<head>里link标签这样:<link href="xmlrpc.php?rsd=1" title="rsd" ty ...

  3. 【转】EXT JS MVC开发模式

    原文链接:EXT JS MVC开发模式 在app(亦即根目录)文件夹下面创建controller.model.store和view文件夹,从名称上就知道他们该放置什么代码了吧.然后创建Applicat ...

  4. js初学必知三重点

    这里列出了一些JS重要知识点(不全面,但自己感觉很重要).彻底理解并掌握这些知识点,对于每个想要深入学习JS的朋友应该都是必须的. 讲解还是以示例代码搭配注释的形式,这里做个小目录: JS代码预解析原 ...

  5. phpcms(1)phpcms V9 MVC模式 与 URL访问解析(转)

    [1]URL访问解析 观察访问网页时的网址,可以得出模块访问方法,如下示例: http://www.abcd.com.cn/phpcms/index.php?m=content&c=index ...

  6. php文件锁解决少量并发问题

    阻塞(等待)模式: <?php $fp = fopen("lock.txt", "r"); if(flock($fp,LOCK_EX)) { //..处理 ...

  7. POJ 2252 Dungeon Master 三维水bfs

    题目: http://poj.org/problem?id=2251 #include <stdio.h> #include <string.h> #include <q ...

  8. Java NIO之Selector

    选择器是JavaNIO重磅推出的一个概念:在旧有的系统中为了跟踪多端口消息,需要为每一个端口配备一个线程做监听:但是有了selector就不需要了,一个Selector可以管理一众渠道(channel ...

  9. utube视频落地

    utube视频落地 简单粗暴的方法: 利用视频下载网站的网页版进行处理. 比如需要下载的视频的url是vid_url, 需要用到的web服务的url是web_service vid_url='http ...

  10. iOS - 应用程序国际化

    开发的移动应用更希望获取更多用户,走向世界,这就需要应用国际化,国际化其实就是多语言.这篇文章介绍Xcode4.5以后的国际化,包括应用名国际化和应用内容国际化.如果是Xcode4.5之前版本请参考. ...