Generate smooth normals when normals are missing #133
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously we did not always generate normals when they were missing. Presumably Unity was generating normals for us in that case but potentially gets confused with the model transform we give our tiles. In particular, Unity and glTF have opposite handedness - while the conversion between the two is still possible in the form of a matrix, Unity only provides us the ability to individually set translation, rotation, and scale. The only workaround then, was to invert the change-of-handedness matrix to make it a valid rotation matrix, and use a negative scale so the handedness would be corrected in the final matrix.
Unfortunately, it seems like Unity may have been using the rotation without the scale when auto-generating normals for our tiles (after all one would think scale shouldn't affect rotation!). After this change, we always generate smooth normals in Cesium Native when normals are missing - so it is no longer an option on the tileset.