Orthonormal basis
Anyone know how to construct an orthonormal basis for use in Dot product bumpmapping?
I know the vertex normal vector and if I could figure out how to calculate the tangent vector I could calculate the binormal (N x T) and these would form the orthonormal basis.
Thanks,
Jason A.
---
I write code.
DelphiGL (http://delphigl.cfxweb.net)
---I write code.DelphiGL (http://delphigl.cfxweb.net)
The way I do it is to find the direction that the texture is mapped onto a polygon which gives you the second vector.
You could calculate the other two as simply any perpendicular to the normal but this would give you problems with real world models where polys are not mapped consistently.
The following is the code used per polygon for an indexed mesh. Its part of an inner loop - the resultant basis vectors are averaged for the basis for all vertices in that poly (same way as averaging vertex normals):
edge1[] and edge2[] are float[4] arrays.
d_du, tx, ty and tz are 3 component vectors.
--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com
You could calculate the other two as simply any perpendicular to the normal but this would give you problems with real world models where polys are not mapped consistently.
The following is the code used per polygon for an indexed mesh. Its part of an inner loop - the resultant basis vectors are averaged for the basis for all vertices in that poly (same way as averaging vertex normals):
|
edge1[] and edge2[] are float[4] arrays.
d_du, tx, ty and tz are 3 component vectors.
--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement