Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: TBN vectors

  1. #1
    Intern Contributor
    Join Date
    Mar 2001
    Location
    Duplje, Slovenija
    Posts
    76

    TBN vectors

    How do you create TBN matrix polysoup. I know that T and B vectors follow s and t coordinats but I realy dont know how to calculate them. I've searched some forums and google but I only found info how to calculate T and B for simple objects like cubes and spheres. Any (pseudo)code would be very usefull.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    France
    Posts
    768

    Re: TBN vectors

    If you have a procedural model (a sphere, a torus...) then the TNB triplet is pretty obvious. That's why you've found so many info on them over the Internet.

    If you're looking for the TNB triplet for bump-mapping, then all you can select whatever Tangent and Binormal you like once you have the Normal.

    Details
    Compute a (first) vector - the Tangent - orthogonal to the Normal. You can use the equation : dot_product(T,N)=0
    There is an infinite number of vectors that solves the quation. Choose whichever you like.

    Then compute a (second) vector - the Binormal - orthogonal to the Normal and orthogonal to the Tangent. Given a Normal and a Tangent, there is a unique Binormal vector. It can be computed as the cross product between the Normal and the Tangent : B=cross_product(N,T)

    Additional Information
    Even though there exists an infinite number of triplets TNB (for a given Normal), I recommend you to select a Tangent that has some kind of organization. If words like "up/down", "left/right" or "cw/ccw' (not for backface culling this time!) has some meaning to your model, then it's better to use them.
    For instance, you may want to have all your tangents facing "upwards", or "in clockwise direction relatively to the vertical axis".

    Hope this helps, and I hope I'm clear !

  3. #3
    Intern Contributor
    Join Date
    Mar 2001
    Location
    Duplje, Slovenija
    Posts
    76

    Re: TBN vectors

    Thanks. That's what I'm doing now. But when I read nVidias papers on this they said T and B must follow texture mapping coordinats but I dind't know how to calculate them. The problem with this aproach is that scene looks diferent if I change T (and B). Does anyone else has opinion on this?

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    France
    Posts
    768

    Re: TBN vectors

    I'm sorry but I can't figure why your scene looks different.
    Also, does it look *really* different, or just a bit ?

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    France
    Posts
    768

    Re: TBN vectors

    Maybe you should post in another forum. You won't get much answers in the OpenGL.org beginners forum. Perhaps try the advanced forum ?

  6. #6
    Intern Contributor
    Join Date
    Mar 2001
    Location
    Duplje, Slovenija
    Posts
    76

    Re: TBN vectors

    I think I got this sloved. It look OK except in some cases with animated meshes... If I can't get this bug out then I'll try asking in the advanced forum...

Posting Permissions

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