# Tangent Space Light Problem

## Recommended Posts

AndyPandyV2    298
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!