• Create Account

## confused about tangent/bi-tangent in 'normal' mapping...

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

1 reply to this topic

### #1timothyjlaird  Members

598
Like
0Likes
Like

Posted 08 March 2014 - 10:06 PM

I'm trying to get a normal map working in WebGL. I'm still struggling with linear algebra and graphics theory so I've been experimenting and reading through tutorials to try to get it right. Basically I've got a sphere and a directional light. Unfortunately it obviously does not quite work if you go here and click the button it switches on the normal map which isn't quite right...

Shortly after putting this together I realized that I need to apply a matrix made up of normal, tangent and bi-tangent vectors to my calculations in order to fix it. I found these articles and they seem to contradict one another...

http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-13-normal-mapping/#Normal_textures

http://voxelent.com/html/beginners-guide/1727_10/ch10_NormalMap.html

The first says I need to calculate both tangent and bi-tangent attributes BEFORE I send them to the vertex shader. The second says it's OK to compute the bi-tangent vector based on a cross product of the normal and tangent vectors.

The guy in this stackoverflow article also says that I need to calculate both and pass them to the vertex shader...

http://stackoverflow.com/questions/5255806/how-to-calculate-tangent-and-binormal

So who is right?

### #2Lodeman  Members

1551
Like
2Likes
Like

Posted 09 March 2014 - 01:43 AM

The TBN matrix consists of an orthonormal basis between the the tangent, bi-tangent and the normal.
You COULD pass in all three to the shader, however it's unnecesarry as you can calculate the bi-tangent as the cross-product from the tangent and normal (orthonormal basis is really the clue here). Therefore it is enough to send in normal and tangent to the shader, and let the shader calculate the bi-tangent.

So in conclusion, both are right.

Here's the reference I used when implementing normal maps: http://ogldev.atspace.co.uk/www/tutorial26/tutorial26.html

Edited by Lodeman, 09 March 2014 - 01:45 AM.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.