View Full Version : How to compute binormal( bitangent ) vector?
07-09-2007, 11:18 PM
How to compute binormal vector for bump mapping calculations?
07-09-2007, 11:46 PM
07-10-2007, 01: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, 02: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, 05: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.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.