• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
lomateron

normals in tangent space question

16 posts in this topic

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
0

Share this post


Link to post
Share on other sites

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). 

0

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
0

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.

2

Share this post


Link to post
Share on other sites

"derived from the u-v coordinates"

how exactly is the bitangent direction derived?

1

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
1

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
0

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
0

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).

1

Share this post


Link to post
Share on other sites

this is my new question

 

I want to tranform the 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 will need a 3x3 matrix to rotate this tangent normals

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

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

the middle vector of the matrix will be what?

0

Share this post


Link to post
Share on other sites

the middle vector of the matrix will be what?

 

The bitangent smile.png but that matrix is incorrect either way.

 

The "normal" way (no pun intended) to generate this matrix is to know the face or vertex normal in advance from the model (though you can calculate it from the vertices if you want) as well as the bitangent, and compute the missing vector by crossing the two and possibly flipping the sign of the resulting vector depending on your coordinate system. And, no, you can't make both vectors up, if you need the correct TBN matrix (not just the normal) then you need to obtain the bitangent somehow and that is from the model's u-v coordinates or other equivalent source as linked above.

 

As your matrix is now it has zero information about the actual texture of the object, so it can't possibly be a texture space to world space matrix. You see the problem?

Edited by Bacterius
1

Share this post


Link to post
Share on other sites

I think the problem is that you are failing to realize that there are infinitely many possible TBN matrices for any given face. They are all the same except they are slightly rotated around the normal. And they will produce different results when you try to use them. So which one to use? The idea is to already know two of the vectors of the matrix (normal and bitangent) and the bitangent tells you exactly which matrix you want. But to be meaningful, this bitangent needs to be defined with respect to the texture coordinates, to correctly align the matrix of each face to the orientation of the texture covering said face. On the other hand, the locations of the vertices of the object are independent of how the object's texture is mapped, so using them won't produce good results at all.

2

Share this post


Link to post
Share on other sites

ok i thought it was simple tranformation, I will try now to undestand again what is inside the link the man gave me

 

I thought i just needed different rotational matrix for every face of an object but the same rotational matrix for every texel normal of a face

Edited by lomateron
0

Share this post


Link to post
Share on other sites

I think the problem is that you are failing to realize that there are infinitely many possible TBN matrices for any given face. 

This not correct.  For one thing the TBN matrix exists for each vertex, not for each face.  Also, the Tangent is defined to point in the direction of change of the U coordinate, and the binormal (or bitangent as some here are calling it) points in the direction of the V coordinate.

-2

Share this post


Link to post
Share on other sites

this is my new question

 

I want to tranform the 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 will need a 3x3 matrix to rotate this tangent normals

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

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

the middle vector of the matrix will be what?

 

The tangent-space matrix is not guaranteed to be orthonormal, so you cant get the basis vectors like this by crossing them to get the last one.  Also, they will transform the tangent-space normals into object-space, not world-space.  

-1

Share this post


Link to post
Share on other sites

There is some very good discussion here, and I appreciate all of the contributions. There are a couple of points that I think are worth restating, or clarifying, so that people might understand more deeply.

 

With regard to which aspect of geometry the TBN is associated, the TBN exists for any point on the surface, not only at each face, and also not only at each vertex. It may be computed at each vertex, or each pixel, or once per face for that matter, depending on how it is to be used (vertex or fragment shader or just asset calculations on the CPU) or what is convenient, but strictly speaking it exists continuously across the surface.

 

With regard to the tangent direction, it is not in general true that it is defined to point in the direction of change of the u coordinate. A tangent vector can be any vector that is located in the tangent plane at a point on the surface (the tangent plane being the plane that is orthogonal to the local surface normal at that point, er, for a surface that is continuously differentiable). So, as Bacterius noted, it is true that there are infinitely many possible tangent space choices at any point on the surface.

 

It happens that computing the tangent along the curve of the u direction is quite convenient, and, since it aligns with texture coordinates, this choice fits very nicely with computer rendering use cases. Also, on a mesh, standardizing on this choice enables continuity of the tangent spaces across the entire mesh surface.


As for the bitangent (which is a more appropriate term than binormal, when dealing with surfaces), it is in fact just like the tangent in that it lies in the tangent plane. It is a tangent vector, just a different one than the T in TBN. In computer graphics the bitangent is often computed along the v direction, again in order to align with texture coordinate directions and provide for TBN continuity, but there is that issue of the u and v directions being nonorthogonal in model/world space (vs. tangent space), as discussed in prior posts. The terathon page linked above discusses this orthogonality issue with a workable solution, concisely.

 

I know many resources out there explicitly define the tangent to be computed along the u direction and bitangent to be computed along the v direction, but to understand deeply you should recognize that these choices are made merely to achieve the alignment with the texture directions with the happy bonus of TBN continuity. I hope this reply helps someone understand more deeply, if only a little.

 

Graham

2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0