I have a problem with TBN matrices due to their transformation in world space.
In .cpp I am trasforming my worldMatrix based on rotation:
worldMatrix = DirectX::XMMatrixMultiply(worldMatrix, DirectX::XMMatrixRotationY(m_Camera->GetRotation().y / 3.14f)); worldMatrix = DirectX::XMMatrixMultiply(worldMatrix, DirectX::XMMatrixRotationX(m_Camera->GetRotation().x / 3.14f));
In .vs I do:
output.normal = mul(input.normal, (float3x3)worldMatrix); output.normal = normalize(output.normal); output.tangent = mul(input.tangent, (float3x3)worldMatrix); output.tangent = normalize(output.tangent); output.binormal = mul(input.binormal, (float3x3)worldMatrix); output.binormal = normalize(output.binormal);
Which results in screen below. Problem occurs due to multiplying my TBN by rotation which badly transforms them and destroys my specular calculation (PBR Forward Renderer). How can I avoid that?
I have already tried splitting worldMatrix to worldMatrix and rotationMatrix but it didn't worked for me.