-
Notifications
You must be signed in to change notification settings - Fork 100
Flip textures and UVs #611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…UV coordinates to comply with Unity U-right, V-up convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @david-lively! I'm still building this locally to test it out, but figured I'd post my comments now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes @david-lively ! Just a few small things that I won't trouble you with; I'll batch into a commit so CI can start running.
…n.rowPitch for the row stride when flipping textures.
Description
This PR modifies the texture and model import process to comply with Unity's U-right, V-up convention.
The glTF 2.0 spec mandates that textures are anchored at UV (0,0) and the upper-left corner of the texture, with UVs increasing to the right and down. (See https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#images .)
Unity, however, assumes that UV (0,0) corresponds to the bottom-left corner of the image. Previously, the system did not flip either the textures OR the UVs, so it mostly worked, but has caused issues with tangent generation.
In the UV overlay debug images below, the six columns on the left were loaded by Cesium, while the six on the right were loaded by Unity glTFast. These were generated using the same glTF model:
This requires changes to
cesium-native
in CesiumGS/cesium-native#1259 .Before this change:

After this change:

With textures flipped:

Author checklist
CHANGES.md
with a short summary of my change (for user-facing changes).Testing plan
Load a tileset. Use Unity's Render Debugger to visualize the

Texcoord0
vertex attribute. Observe that UV coordinates increase in the right- and up-direction, and that textures are correctly flipped to match.