View Full Version : How to compute binormal( bitangent ) vector?
07-10-2007, 12:18 AM
How to compute binormal vector for bump mapping calculations?
07-10-2007, 12:46 AM
07-10-2007, 02:41 AM
What's the idea behind the code? Note that I don't like to buy the book "Mathematics for 3D Game Programming & Computer Graphics" to only read one section;-)
07-10-2007, 03:17 AM
Basic idea is that given a mesh that has position, normal and a texcood, you can calculate the tangent/bi-tangent by getting the rate of change of the texture coordinates over the mesh surface.
If you want more details, look up the GDC slides from 2003/2004 era.
07-10-2007, 06:11 AM
The idea is to use the derivative of texture coordinates across triangle vertices to calculate the derivative of the cardinal texture axes in 3D.
In that example sdir and tdir are the tangent & binormal.
The stuff at the end ensures the tangent and normal axes are orthognal and it looks like binormal is the implicit cross product (a common approximation) since tdir isn't corrected the way sdir is. There's no 'right' way to handle bad content here, this is just tidying things up, normalize is the most important operation in the second part of the code.
The final part is flipping w based on the axis orientation (basically adding support for mirrored coordinates but it needs support in the vertex shader to use this correctly).
This example shows definite signs of being lifted from somewhere without proper cleanup, especially the way tdir is handled.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.