Search Unity

Why mesh tangents/normals are broken?

Discussion in 'High Definition Render Pipeline' started by Passeridae, Mar 26, 2021.

  1. Passeridae

    Passeridae

    Joined:
    Jun 16, 2019
    Posts:
    395
    So here's a mesh:
    upload_2021-3-26_17-57-20.png

    Here's the same mesh with a normal map (I've chosen one of the most contrast normal maps I have in the project, but the same goes for every normal map. For some it's less visible, for others - more):

    upload_2021-3-26_18-0-32.png

    As you can see, some parts of the mesh are brighter and some are darker. It works this way with the basic HDRP Lit Shader and any shader created in Shader Graph. If I use Shader Graph and rotate the textures there by 180 degrees I'll get this result:

    upload_2021-3-26_18-4-38.png
    |

    So, the bright and dark areas are inverted. Note, that I apply a correction for normal map rotation from this thread. It helps to keep the normal map itself from inverting, but the general problem of light and dark areas of the model isn't affected. If I rotate the model the appearance also changes.

    The model is made in 3Ds Max and exported as an FBX file. I've checked normals in 3Ds Max, applied ResetXForm, tried different export options related to geometry, tried different import options in the inspector in Unity and haven't found anything that both eliminates this issue and yields the correct normal appearance.

    The problem isn't related to Unity specifically, some other renders show the same artefacts but to a lesser degree. Some don't. For example, 3Ds Max renders it correctly (Corona render) but shows similar issues if the gamma-correction isn't applied to the normal map (you're supposed to apply it in this renderer) and shows the inverted result not with a rotated texture but with a flipped red channel of the normal map. But then again, if the normal map is processed as it should (gamma-correction applied) it renders it perfectly. Other models in the project show similar issues, so it's not just one mysteriously broken mesh.

    What might be the issue?

    Thanks!
     
    Last edited: Mar 26, 2021