Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / Doubt about Dot3 bump map,[ code ] Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
alanchen

April 29, 2005, 02:17 AM

// Calculate and cache the reciprocal value
float fScale2 = 1.0f / ((T.x * B.y * N.z - T.z * B.y * N.x) +
(B.x * N.y * T.z - B.z * N.y * T.x) +
(N.x * T.y * B.z - N.z * T.y * B.x));
//float fScale2 = 1.0f;

//
// Use the temporary T (Tangent), (B) Binormal, and N (Normal) vectors
// to calculate the inverse of the tangent matrix that they represent.
// The inverse of the tangent matrix is what we want since we need that
// to transform the light's vector into tangent-space.
//

//D3DXVECTOR3 vTemp;

(*vTangent).x = D3DXVec3Cross( &vTemp, &B, &N )->x * fScale2;
(*vTangent).y = -(D3DXVec3Cross( &vTemp, &N, &T )->x * fScale2);
(*vTangent).z = D3DXVec3Cross( &vTempT, &B )->x * fScale2;
D3DXVec3Normalize( &(*vTangent), &(*vTangent) );

(*vBiNormal).x = -(D3DXVec3Cross( &vTemp, &B, &N )->y * fScale2);
(*vBiNormal).y = D3DXVec3Cross( &vTemp, &N, &T )->y * fScale2;
(*vBiNormal).z = -(D3DXVec3Cross( &vTemp, &T, &B )->y * fScale2);
D3DXVec3Normalize( &(*vBiNormal), &(*vBiNormal) );

(*vNormal).x = D3DXVec3Cross( &vTemp, &B, &N )->z * fScale2;
(*vNormal).y = -(D3DXVec3Cross( &vTemp, &N, &T )->z * fScale2);
(*vNormal).z = D3DXVec3Cross( &vTemp, &T, &B )->z * fScale2;
D3DXVec3Normalize( &(*vNormal), &(*vNormal) );

Above snip code is from sample:
http://www.codesampler.com/dx9src.htm#dx9_dot3_bump_mapping

T, B, N is the Tangent , BiNoraml, Noraml vectors individual. Then what does this snip code meansӣ
The cross operation liks tranpose(inverse) the tangent-world Matix. Like:
| T | | |
| B | --> | T B N |
| N | | |
then vTangent is the MarixӨs first colӣ vTangent == T!
and vBiNoraml == B, vNormal == N;
then , this snip code do nothing!

Is there anybody who has read the sample code can explain?
Thanks!

 
DavidR

May 05, 2005, 02:05 PM

You're trying to calculate basis vectors for tangent-space so you can transform the light position from world-space to tangent-space. T, B, and N are your basis vectors of your new coordinate system (tangent-space). There are some very good articles you should read:

http://www.blacksmith-studios.dk/projects/downloads/tangent_matrix_derivation.php
http://www.blacksmith-studios.dk/projects/downloads/bumpmapping_using_cg.php

-DavidR-

 
alanchen

May 07, 2005, 09:18 PM

thanks£”

 
This thread contains 3 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.