Sign in to follow this  
AndyPandyV2

Tangent Space Light Problem

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this