Archived

This topic is now archived and is closed to further replies.

Tangent Space Matrix

This topic is 5750 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all, im currently implimenting Dot3 Bump mapping in the graphics side of my engine and am having problems generating the tangent matrix,could anyone possibly point out what is wrong with the following code
  

function TangentMatrix16(T: PTexCoords2f ;N: PVector3f): TMatrix16f;
var
  t3d,b: TVector3f;
begin
  Result := NullMatrix16;
  //generate and normalize t vector from 2d texture coords

  t3d := Vector3f(T[0],T[1],0);
  Normalize(t3d);

  //generate bi normal

  CrossProd(@n,@t3d,b);
  Normalize(b);

  //populate matrix

  Result[0] := t3d[0]; Result[1] := t3d[1]; Result[2] := t3d[2];
  Result[4] := b[0]; Result[5] := b[1]; Result[6] := b[2];
  Result[8] := n[0]; Result[9] := n[1]; Result[10] := n[2];

  Result[15] := 1;
end;

  
Many thanks Mark

Share this post


Link to post
Share on other sites
Wow, I haven''t seen Pascal code in ages! That brings back some (haunting) memories! Next thing you know, someone will post some Fortran!

Timkin

Share this post


Link to post
Share on other sites