From dea89a7539b05360c681a16acdc2135df956310c Mon Sep 17 00:00:00 2001 From: Tommy Walton Date: Thu, 3 Feb 2022 11:55:44 -0800 Subject: [PATCH] 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 --- Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/TangentSpace.azsli | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/TangentSpace.azsli b/Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/TangentSpace.azsli index 4ef1f82b11..005499e0ed 100644 --- a/Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/TangentSpace.azsli +++ b/Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/TangentSpace.azsli @@ -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 ----------