Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity 5.3beta5 is now compatible with xnormal and several other bakers! (mikktspace standard)

Discussion in '5.3 Beta' started by mortenm, Nov 6, 2015.

  1. mortenm

    mortenm

    Unity Technologies

    Joined:
    Nov 6, 2015
    Posts:
    15
    Integration of mikktspace tangent space generation solution into Unity.

    This makes Unity compatible with a popular baker such as xNormal and
    several other baking tools.

    When there is a mismatch between baker and renderer it often leads to
    undesirable discontinuities in the lit results and distortions. This change now syncronizes Unity with the
    industry standard.

    By default if you import from an fbx file which contains vertex tangents
    Unity imports these from file (same for normals).
    In this case tangents in the inspector is set to "Import". New content
    which does not contain vertex tangents will be set to "Calculate Tanget
    Space" which will use mikktspace. Content brought into your scene prior to
    beta5 will be set to legacy tangent space by default.

    Note that the obj file format does not contain tangent space so if you
    baked in xNormal using obj files and you import the equivalent fbx into Unity you would have
    a mismatch if the fbx contains tangents.

    Please give this a try! If you see any issues then try the following 2
    steps:

    1. Disable texture compression on the normal map.
    2. Try and pre-triangulate the mesh before normal map baking and import
    into Unity.

    These steps are only needed for corner cases (and not specific to Unity).
    The motivation for step 2 is that interpolated vertex attributes,
    such as tangent space, change depending on how the polygons of the mesh are
    triangulated. To visualize what this means one might think of an obvious
    case such as vertex lighting (Gouraud shading). Just like vertex colors are
    interpolated attributes and these are impacted by triangulation the same is
    true for tangent space.

    Also please let us know if the user-interface behaves as you would expect.


    Morten S. Mikkelsen.
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    Great news!

    I'm guessing the implementation will be great since it was made by the author of mikktspace ;)

    Looking forward to doing some tests this weekend.
     
    Last edited: Nov 6, 2015
    Yash987654321 likes this.
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    First off: It works! Yay! Here are the results of my (very original, I know...) test.

    Legacy tangents (boo :'( )
    legacy.jpg

    Mikktspace (woohoo :D )
    Mikktspace.jpg

    Now, there is one small issue (maybe?). There is a slight distortion going on, I'm not sure if it's a problem, but I never noticed it when I used handplane (it's very possible that I never looked that closely before though)
    distortion.jpg

    The workflow I used it -> Bake object space normal map to 16bit png -> Export object with all normals smoothed -> Run xNormal and convert to tangent space.
     
    spryx likes this.
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    I answered my own question:

    It looks exactly the same in Substance
    designer.jpg

    So it's either a general precision issue (I'm guessing some sort of slight mismatch in the way the normals are interpolated on the actual model vs how the pixels are on the texture?), or there's something wrong with my workflow.

    In any case the Unity implementation is great.
     
    Last edited: Nov 8, 2015
  5. mortenm

    mortenm

    Unity Technologies

    Joined:
    Nov 6, 2015
    Posts:
    15
    Thank you very much for your test and feedback :)

    Yeah what you're seeing is definitely the limits to 8 bit precision in normal maps.
    Fixing it requires either 16 bit uncompressed or 16 bit source compressed as bc5. I am sure we will add bc5 compression to unity in the future though not for 5.3 of course. Thank you for your confirmation on mikktspace! :)

    Cheers,

    Morten S. Mikkelsen.
     
    MarcClintDion and Lex4art like this.
  6. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Are derivative maps coming to the standard shader in the future?
     
  7. mortenm

    mortenm

    Unity Technologies

    Joined:
    Nov 6, 2015
    Posts:
    15
    It's a possibility but not something we have discussed at this point.

    It's very possible though we may decide to treat all bump contributions as derivatives internally in the shader
    going forward since it allows for correct mixing of an arbitrary set of bump contributions.
     
    MarcClintDion likes this.
  8. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    Aw damn ... I currently really can't keep up with the Betas for my personal projects. MikktSpace seems really awesome. Even without trying it myself yet: Cool thing, Unity! Love you guys. :)
     
  9. minhdaubu2

    minhdaubu2

    Joined:
    Jun 10, 2014
    Posts:
    76
    You should use .tif format if you bake with XNormals