Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

Blender - Cycles bake tangent basis

Discussion in 'Formats & External Tools' started by Ng0ns, Apr 9, 2020.

  1. Ng0ns

    Ng0ns

    Joined:
    Jun 21, 2016
    Posts:
    123
    So, the other day I was trying the bevel node in Blender to make hardsurface models without subdividing them - a technique commonly used in Modo as well.

    It requires cycles, so I did a quick model + bake and threw it into Unity, only to stumble on my old friend ... normal calculation not matching up between engines.

    Bake looks fine in Blender, but shading (easy to see on specular surfaces) will be wonky in Unity.
    I remember using a external tool in to past which accounted for the differences and exported correct maps, though its name alludes me.

    It can be "partially" solved by splitting uv's more, as there will be less warping within the normal map to display incorrectly... but thats not exactly fixing the problem, more avoiding it.

    Any Ideas? :)

    I know Farfarer made a XNormal plugin for it long ago.

    https://farfarer.com/blog/2012/06/12/unity3d-tangent-basis-plugin-xnormal/
     

    Attached Files:

  2. Ng0ns

    Ng0ns

    Joined:
    Jun 21, 2016
    Posts:
    123
    Quick note - It seems HDRP (havent tested Universal, but assume the same) doesn't have this issue, only regular renderer.

    Edit - Universal doesn't seem in sync either.
     
    Last edited: Apr 10, 2020
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    3,109
    I'm assuming you are baking normal maps in that case? It sounds like you are already knowledgeable about graphics, so you've probably already thought of this, but have you tried messing with the mesh import settings? Specifically, Unity calculates tangents itself by default rather than importing them from the .fbx. You can change this, though.

    Also I don't know what "normals mode" does exactly (I think it's new), but the default setting may affect imported mesh normals in some way.
     
  4. Ng0ns

    Ng0ns

    Joined:
    Jun 21, 2016
    Posts:
    123
    Hey Kdgalla =)

    Yes, model is set to import both normals and tangents.

    Exporting the normals with the fbx seems to work fine, as does including tangent and binormals (easy to see when omitting them from blender export and asking Unity to used imported).

    Its an issue that has resulted in grey hairs in the past. MikktSpace has become more common, but each engine tend calculate/use the tangent basis a bit different from each other. As a result, unless this is taken into account while baking or afterwards (using conversion tools) the maps won't be in sync and you start getting shading artifacts.

    It seems the stars align with the HDRP engine, but neither default nor Universal.
     
unityunity