1. ## Regarding Tangent space

Hello Everyone,

I am reading about Normal mapping from OpenGL 4.0 Shading Language Cookbook. I could understand about the concept of tangent space. But I'm not able to understand how exactly the matrix is created for transforming vectors to the tangent space.

The matrix is generated like this:

Code :
```#version 400
layout (location = 0) in vec3 VertexPosition;
layout (location = 1) in vec3 VertexNormal;

layout (location = 2) in vec2 VertexTexCoord;
layout (location = 3) in vec4 VertexTangent;

// .. Other uniforms

void main(void)
{
// Transform normal and tangent to eye space
vec3 norm = normalize(NormalMatrix * VertexNormal);
vec3 tang = normalize(NormalMatrix * vec3(VertexTangent));

// Compute the binormal
vec3 binormal = normalize(cross( norm, tang ))
* VertexTangent.w;

mat3 toObjectLocal = mat3(
tang.x, binormal.x, norm.x,
tang.y, binormal.y, norm.y,
tang.z, binormal.z, norm.z
);

// .. continues
}```

2. ## Re: Regarding Tangent space

Tangent, Bitangent (binormal is IMHO a terrible misnomer since this vector is tangential to the surface not orthogonal to it) and normal are the three basis vectors of tangent space. The matrix is simply a change of base from tangent space to object space (the space in which normal, tangent, bitangent are expressed).
Therefore its rows are the basis vectors of the source space (here: tangent space) expressed as vectors in the destination space (here: object space).

PS: I hope I didn't mix up rows/columns in the above, but you get the idea

3. ## Re: Regarding Tangent space

Bitangent (binormal is IMHO a terrible misnomer since this vector is tangential to the surface not orthogonal to it)
Not in this case.

The "Bi" in binormal refers to the tangent and normal vectors. It is "normal" to the "Bi": tangent and normals.

The problem with the term "binormal" is that it assumes that the binormal is normal: orthogonal to the tangent and normals. It isn't. In the above case it is, but that's because the people who wrote the code were lazy and didn't properly create a tangent space basis. A proper basis can have the tangent and bitangent not be orthogonal to one another.

"Bitangent" is a surface property, which may be orthogonal to the tangent and normal but does not have to be. "Binormal" is a geometric property which is, by definition, orthogonal to them.

So they refer to two different things. And since he's constructing the binormal orthogonally, it is correct to call it "binormal".

4. ## Re: Regarding Tangent space

Thanks Alfonse Reinheart, Carsten Neumann.

@Carsten Neumann:

>> The matrix is simply a change of base from tangent space to object space

Well now i'm confused. Isn't it from eye space to tangent space?

5. ## Re: Regarding Tangent space

Originally Posted by Alfonse Reinheart
Originally Posted by carsten neumann
Bitangent (binormal is IMHO a terrible misnomer since this vector is tangential to the surface not orthogonal to it)
And since he's constructing the binormal orthogonally, it is correct to call it "binormal".
Another take on this:

Originally Posted by [url="http://www.terathon.com/code/tangent.html"
Computing Tangent Space Basis Vectors for an Arbitrary Mesh[/url] (Eric Lengyel)]Bitangent versus Binormal

The term binormal is commonly used as the name of the second tangent direction (that is perpendicular to the surface normal and u-aligned tangent direction). This is a misnomer. The term binormal pops up in the study of curves and completes what is known as a Frenet frame about a particular point on a curve. Curves have a single tangent direction and two orthogonal normal directions, hence the terms normal and binormal. When discussing a coordinate frame at a point on a surface, there is one normal direction and two tangent directions, which should be called the tangent and bitangent.
Eric's explanation makes more sense to me.

6. ## Re: Regarding Tangent space

Well now i'm confused. Isn't it from eye space to tangent space?
Ah, your code uses the vectors after applying the normal matrix, so yes it is between the eye and tangent spaces.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•