Advertisement

Linear solution for a translation

Started by November 23, 2002 06:08 AM
0 comments, last by Drath 22 years, 2 months ago
In the vertex shader I need a cost efficient formula to transform a vector so it is relative to a light direction vector. The light direction vector points in the direction of the light and also has an up and right vector as well. I know how I could to it through trig but it is too expensive. The original vector would be relative to Forward(0,0,1), Up(0,1,0), Right(1,0,0).
It''s not very clear what you mean. It''s usual to do lighting calculations using global axes/a global frame of reference. This means all other coordinates need to be transformed into the global frame of reference to be used in lighting calcuations. E.g. if your object has a rotation matrix associated with it use that to transform the object''s normals for lighting. You only need the rotation (3x3) part of the matrix: disregard any translation component.

Matrices are generally better than quaternions for this as the vertex shader can do matrix transforms very quickly. Avoid angles as they are far slower.
John BlackburneProgrammer, The Pitbull Syndicate

This topic is closed to new replies.

Advertisement