# spot light bump mapping

This topic is 2633 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi!
I am trying to implement a spot light shader with bumpmapping and I am having problems getting the right output!
I have the necessary spot light pixel shader inputs (vertex to light direction and spot direction) in view space and would like to convert them to tangent space.
But I have only been able to find this version that converts world space to tangent space.

 // Create a transform to convert a world space vector to tangent space. mat3 tangentSpaceTransformMatrix = mat3(tangentVector, binormalVector, normalVector); 
my question here is : does the following matrix convert vertors from view space to tangent space?

 // Transform the normal, tangent and binormals to view space. mat3 inverseTransposeWorldViewMatrix = mat3(u_inverseTransposeWorldViewMatrix); vec3 tangentVector = inverseTransposeWorldViewMatrix * a_tangent; vec3 normalVector = inverseTransposeWorldViewMatrix * a_normal; vec3 binormalVector = inverseTransposeWorldViewMatrix * a_binormal; // Create a transform to convert a vector to tangent space. mat3 tangentSpaceTransformMatrix = mat3(tangentVector, binormalVector, normalVector); 

I am under an impression it does.. But please correct me if I am wrong!

Thanks!
mrp

##### Share on other sites
You could give the spotlight position and direction to the vertex shader in object-space and then it is only a matter of transforming them with the norma, tangent and bitangent matrix in order to have them in tangentspace.

##### Share on other sites

Hi!
I am trying to implement a spot light shader with bumpmapping and I am having problems getting the right output!
I have the necessary spot light pixel shader inputs (vertex to light direction and spot direction) in view space and would like to convert them to tangent space.
But I have only been able to find this version that converts world space to tangent space.

 // Create a transform to convert a world space vector to tangent space. mat3 tangentSpaceTransformMatrix = mat3(tangentVector, binormalVector, normalVector); 
my question here is : does the following matrix convert vertors from view space to tangent space?

You have a view matrix that goes from world space to view space, and that means its inverse goes from view space to world space. The TBN transformation goes from world space to tangent space. Thus, you would need to form the composite of the inverse view and the TBN matrices to go from view space to tangent space. Since the TBN and the inverse view are both invertible, the composite is also invertible and this makes it a linear isomorphism of vector spaces. Thus, the composition will work. i.e. apply the inverse view first, then the TBN.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634092
• Total Posts
3015447
×