Proposal: add an ability to Y-flip images during transcode #79
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.
While the encoder-provided option to flip the image during encoding is everything needed when one controls the whole pipeline, it's of no use for general image viewers that have no power over how the input was generated. Having the chance to configure Y flipping during the transcode makes it easier to integrate, as the application doesn't need to worry about patching texture coordinates or doing texture coordinate transform in a shader.
While flipping the compressed image post-transcode is possible, it's a non-trivial amount of work, considering the broad range of target formats supported. On the other hand, when done directly in Basis, flipping can be done on the internal ETC1S representation:
Assuming the encoder's output is reasonably invariant to image flip, this new code path could be tested by comparing these two outputs for equality:
This was tested on ETC1/2, BC1-7, ASTC and RGBA8 output, however it currently doesn't handle flipping for PVRTC textures, as there's cross-block modulation and I don't have deep enough understanding of the format to be able to code that. Similarly for FXT1 due to a different block size. Treat the code more like a proof-of-concept (and feel free to do anything with it, of course).
At first I thought about just opening a feature request, but then went on to try how feasible this would be, to avoid asking for the impossible :) It's of course entirely possible that I missed some important aspect of the format and it can't work this way -- however if it can, I dare to say the code changes needed won't be so invasive and the additional maintenance/testing effort for this feature is in reasonable bounds.