microsoft / DirectX-Graphics-Samples

This repo contains the DirectX Graphics samples that demonstrate how to build graphics intensive applications on Windows.
MIT License
5.89k stars 2k forks source link

Why a tangent vector multiplied by WorldIT matrix? #818

Closed RTSBoomIsComing closed 1 year ago

RTSBoomIsComing commented 1 year ago

https://github.com/microsoft/DirectX-Graphics-Samples/blob/a79e01c4c39e6d40f4b078688ff95814d166d34f/MiniEngine/Model/Shaders/DefaultVS.hlsl#L118

I know that a normal vector would be multiplied by the worldIT matrix, but a tangent vector would be multiplied by the world matrix.

Is it also okay to multiply it with the worldIT matrix?

stanard commented 1 year ago

It is correct to multiply the entire tangent frame by the inverse transpose of the world matrix. This includes normal, tangent, and bitangent. In the event that the world matrix is orthogonal, the result will be the same using World instead of WorldIT. The world matrix is usually orthogonal, but skew or (more likely) scale could be involved.