Jump to content
• Advertisement

# spot light bump mapping

This topic is 2567 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

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 this post

##### Share on other sites
Advertisement
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 this post

##### 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.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5
• Advertisement

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633300
• Total Posts
3011266
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!