Jump to content
  • Advertisement
Sign in to follow this  

Tangent Space Light Problem

This topic is 4624 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 I have a slight problem with a point light in tangent space. I have a position of light in object space(OGL says eye space but I think it is just based on the active matrix when you create the light?) and a vertex in eye space. I think my problem is getting these two positions into the same space so I can create a vector to be transformed by the tangent matrix.
vec4 lightTrans = gl_ModelViewMatrixInverse*gl_LightSource[1].position;
vec3 lightVec = normalize(lightTrans.xyz - gl_Vertex.xyz );   
tanLightVec.x = dot(Tangent, lightVec);
tanLightVec.y = dot(BiTangent, lightVec);
tanLightVec.z = dot(gl_Normal, lightVec);
tanLightVec =  normalize(tanLightVec);

This almost seems to work except when I rotate the camera up and down the light seems to move with the camera. Anyway here is a video of the problem Light Video. Anyone know how to do this properly? Thanks!

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!