   Fast way to construct TranslationRotation matrix in shader
  What I'm dealing with right now is a need to construct arbitrary TranslationRotation matrix in a shader during real time. Basically, I have a lot of virtual lights, each of them has a position and direction, these should be used to create virtual light's TranslationRotation matrix.During shading I need to convert position of current fragment into space of one of this virtual lights. I can't prepare TranslationRotation matrices of virtual lights upfront so I'm looking for a way how to do this in shader manually for each fragment.One of the tips I've already found is to build only Rotation matrix and instead of constructing Transaltion matrix just add traslation. So basically operation of moving fragment into virtual light space will be to multiply fragment position with lights Rotation matrix and then simply add lights Translation vector:vec_VPL_frag_pos = mul(vec_frag_world_pos, mat_VPL_Rotation) + vec_VPL_TranslationI do realise that this should be simple, but just not sure how to correctly make rotation matrix from a single directional vector. Any advise?[Edited by - Viik on May 1, 2010 8:31:22 AM]
  If the problem is simply how to build a rotation matrix from a direction vector, then that's fairly straightforward. It's been discussed quite a bit here on the forums, so I'd suggest searching the forum archives for terms such as 'billboard', 'aim at', 'aim at target', 'align with normal', and so on.   