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导航”,非常简 ...
随机推荐
- javee学习-通过ServletContext对象实现数据共享
1,设置值. ServletContext context = this.getServletConfig().getServletContext();//获得ServletContext对象 // ...
- Win32 CreateWindow GdiPlus
#include "stdafx.h" #include "TestGidPlus.h" LRESULT CALLBACK WndProc(HWND, UINT ...
- v4l2简介
V4L是linux内核中关于视频设备的子系统,为linux下的视频驱动提供了统一的接口,使应用程序可以使用统一的API操作不同的视频设备,简化视频系统的开发与维护 V4L2相比与V4L有更好的扩展性和 ...
- ubuntu mint 15 编译安装PHP开发环境
php 5.3.5(download zip) httpd 2.2.24(download zip) mysql: apt-get install mysql step 1: install mysq ...
- getDrawingRect,getHitRect,getLocalVisibleRect,getGlobalVisibleRect
本文主要大体讲下getHitRect().getDrawingRect().getLocalVisibleRect().getGlobalVisibleRect. getLocationOnScree ...
- 默认时,销毁会话,session_unset, session_destory
<?php /** 一般我们登录时,开启了会话,就会自动生成 session 有关的文件, 保存有相关的用户登录信息,所以正常情况下得退出登录, 同时也要清空 session 有关的文件和相关的 ...
- MySQL修改时区的方法小结
这篇文章主要介绍了MySQL修改时区的方法,总结分析了三种常见的MySQL时区修改技巧,包括命令行模式.配置文件方式及代码方式,需要的朋友可以参考下 方法一:通过mysql命令行模式下动态修改 1.1 ...
- STM32启动过程--启动文件--分析
一.概述 1.说明 每一款芯片的启动文件都值得去研究,因为它可是你的程序跑的最初一段路,不可以不知道.通过了解启动文件,我们可以体会到处理器的架构.指令集.中断向量安排等内容,是非常值得玩味的. ST ...
- 使用自定义《UIActivity》进行内容分享-b
简介 这段时间有很多朋友都问我关于怎么去集成ShareSDK或者友盟社会化分享SDK的问题, 其实我想说, Apple一开始就提供了一个类, 供我们去使用分享了, 在iOS 6之后更加增强了这个类, ...
- 使用ImageMagick和Tesseract进行简单数字图像识别
使用ImageMagick和Tesseract进行简单数字图像识别 由于直接使用 tesseract 进行识别,识别率很低, ImageMagick 安装.配置及使用: 平台:winXP 1. 安装I ...