Jump to content
  • Advertisement
Sign in to follow this  
rampster

spot light bump mapping

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


Link to 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


Link to 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


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!