Update to latest Magnum with glTF additions and block Y-flip APIs #2123
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.
Motivation and Context
Another ~two weeks and ~15k lines of changes in Magnum 😅 This PR mainly brings initial support for loading glTFs with Basis-compressed files that aren't pre-Y-flipped, as -- due to unfortunate featurebugs in Basis itself -- that makes them problematic to load in all other software.
This is implemented by Y-flipping the block-compressed data on import. So far this is implemented only for a few formats, more will be gradually added once I figure them out. GPUs that don't support any formats I have Y-flip implemented will fall back to RGBA8.
Compared to other libraries, this means that Magnum is now capable of loading both Y-up and Y-down files (assuming the orientation metadata is correct in the file, which isn't the case for
gltfpack -y_flip
, for example), so both all existing datasets and new datasets generated using the updated tools will load with correct orientation. For consistency, this Y-flip-on-load change is also made for DDS and KTX file format import, so for example FBX files with DDS textures will load correctly as well.I promised to add a possibility for PNG fallback to Basis-compressed files, but decided not to because storing the extra image files would be a hurdle. Instead, the way to import Basis-compressed files to Blender and other tools that don't support the
KHR_texture_basisu
glTF extension, is to first decode them back to PNGs with the following.The output, if modified, can be then encoded back to Basis if needed, although each such roundtrip will result in a slight quality decrease, so it's better to operate directly on the original non-encoded files instead. The format fallback isn't completely out-of-question yet, but I'm postponing it for now as I don't see an immediate need.
Besides the Y-flip, there's the following updates:
JSON
andBIN
chunks in a*.glb
file are padded according to the spec now as well.min
/max
properties are written forPOSITION
attributes as the glTF spec demands. The glTF validator however also demands that those properties are written with an excessively large precision and complains if not. This was reported multiple times upstream but no fix in the validator was made yet.assumeYUp
,assumeYUpZBackward
andassumeOrientation
options in BasisImporter, DdsImporter and KtxImporter plugins to be able to override the orientation information from file metadata (if there's any) for greater control over Y flipping.How Has This Been Tested
📗