Fix tangent problem for model with multiple uv

Recently I encountered a wierd normal shading issue, as shown in image. Turn out it caused by incorrect tangent. Normally, tangent is automatically calculated from vertex UV. However, with multiple uv sets, it’s possible to have very different UV layout. Any rotation or flipping will make the original tangent incorrect for current UV set. If one happened to apply normal map in this UV (using tangent to world transformation), the issue arise.

To solve this, we need some additional information to identify the modifed tangent direction. Vertex color seems to be the most convinient one. So, I made a houdini file to calculate tagent space and encode the corrected tangent into one vertex channel. Then it can be unpacked in shader.

Leave a Reply

Your email address will not be published. Required fields are marked *