Skip to main content
Participant
November 4, 2024
Question

Convert world space normals to tangent space with Pixel Processor node

  • November 4, 2024
  • 1 reply
  • 4840 views

I heard mention on a video that this was possible, but unsure where to start. Wondering if someone has some ideas?

1 reply

Community Expert
November 4, 2024

Hello converting World Normals to Tangent Normals is absolutely possible using a Pixelprocessor, although it involves a little linear algebra and the use of matrices, which are not part of the function set in Substance 3D Designer.

These have to be build from scratch, which can be a little tricky.

 

I have some of the needed functions lying around and I should be able to create you a Node, which does this, today or tomorrow.

 

If you want to give it a try by yourself, here is a step by step explanation of the workflow:

 

  • Calculate the Tangent and Bitangent from the UV-Coordinates and the Position-Map, this can be done, by sampling the neighbors of the current position and construct the tangent and bitangent vectors, from these positions. The Tangent Vector is retrieved from the vector in x-Direction, the Bitangent is retrieved in y-Direction.

 

  • Construct the TBN-Matrix from the Tangent-, Bitangent- and WorldNormal-Vectors. This step involves a little creativity, because there is no 3x3 Matrix Data-Type in SD so use 3 Float3 for this (I usually use them as matrix columns, because then they are the same as the 3 Vectors)

 

  • Now you have to calculate the Inverse of the TBN-Matrix, which is the hardest part and involves a deeper understanding how matrices work and how to calculate the inverse of a matrix (I have such a function lying around for 4x4 matrices, as soon as I'm home from work I can change it, so it fits your needs, but that may take a little)

 

  • The last step is to Transform the World Normals to Tangent Normals by multiplying the World Normals with the Inverse of the TBN Matrix. 

 

I hope this helps and if you have one or two days, I would be very happy to create such a node for you.

 

Stay healthy and creative Marco 

Participant
November 4, 2024

Legendary, thanks for the response!
Will definitely give this a go, but if you have the space for it, if you could create a node I would be absolutely over the moon.

davescm
Community Expert
Community Expert
November 4, 2024

You could also try the World Space Direction baker, using your existing World Space Normal texture as a direction file.

 

Dave