Original Post
Hi, can you please tell me, if this would work in theory. A normal mapping shader. I have this input data for the shader: lightVector - in world coordinates; normal - in object space coordinates; tangent - in object space coordinates; bitangent - in object space coordinates; WorldToEyeSpaceMatrix - the modelview matrix that the world is rendered with(this matrix does convert vectors from world to eye space, right?); ObjectToEyeSpaceMatrix - the modelviewmatrix that the current object is rendered with(this matrix does convert vectors from object to eye space, right?); Then i do this: EyeSpacelightVector=multiply(WorldToEyeSpaceMatrix,lightVector); EyeSpacenormal=multiply(ObjectToEyeSpaceMatrix,normal); EyeSpacetangent=multiply(ObjectToEyeSpaceMatrix,tangent); EyeSpacebitangent=multiply(ObjectToEyeSpaceMatrix,bitangent); then create the TBN matrix from the EyeSpacetangent, EyeSpacebitangent, EyeSpacenormal; This TBN matrix should now convert vectors from eye space to tangent space, right? then do: TangentSpacelightVector=multiply(TBNSpaceMatrix,EyeSpacelightVector); and do the lighting calculation with TangentSpacelightVector and the normals from the normal map. The reason I'm asking is, I've written a shader that works like this, but the light direction doesnt work as planned. So now I'm thinking - is there something wrong with the shader, or the input values (the appliaction itself is now wrtitten by me, I rely on some other ppl to send the correct data). Thanks.