views:

91

answers:

5

I'm trying to find out what a binormal is in the context of graphics programming but coming up short, I saw on a site that the binormal was being calculated as the corss between the normal and tangent (i.e. cross(normal, tangent)), is this the correct way to calculate a binormal?

+2  A: 

According to mathworld, the binormal vector is defined as cross(tangent,normal) where tangent and normal are unit normal vectors.

Note that, strictly speaking, order matters when you take cross products. cross(tangent,normal) points in the opposite direction from cross(normal,tangent). That may or may not matter depending on your application. It really doesn't matter as long as your calculations are internally consistent.

unutbu
+1  A: 

Normal, tangent and binormal vectors form an orthonormal basis to represent tangent space.
Tangent space ( sometimes called texture space ) is used in per-pixel lighting with normal maps to simulate surface detail ( imagine a wall or a golf-ball ).

The tangent and binormal vectors represent the equivalent texture UVs i.e the vectors parallel to the surface normal.

So technically speaking - as they form an orthonormal basis then binormal = cross (tangent,normal ) however in practice, since binormals and tangents are generated from the UVs in the normal map and may be averaged over several vertices then they may not be strictly orthonormal.

For a couple of good articles on the subject read
http://www.3dkingdoms.com/weekly/weekly.php?a=37
and
http://www.blacksmith-studios.dk/projects/downloads/bumpmapping_using_cg.php

zebrabox
+3  A: 

Just to point out that is TOTALLY not the definition of the binormal. Thats the definition of a Bi Tangent. A Binormal is something totally different relating to the "other" normal formed by a curved surface.

People need to learn not to re-iterate that mistake (Made by someone early on in the days of normal mapping).

Goz
Yep good point - however the term 'binormal' has stuck in computer graphics despite it being incorrect
zebrabox
bitangent sounds a lot more logical than by normal given how it's calculated, dunno why everywhere I've read about it it's referred to as a binormal.
meds
It was a mistake made when DX8 normal mapping was first introduced. Its, alas, kind of stuck since then :)
Goz
+1  A: 

Actually, no, sometimes it isn't. In 3d graphics, at least.

If a texture was stretched, then it is possible that binormal will not be perpendicular to both normal and tangent (although it should be perpendicular).

Just use whatever your exporter has calculated. If the exporter provides both tangent and binormal, it is good. If there is only tangent, then calculate binormal as a perpendicular to tangent and normal.

Get a complex object with both tangent and binormal calculated, and compare lighting when you use binormal which was provided with the lighting that you get when binormal was calculated as cross-product. There will be a difference.

Anyway, I believe that a proper way is to get both tangent and binormal calculated in exporter, and just use what exporter has provided.

SigTerm
+1  A: 

Yes the Binormal or Bitangent is the cross between the normal and the tangent of a vertex. If you have any 2 vectors out of these three you can calculate the other one.
For instance if you have a tangent and a binormal (or bitangent) you can calculate the normal.
Here is a sample that can create binormal and bitangents in GLSL having just the normal:

varying vec3 normal;
varying vec4 vpos;
varying vec3 T,B;
void main()
{
    gl_TexCoord[0] = gl_MultiTexCoord0;
    normal = normalize(gl_NormalMatrix*gl_Normal);
    gl_Position =gl_ProjectionMatrix*gl_ModelViewMatrix*gl_Vertex;
    vpos = gl_ProjectionMatrix*gl_ModelViewMatrix*gl_Vertex;
    T = cross(normal,vec3(-1,0,0));
    B = cross(T,normal);
}

While it might not get the desired restults sometimes it should get you where you want.

Sanctus2099