(08-18-2017, 12:23 PM)aboood40091 Wrote: It's always flipped for me:
Lastly, I want to report that your swizzle algorithm works with XTX files, the Switch's equivalent of the Wii U's GTX, as well! Good job!
Yea, tgas are loaded upside-down because by default, TGA images are stored upside down (so first line is bottom, and last line is top). A bit on the TGA header controls this, when the bit is 1, the image is read normally (top to bottom), when its 0 it is read from bottom to top. The ARM ASTC tool seems to always write 0 to this bit, so its always loaded upside down. This value is located at position 0x11 on the TGA file, and the bit that controls this is the bit 5, so you can change the value from 0x00 to 0x20 to make it load properly.
To fix that you can change the line with "hdr.descriptor = 0;" in astc_stb_tga.cpp to "hdr.descriptor = TGA_DESCRIPTOR_YFLIP;".
Also just for completness, I found 2 other tools that can decode astc textures:
https://github.com/philiptaylor/oastc
https://github.com/GammaUNC/FasTC/blob/m...ressor.cpp
It's probably worth noting that they only support decoding, while the reference tool supports both encoding and decoding.
Also nice to know that it works with xtx (althrough this was expected since swizzling is a GPU access optimization, so all textures needs to use it, or not since I belive that linear addressing is also supported somehow). I don't know any game that uses this format tho, just out of curiosity which game uses it?