Packing data into UV channels in Tangent space #113
-
Blender Version: 2.93 LTS I'm trying to pass vertex data from a different mesh into the shader to use in displacement calculation, but I also want the general shape to be deformable by bones. In order to do this, I figured the easiest way would be to convert this data into tangent space, then convert it back to world space in the shader. In python:
In shader:
Video showing expected result, followed by actual result, then with precomputed tangents (why did the normals flip?): 2021-08-13.16-53-00_edit.mp4I tried looking into how Malt computes tangents and found this in Common.glsl:
I know that Tangents are calculated using the UV Map in Blender, so I figured I just need to calculate them the same way as Malt to fix the issue, like so:
This didn't give me the right result either. It got worse, in fact. Well, even if the computation is different, using precomputed tangents should work in theory but, it doesn't. Might have something to do with calc_tangents() flipping the normals for some reason. Any ideas on what I'm doing wrong here? I feel like I'm making it way more complicated than it needs to be. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Long story short:
|
Beta Was this translation helpful? Give feedback.
Long story short:
If you want to use tangents, always use pre-computed tangents. The current calculation when there are no pre-computed tangents is a pretty bad workaround and will be replaced soon.
In Blender and Malt matrix multiplication is right to left: