Jump to content
  • Advertisement
Sign in to follow this  

Fast way to construct TranslationRotation matrix in shader

This topic is 2941 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

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_Translation I 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]

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!