vector T = normalize(v@tangentu); vector B = normalize(v@tangentv) ; vector N = normalize(@N); matrix m = set(@T, @B, @N); @Cd = m * @Cd; @Cd = @Cd * {-0.5,0.5,0.5} + 0.5; //unity is leftHand
float3 bitangent = cross(normalize(v.normal) , normalize(v.tangent.xyz)) * v.tangent.w; float3x3 TtoO = float3x3(v.tangent.x, bitangent.x, v.normal.x, v.tangent.y, bitangent.y, v.normal.y, v.tangent.z, bitangent.z, v.normal.z); float3 normalOS = v.color.xyz; normalOS = normalOS * 2 -1; normalOS = mul(TtoO, normalOS) ;
@Cd = @N; @Cd = @Cd * 0.5 + 0.5; @Cd = normalize(@Cd); @N = @Cd;
In RenderDoc:
When we wrote the same values to the normals and vertices, but in Unity, the vector order was different and the values had some deviations, including decimal points.
Can someone who has access to the Unity source code check what calculations Unity performs when importing FBX files, and how to construct the TBN inverse matrix in Houdini to restore the tangent space vectors written in Houdini?