当前位置:网站首页>Tangent space
Tangent space
2022-04-23 13:31:00 【Zong haoduolao】
Tangent space
1、 What is tangent space ?
Tangent Space In fact, there is an origin + A local space determined by three coordinate axes , It's just a coordinate system
- Coordinate origin : Is the position of the vertex
- N Axis : Is the normal direction defined by the vertex
- T Axis (Tangent): Vector perpendicular to normal . But there are many such tangents , The standard approach is to combine the tangent direction and texture space (u or v Axis ) alignment , Generally choose u
- B Axis (Bitangent): adopt N Axis and T Cross product of axes
Tangent space is for any vertex of the model , How many points does the model have , How many independent tangent spaces are there
The normal texture we usually see ( Normal map ) It is constructed based on the original normal information . Each texture element stores the normal direction in the tangent space of each vertex . If the normal direction of a vertex remains the same , Or the normal direction of the original model ( The normal of a position on the surface is the vertical line of the tangent plane ), Then the normal in its tangent space is (0, 0, 1) , But this is not the value stored in the normal texture , Of each tattoo element RGB The value range of color component is (0, 1), Store normals with textures , Actually store XYZ vector , The direction of the vector XYZ The value range of the component is (-1, 1), Because the value range is different , So use textured RGB To represent the normal XYZ It doesn't mean , So we need to make a mapping , namely color = (normal + 1) / 2 . such , Normal value (0, 0, 1) Store in texture RGB The value of is (0.5, 0.5, 1), The normals stored on almost the entire texture b The components are all 1 Or very close to 1, So the normal texture is visually blue . So in summary , Normal texture RGB The channel stores the direction of the normal in the tangent space of each vertex Mapping values .
2、 Why do I need a normal map
When a model has many concave convex details , The vertex mesh of the model will be dense ( Large amount of data ), Then comes the performance problem . The bump of the model corresponds to different vertex heights , Thus, the directions of normals are different , After shading calculation , The concave convex feeling is very strong . However, in order to save space and computational performance , Do not want to increase the number of faces of the model , What do I do ? Only the normal information of the original model can be modified ( height map or Normal map ), Replace the original normal of this point with the modified normal , Perform shading calculations , Make the model look concave and convex
3、 With normal mapping, why do I need a normal mapping in tangent space
If the normal direction is in world coordinates (world space), That's called world space normal. If it is in the local coordinates of the object itself , That's called object space normal. It's easy to imagine ,world space normal Once extracted from the map , You can use it directly , It's very efficient . But there's a drawback , This world space normal It's fixed , If the object does not remain the same Direction and position , That originally generated normal map It's invalid . So someone saved object space normal. It decompresses from the map , It also needs to be multiplied by the same number as the model model、view Matrix conversion to world coordinates , Or convert to other coordinates, depending on the calculation process and requirements .object space normal Generated map , Objects can be rotated and displaced . Basically satisfactory . But there is still one drawback . That is, a map can only correspond to a specific model , The model cannot be deformed .
- world space normal texture: Directly save the normal direction of the points on the model surface in the world , After mapping the texture to the vertices of the model , The internal points are mapped by interpolation . If there are two as like as two peas at this time , But the location 、 Different directions , You cannot apply the same normal texture , Otherwise, the normal direction is wrong . So efficient but inflexible .
- object space normal texture: Each texture element saves the normal direction of each point in model space , Before mapping textures , The same as the model needs to be done again model-view Transformation . Poor efficiency , High flexibility , But you can't deform .
The problem is coming. , Can we find another coordinate system , So that the normal of the model can be correctly transformed into the world coordinate system when deforming ?
- When deforming , The vertex relationship has changed , That is, the shape of the face , The direction has changed . If there is a fixed coordinate system on the face , When an object deforms , Move , When rotating , This coordinate system must move with the surface , So a point or vector in this coordinate system , There is no need to change . When the whole face changes , We only need to calculate the transformation matrix from the coordinate system on the plane to the world coordinate system , Then the point or coordinate defined on this surface ( Constant oh ), Multiply this matrix to get the coordinates in the world . How this coordinate is constructed is not important to us at present , Please be sure to understand this concept . We're just looking for a local coordinate system , Point coordinates in local coordinate system , Multiply by the transformation matrix from local coordinate system to world coordinate system ( This matrix is based on the current transformation of the model , Dynamically calculated ), Get the coordinates of the points in the local coordinate system in the world coordinate system . This the normal direction stored in the normal map ( Fixed value ) Can be used for meaningful shading calculations .
- It's obvious to see here , This requires thousands of different coordinate systems defined on the face . How many faces are there on the low die , How many such coordinate systems do you have to have . The calculation amount of this method is naturally higher than object space normal map A bigger one . On each side of the low die , To construct this coordinate system . This coordinate system is called... In terminology tangent space.
4、TBN Matrix computing , Well, No .. I'll make it up later
For reference only , For details, please see the following
https://blog.csdn.net/damenhanter/article/details/22481563
https://www.zhihu.com/question/23706933/answer/161968056
http://www.opengl-tutorial.org/cn/intermediate-tutorials/tutorial-13-normal-mapping/#%E9%A1%B6%E7%82%B9%E7%9D%80%E8%89%B2%E5%99%A8
https://blog.csdn.net/weixin_46525412/article/details/120278159
版权声明
本文为[Zong haoduolao]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231325328781.html
边栏推荐
- Nodejs + Mysql realize simple registration function (small demo)
- filter()遍历Array异常友好
- [quick platoon] 215 The kth largest element in the array
- Vscode tips
- Filter and listener of three web components
- 在 pytorch 中加载和使用图像分类数据集 Fashion-MNIST
- Interface idempotency problem
- MySQL5. 5 installation tutorial
- Ffmpeg common commands
- How to build a line of code with M4 qprotex
猜你喜欢
Common interview questions and detailed analysis of the latest Android developers in 2020
9419页最新一线互联网Android面试题解析大全
web三大组件之Servlet
X509 parsing
[point cloud series] summary of papers related to implicit expression of point cloud
The first lesson is canvas, showing a small case
vscode小技巧
Imx6ull QEMU bare metal tutorial 2: usdhc SD card
Analysis of the latest Android high frequency interview questions in 2020 (BAT TMD JD Xiaomi)
[point cloud series] unsupervised multi task feature learning on point clouds
随机推荐
TERSUS笔记员工信息516-Mysql查询(2个字段的时间段唯一性判断)
Example interview | sun Guanghao: College Club grows and starts a business with me
LeetCode_ DFS_ Medium_ 695. Maximum area of the island
数据仓库—什么是OLAP
这几种 VSCode 扩展是我最喜欢的
Nodejs + Mysql realize simple registration function (small demo)
Isparta is a tool that generates webp, GIF and apng from PNG and supports the transformation of webp, GIF and apng
"Play with Lighthouse" lightweight application server self built DNS resolution server
Solve the problem of Oracle Chinese garbled code
Processbuilder tool class
Nodejs + websocket cycle small case
TCP 复位gongji原理和实战复现
[dynamic programming] 221 Largest Square
CSDN高校俱乐部“名师高校行”——湖南师范大学站
面试官给我挖坑:单台服务器并发TCP连接数到底可以有多少 ?
How do ordinary college students get offers from big factories? Ao Bing teaches you one move to win!
在 pytorch 中加载和使用图像分类数据集 Fashion-MNIST
SAP UI5 应用开发教程之七十二 - SAP UI5 页面路由的动画效果设置
2020年最新字节跳动Android开发者常见面试题及详细解析
Brief introduction of asynchronous encapsulation interface request based on uniapp