Unity-Technologies / usd-unity-sdk

Integration of Pixar's Universal Scene Description into Unity. UPDATE: This package has been superseded by our new bundle of USD packages. Please see README & link below for further details.
https://forum.unity.com/threads/new-openusd-packages-now-available.1524583/
Apache License 2.0
499 stars 77 forks source link

Exported USD and USDZ have corrupted normals along UV seams (FTV-1110) #192

Open hybridherbst opened 4 years ago

hybridherbst commented 4 years ago

I've been trying to find the root cause for this myself but haven't been successful in doing so. UV seams in meshes cause visible seams along normals in USD and USDZ files exported with usd-unity.

It's clear that vertices need to be split in places where UV seams are but the resulting normals should be identical, resulting in smooth shading independent of UV seams.

My assumption so far is that it has something to do with normal interpolation behaviour; Blender sets that explicitly to "faceVarying" while Unity leaves it as default.

Reproduction cases: https://glitch.com/edit/#!/usd-normals-bug (you can directly download the usdz files from the "assets" section in Glitch)

Reproduction from Unity: NormalsBugs.unitypackage.zip

Import these, export as USD or USDZ. Import them in Blender or anything else that can export USDZ and try again.

Note that re-importing the corrupt files in Unity looks correct, so some logic seems to be wrong in both import and export.

Ground truth in Unity (these are smoothed cubes; the left one has 3x3 quads per face, the others 1x1. The left one has a deliberately shitty UV layout to show the issues better. UV layout should not affect shading at all if no textures are used.) image

Exported from Unity: IMG_0149

Same file, exported from Blender: IMG_0153

For simple shapes, it's the same, visible edges along all UV seams: image

For complex shapes, also, but much less visible since there's more going on - this is where I originally found the issue - note the vertial line along the center: IMG_0154

Reimporting them with usd-unity looks correct, which I believe points to different defaults being in the spec and used by Unity for some interpolation: image

jcowles commented 4 years ago

After some investigation, it appears: