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

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.

4 Likes

Great news!

I’m guessing the implementation will be great since it was made by the author of mikktspace :wink:

Looking forward to doing some tests this weekend.

1 Like

First off: It works! Yay! Here are the results of my (very original, I know…) test.

Legacy tangents (boo :cry: )
2372959--161270--legacy.jpg

Mikktspace (woohoo :smile: )
2372959--161271--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)
2372959--161272--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.

1 Like

I answered my own question:

It looks exactly the same in Substance

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.

Thank you very much for your test and feedback :slight_smile:

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! :slight_smile:

Cheers,

Morten S. Mikkelsen.

2 Likes

Are derivative maps coming to the standard shader in the future?

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.

1 Like

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. :slight_smile:

You should use .tif format if you bake with XNormals