当前位置:网站首页>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
边栏推荐
- torch. Where can transfer gradient
- ESP32 VHCI架构传统蓝牙设置scan mode,让设备能被搜索到
- Feature Engineering of interview summary
- 榜样专访 | 孙光浩:高校俱乐部伴我成长并创业
- Stack protector under armcc / GCC
- Is Hongmeng system plagiarism? Or the future? Professional explanation that can be understood after listening in 3 minutes
- ECDSA signature verification principle and C language implementation
- Bottomsheetdialogfragment + viewpager + fragment + recyclerview sliding problem
- Learning notes of AMBA protocol
- [andorid] realize SPI communication between kernel and app through JNI
猜你喜欢
解决Oracle中文乱码的问题
Stack protector under armcc / GCC
./gradlew: Permission denied
十万大学生都已成为猿粉,你还在等什么?
Explanation of input components in Chapter 16
Mui + hbuilder + h5api simulate pop-up payment style
Plato farm, a top-level metauniverse game, has made frequent positive moves recently
QT调用外部程序
Isparta is a tool that generates webp, GIF and apng from PNG and supports the transformation of webp, GIF and apng
在 pytorch 中加载和使用图像分类数据集 Fashion-MNIST
随机推荐
[quick platoon] 215 The kth largest element in the array
LeetCode_DFS_中等_695.岛屿的最大面积
解决Oracle中文乱码的问题
RTOS mainstream assessment
Using open to open a file in JNI returns a - 1 problem
Machine learning -- naive Bayes
【动态规划】221. 最大正方形
[point cloud series] summary of papers related to implicit expression of point cloud
[indicators] precision, recall
The difference between string and character array in C language
Short name of common UI control
Data warehouse - what is OLAP
Unified task distribution scheduling execution framework
2020最新Android大厂高频面试题解析大全(BAT TMD JD 小米)
[point cloud series] neural opportunity point cloud (NOPC)
缘结西安 | CSDN与西安思源学院签约,全面开启IT人才培养新篇章
切线空间(tangent space)
浅谈js正则之test方法bug篇
[point cloud series] deepmapping: unsupervised map estimation from multiple point clouds
Explanation of input components in Chapter 16