BinomialLLC / basis_universal

Basis Universal GPU Texture Codec
Apache License 2.0
2.71k stars 266 forks source link

Y-flip feature on transcoding for both UASTC and ETC1S #135

Open nontan-rh opened 4 years ago

nontan-rh commented 4 years ago

I know there's a pull request which is for ETC1S. This is very useful to integrate the Basis transcoder into Unity where the image is imported upside down.

I also know UASTC is very good at the image quality and really want to use UASTC with Unity.

Do you have a plan to implement the feature for UASTC? It must be appreciated by many developers.

P.S.

I tried to implement the Y-flip feature for UASTC by myself. Below are my attempts to find the flipped Partition Patterns of ASTC.

Then I found that it's hard to flip a texture losslessly because of lacking flipped partition patterns.

I also want to know if there's a lossy converter, the converter can be merged into the upstream? (or are you already developing it?)

mosra commented 4 years ago

Oh, great :)

@richgel999 it would be great to have some feedback on this and #79 -- is this something you'd be willing to have integrated at some point? Or is this completely out of scope / interest and apps should be patching texture coordinates or doing texture coordinate transform in a shader instead? Thanks in advance.

richgel999 commented 4 years ago

Hmm - I don't think it's possible to 100% losslessly flip a UASTC texture, unless we add a mode to the encoder to limit which partition patterns get used. This will lower quality, but not much.

Would this interest you? I like this idea, and want to support it.

mosra commented 4 years ago

Interesting, I thought all ASTC partition patterns were invariant to flip/mirror, like (IIRC) under the BC formats. Perhaps a bit tangential -- does that mean an image can potentially get better quality encoding if it's flipped / mirrored before? (Encoding four different orientations and picking one that has the smallest encoding error, for example?)

I'm peronally still interested in this, even with the tradeoffs.

MarkCallow commented 4 years ago

Unity where the image is imported upside down.

This is like asking "how long is a piece of string?" Upside down compared to what? To give you a starting point the file format needs to identify the logical orientation of the image, something lacking in .basis. It has a YFlipped flag in the header but all that tells you is that a flip was performed when the image was encoded. It tells you precisely nothing about the actual image orientation.

richgel999 commented 3 years ago

Y flipping during transcode is on our radar, at least for ETC1S. But several other things (like faster UASTC encoding, and better sRGB support for UASTC) are higher priority at the moment.