Removing bitangent flip from ConstructTBN. Tangent.w should only be used for flipping the bitangent when recomputing the bitangent using the cross product of the normal and tangent, not when reading bitangents directly from vertex data. (#7221)

Signed-off-by: Tommy Walton <waltont@amazon.com>
monroegm-disable-blank-issue-2
Tommy Walton 4 years ago committed by GitHub
parent 74a876ae3b
commit dea89a7539
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,13 +26,12 @@ float3 WorldSpaceToTangent(float3 vectorWS, float3 normalWS, float3 tangentWS, f
return float3(a,b,c);
}
//! Utility function for vertex shaders to transform vertex tangent, bitangent, and normal vectors into world space based on MikkT conventions.
//! Utility function for vertex shaders to transform vertex tangent, bitangent, and normal vectors into world space.
void ConstructTBN(float3 vertexNormal, float4 vertexTangent, float3 vertexBitangent, float4x4 localToWorld, float3x3 localToWorldInverseTranspose, out float3 normalWS, out float3 tangentWS, out float3 bitangentWS)
{
normalWS = normalize(mul(localToWorldInverseTranspose, vertexNormal));
tangentWS = normalize(mul(localToWorld, float4(vertexTangent.xyz, 0)).xyz);
float bitangentSign = -vertexTangent.w;
bitangentWS = normalize(mul(localToWorld, float4(vertexBitangent, 0)).xyz) * bitangentSign;
bitangentWS = normalize(mul(localToWorld, float4(vertexBitangent, 0)).xyz);
}
// ---------- Normal Calculation ----------

Loading…
Cancel
Save