Trimatix / AEPi

Read and write Abyss Engine Image (AEI) files from python, for Galaxy on Fire 2
Apache License 2.0
2 stars 0 forks source link

Support GOF3D Compression Formats #41

Open Trimatix opened 4 months ago

Trimatix commented 4 months ago

@BaalNetbek recently discovered (#40) that, while not used in GOF2, format ID 23 is used in GOF3D for symbian.

AEIEditor seems to internally use the PowerVR SDK for a lot of texture compression. Interestingly enough, 23 is the ID in PVR for ETC2 (BGR), and the textures provided by BaalNetbek in #40 can be decompressed successfully by the existing Tex2Img codec adaptor. Here's a link to the relevant PVR SDK documentation: https://docs.imgtec.com/sdk-documentation/html/framework-libraries/PVRCore/library/file_texture_PixelFormat.h.html

AEIEditor stores a copy of supported PVR format IDs, used when calling the PVR SDK. If we assume that PVR format IDs can be used as AEI format IDs then, reading the AEIEditor format enum, the following formats should be representable in an AEI:

Name AEI Format ID
PVRTC1 4bpp (RGB) 2 (mipmapping not representable)
PVRTC2 2bpp (channels unknown) 4
PVRTC2 4bpp (channels unknown) 5
DXT2 (RGBA) 5
DXT4 (RGBA) 10 (mipmapping not representable)
Shared Exponent RGB9E5 (RGB) 19 (mipmapping not representable)
RGBG 8bpp 20
GRGB 8bpp 21
ETC2 (BGR) 22 (mipmapping not representable)
ETC2 (BGRA) 23 (mipmapping not representable)
ETC2 (BGR + 1 bit alpha) 24
EAC single channel (research needed) 25
EAC dual channel (research needed) 26 (mipmapping not representable)

Some of the above format IDs require the mipmapping flag (2) to be high in order to be represented, so if they really do exist in AEIs, then we'll have to somehow assume that they will either always, or never, be stored with mipmapping.

These PowerVR format IDs may not match what's used in AEI. #40 found that AEI uses ID 23 for format ETC2 RGB, instead of ETC2 BGRA.

The following formats would not be usable in an AEI, because they clash with already known AEI compression format IDs:

Name AEIEditor Unsupported ID
PVRTC1 2bpp (RGB) 0 (clash with Unknown)
UYVY (YUV) 16 (clash with PVRTC1 4bpp (RGBA))
YUY2 (YUV) 17 (clash with ATC)
BlackWhite 1bpp 18 (clash with PVRTC1 4bpp (RGBA) + mipmapping)
BaalNetbek commented 4 months ago

Thank you for the effort unfortunately thoese ID 23 aeis is quiet buggy. I described the issue in #40 but now I realised that you may not recieve notifications for closed issues.