Jump to content
  • Advertisement
Sign in to follow this  
lomateron

normals in tangent space question

This topic is 1956 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

when blender makes the normals in tangent space it has to use 3 direction vectors, one is the normal of a face, the other is vector "b" and the other is the cross between this two vectors.

What is vector "b"?

Edited by lomateron

Share this post


Link to post
Share on other sites
Advertisement

you don't make normals in tangent space, you just make normals. The tangent, bi-normal, and normal, make up the TBN 3x3 rotation matrix which is used to transform light rays into the coordinate system of your texture. The tangent & bi-normal therefore represent the u & v directions of your texture (which you can deduce by inspecting the texture coordinates). 

Share this post


Link to post
Share on other sites

"you don't make normals in tangent space, you just make normals"

blender produces normals in tangent space, no?

 

"u & v"

What is that?

 

Apart from that:

 

when blender makes the normals in tangent space it has to use 3 direction vectors, one is the normal of a face, the other is vector "b" and the other is the cross between this two vectors.

What is vector "b"?

Edited by lomateron

Share this post


Link to post
Share on other sites

"b" is the bitangent. It describes, loosely, the "orientation" of the object about the normal vector, and generally is derived from the u-v coordinates, as the bitangent is used for texture mapping and anisotropic shading.

 

In tangent space, the normal is equal to (0, 1, 0) or (0, 0, 1) depending on what your up-axis is, by definition.

Share this post


Link to post
Share on other sites

"derived from the u-v coordinates"

how exactly is the bitangent direction derived?

 

The u-v coordinates basically map a vertex (in 3D space) to a 2D texture coordinate, right? The u-coordinate corresponds to the horizontal texture coordinate and the v-coordinate corresponds to the vertical coordinate (in fact, u-v are typically called "texcoords"). So now you can work out the tangent and bitangent vectors by taking the difference in texcoords between neighbouring vertices (interpolated to give per-face TBN matrices, of course).

 

EDIT: Eric above gives the complete derivation - ninja'ed? :p

Edited by Bacterius

Share this post


Link to post
Share on other sites

when blender makes the normals in tangent space it has to use 3 direction vectors, one is the normal of a face, the other is vector "b" and the other is the cross between this two vectors.

What is vector "b"?

"b" refers to the binormal.

 

In tangent space calculations you have the Normal, Tangent, and Binormal.  These 3 normalized vectors represent the basis vectors of the tangent space, which BTW is not necessarily an orthogonal space.  These vectors are in object space, and the 3x3 matrix generated from them represents the transformation from object space to "tangent" space.

 

The normal is the vector pointing directly away from the surface.  This is calculated from the vertex positions and has nothing to do with the UV coordinates.  The tangent vector points along the direction of change of the U coordinates.  The binormal points along the direction of change of the V coordinates.

 

if the UV coordinates are orthogonal, then you can calculate the binormal like this:

 

B = T x N

 

Sometimes in games, inside the shaders, the binormals are calculated this way.  But, again, this only works if the U and V coordinates are orthogonal, which they're not guaranteed to be.  It's very easy for artists to make the texture coordinates flow however they want.  The general solution is to pass in all three, N, T, and B in the vertex to the vertex shader.

Edited by 0r0d

Share this post


Link to post
Share on other sites

I can't understand

 

What I thought when I just hear about tangent space normals was this:

 

normal:::> is just the simple normal of the face

binormal":::> is the direction<<if i have 3 vertices positions(in world space) for a face>>:  normalize(vertice2 - vertice1)

tangent:::>cross(normal, binormal)or the other way cross(binormal, normal)...i don't know

 

wouldn't this be much simpler?

 

so with this 3 vectors I just build a 3x3matrix multiply it by the normal of the texture and finally get the normals in world space

//-----------------------------------------------------------------------------------

this is my new question

 

I want to tranform this tangent normals of the texture to world space

I have three vectors in world space that  represent a face of the object i am drawing

I just need a 3x3 matrix to rotate this tangent normals of the texture

the last vector of the matrix is the normal of the face: normalize(cross(v1-v0,v2-v0))

the middle vector will be what?

the first vector will be: cross(last vector,middle vector)

Edited by lomateron

Share this post


Link to post
Share on other sites

What I thought when I just hear about tangent space normals was this:
 
normal:::> is just the simple normal of the face
binormal":::> is the direction<>:  normalize(vertice2 - vertice1)
tangent:::>cross(normal, binormal)or the other way cross(binormal, normal)...i don't know
 
wouldn't this be much simpler?

 

But this vector doesn't have any use. The point of bitangents is to create a TBN matrix (tangent bitangent normal) which is used for normal mapping, bump mapping, etc.. because the normal isn't enough. We also need to know the "rotation" of the texture at the given vertex/pixel to map it properly. This is why we need a bitangent coming from the texture coordinates. The direction of the vertex doesn't have any relation to that, it's for all intents and purposes random (and may not be coherent from vertex to vertex).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!