在TBN矩阵都是正常的,切线,和二重向量总是垂直?都是、切线、向量、矩阵

2023-09-08 10:32:52 作者:执著到心碎

这是关系到另外一个问题所描述的问题(照片有):

This is related to a problem described in another question (images there):

Opengl着色器的问题 - 奇怪的光反射文物

我有一个.OBJ进口商,创建一个数据结构,并计算切线和bitangents。这里是我的对象,第一个三角形的数据:

I have a .obj importer that creates a data structure and calculates the tangents and bitangents. Here is the data for the first triangle in my object:

我的切空间的理解是,该正常点向外从顶点,切线垂直(正交α)在阳性S的纹理方向上的法向矢量和分,而二重垂直于两者。我不知道你所说的,但我认为这3个向量形成什么看起来像一个旋转或转化的X,Y,Z轴。他们不会是3的任意的导向载体,对吧?

My understanding of tangent space is that the normal points outward from the vertex, the tangent is perpendicular (orthogonal?) to the normal vector and points in the direction of positive S in the texture, and the bitangent is perpendicular to both. I'm not sure what you call it but I thought that these 3 vectors formed what would look like a rotated or transformed x,y,z axis. They wouldn't be 3 randomly oriented vectors, right?

另外我的理解:在一个正常的地图法线提供了一个新的法向量。但在切线空间纹理贴图没有内置定向的RGB之间的连接codeD正常,每个顶点正常。所以你用TBN矩阵来缩小差距,并让他们在同一个空间(或让光线在正确的空间)。

Also my understanding: The normals in a normal map provide a new normal vector. But in tangent space texture maps there is no built in orientation between the rgb encoded normal and the per vertex normal. So you use a TBN matrix to bridge the gap and get them in the same space (or get the lighting in the right space).

但后来我看到的对象数据...我的结构具有270顶点,他们都有一个0的切线Y.那是正确的切线数据?难道这些切线像一个顶点正常的空间还是什么?还是他们只是看起来完全错了吗?还是我困惑的是如何工作的,我的数据是正确的?

But then I saw the object data... My structure has 270 vertices and all of them have a 0 for the Tangent Y. Is that correct for tangent data? Are these tangents in like a vertex normal space or something? Or do they just look completely wrong? Or am I confused about how this works and my data is right?

要更接近解决我的问题,我需要确保其他的问题我的数据是正确的,我的理解是如何切空间照​​明的数学工程。

To get closer to solving my problem in the other question I need to make sure my data is right and my understanding on how tangent space lighting math works.

推荐答案

在纹理的S和T分量方向的切线和二重向量的坐标点(U和V不使用的OpenGL方面的人)。因此,沿S中的切向量点和二重点一带吨。

The tangent and bitangent vectors point in the direction of the S and T components of the texture coordinate (U and V for people not used to OpenGL terms). So the tangent vector points along S and the bitangent points along T.

所以,是的,这不的有无的正交无论是正常的或对方的。它们遵循纹理映射的方向。事实上,这是他们的宗旨:让您从模型空间转换到法线纹理的空间。它们定义从模型空间映射到纹理的空间

So yes, these do not have to be orthogonal to either the normal or each other. They follow the direction of the texture mapping. Indeed, that's their purpose: to allow you to transform normals from model space into the texture's space. They define a mapping from model space into the space of the texture.

切线和二重只会彼此正交,如果S和T的组件在该顶点是正交的。也就是说,如果该纹理映射不具有的切向。虽然大部分的纹理映射算法将尝试最小化的切向,它们不能消除它。所以,如果你想要一个准确的矩阵,你需要一个非正交的切线和二重。

The tangent and bitangent will only be orthogonal to each other if the S and T components at that vertex are orthogonal. That is, if the texture mapping has no sheering. And while most texture mapping algorithms will try to minimize sheering, they can't eliminate it. So if you want an accurate matrix, you need a non-orthogonal tangent and bitangent.