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

转载于:https://www.cnblogs.com/smartgloble/p/3178559.html

Normal Vector Using WorldInverseTranspose相关推荐

  1. Calc3: Vector Fields

    Vector Fields Definition A vector field on R3R^3R3 with domain as D is a function F⃗\vec FF that ass ...

  2. 初译 Support Vector Machines:A Simple Tutorial(一)

    <Support Vector Machines:A Simple Tutorial> 作者 Alexey Nefedov   (一)Introduction 在本章节中将会介绍一些用于定 ...

  3. Common Vector Operators(常见的向量操作)

    周一到周五,每天一篇,北京时间早上7点准时更新~ Vectors behave as you would expect for operations such as addition, subtrac ...

  4. Learn OpenGL 笔记6.5 Normal Mapping(法线贴图)

    我们通过在这些平面三角形上包裹 2D 纹理来增强真实感,隐藏多边形只是很小的平面三角形的事实. 从照明技术的角度来看,确定对象形状的唯一方法是通过其垂直法向量. 这种使用每片段法线与每表面法线相比的技 ...

  5. Normal map (Bump mapping) 法线贴图(凹凸映射) Standard Shader系列10

    Normal map (Bump mapping) 法线贴图(凹凸映射) 本文档主要是对Unity官方手册的个人理解与总结(其实以翻译记录为主:>) 仅作为个人学习使用,不得作为商业用途,欢迎转 ...

  6. Real-Time Rendering——6.7.1 Blinn’s Methods 6.7.2 Normal Mapping法线映射

    6.7.1 Blinn's Methods Blinn's original bump mapping method stores two signed values, bu and bv, at e ...

  7. Learn OpenGL (九):基础光照

    环境光照(Ambient Lighting):即使在黑暗的情况下,世界上通常也仍然有一些光亮(月亮.远处的光),所以物体几乎永远不会是完全黑暗的.为了模拟这个,我们会使用一个环境光照常量,它永远会给物 ...

  8. OpenGL 矩阵变换

    origin refer :http://www.songho.ca/opengl/gl_transform.html#modelview OpenGL 矩阵变换 Related Topics: Op ...

  9. dot3_bump_mapping

    为什么80%的码农都做不了架构师?>>>    //----------------------------------------------------------------- ...

最新文章

  1. 图表+笔记-python语言-第5章:数字/5.11 位操作
  2. Oracle 技术支持之现场优化的思维路径
  3. zookeeper收尾+dubbo前瞻
  4. Modebus Slave 与 Modbus Poll主从设备模拟软件与Configure Virtual Serial串口模拟软件使用
  5. 如何查看进程的运行路径
  6. 手动创建数据库实例全攻略7:UNDO
  7. 《Node应用程序构建——使用MongoDB和Backbone》一第 1 章 介绍与总览1.1 打造一个社交网络...
  8. html文件的获取,获取html文件Java
  9. 对android上下文和窗口的理解
  10. 详情和 PoC 发布后,谷歌匆忙修复严重的 Gmail 漏洞
  11. 没有躲过的坑--0xC0000005: 读取位置 xxx时发生访问冲突
  12. 网络游戏外挂编写初级教程
  13. mysql relay_mysql relay log参数汇总
  14. 关于android 百度地图离线包的调用问题
  15. Android————一个简单的新闻面板
  16. 企业邮箱“成员收发权限”功能详解【如何开通企业邮箱】
  17. 数据库三大范式详解,部分依赖、完全依赖、传递依赖
  18. 物联网LoRa系列-24:LoRa终端--PingPong应用程序常见问题解析
  19. 【基因调控网络】Discovering Gene Networks with a Neural-Genetic Hybride(单层神经网络与遗传算法混合算法2005)
  20. 纷享销客数字化营销能力(三):全渠道获客

热门文章

  1. python向mysql中添加数据_通过python操控MYSQL添加数据,并将数据添加到EXCEL中-阿里云开发者社区...
  2. muduo网络库学习(九)日志类Logger和LogStream,将日志信息打印到屏幕
  3. FreeBSD设置IP地址,网关,DNS
  4. 如何进行良好的程序设计(1)
  5. S3C2440启动代码分析
  6. hihoCoder #1441 : 后缀自动机一·基本概念
  7. matlab下三维dla模型模拟,Matlab下三维DLA模型模拟
  8. 变量之--列表初始化和结构化绑定
  9. 智能指针——auto_ptr
  10. r语言ggplot2一夜多图_R语言ggplot2画四方形的热图展示相关系数的简单小例子