unity3d-jp / MeshSync

A package for synchronizing meshes/models editing in DCC tools into Unity in real time.
Other
1.55k stars 174 forks source link

[For 0.17.x] fix: NaN in tangents and bitangents when vertices are too close to each other. #870

Closed seandillon92 closed 1 year ago

seandillon92 commented 1 year ago

Currently, the tangent calculation can produce NaN results when vertices are too close to each other. This causes rendering issues in Unity 2021 with HDRP.

NaNIssue

The root cause seems to be that we normalize a zero length vector when calculating an angle between vertices. We then multiply the NaN result to a zero tangent vector. Since the intention is to return a zero tangent and bitangent when the area between vertices is to small, I do that more directly and return early. Results of the fix NaNIssueFix