Skip to content

KTX1 / ETC2 Compressed textures support#7070

Merged
BMagnu merged 16 commits into
scp-fs2open:masterfrom
Shivansps:ktx-etc2
May 26, 2026
Merged

KTX1 / ETC2 Compressed textures support#7070
BMagnu merged 16 commits into
scp-fs2open:masterfrom
Shivansps:ktx-etc2

Conversation

@Shivansps

@Shivansps Shivansps commented Sep 30, 2025

Copy link
Copy Markdown
Contributor

This work was split from the android branch. Since KTX/ETC2 has nothing to do with the OS or graphic API.
Supports KTX texture container and -only- ETC2 type without adding a dependency, i took the work done for DDS as an example and worked from there, it contain some small parts of code copied from ddsutils.

Keep in mind this is KTX1, not KTX2, KTX2 is a completely different format. AMD Compressonator and Google Etc2Comp tools are compatible with KTX1 format.

I created a script that is sami-competent at transcoding texture files from DDS to KTX.
https://www.hard-light.net/forums/index.php?topic=99767.0

And here are some mods already converted to ETC2 for testing
https://1drv.ms/u/c/b365427d3c02ed18/ERQGTUZlKqZMuRbBlP-5e1EBsIiYQ99kx-DUCf_3ypCOPg?e=NL5lmU
https://1drv.ms/u/c/b365427d3c02ed18/EaE0G4NEOTpLpI8wlji9f5QBSc3zKmiWLm-9pbm5om76kw?e=Sn99pm
https://1drv.ms/u/c/b365427d3c02ed18/EW2CsDfY3BtIq9WxZTAqZ_4BcUB-cCwRhkaTRtFFcbLwTg?e=ZiuhLt

To use ETC2 on desktop hardware, a GPU supporting OpenGL 4.3 is needed, without that it will fail to display the textures. Keep in mind desktop GPU drivers are not optimised for it, results will be likely slower. On mobile i got Icarus running on 4GB + 4GB swap (with 50% smaller textures)...

KTX/ETC2:
-Initial support for basic 2D textures, no cubemaps
-Support KTX 1 file type with 3 basic ETC2 formats and their signed version: ETC2_RGB, ETC2_RGBA_EAC, ETC2_RGBA1.
-KTX1/ETC2 export support in AMD compressonator
-The DDS->KTX porting plan is something like this:
DXT1 with no alpha -> ETC2_RGB
DXT1 with alpha -> ETC2_RGBA1
DXT3/DXT5/BC7 -> ETC2_RGBA_EAC
Normals maps -> ETC2_RGBA_EAC, it has more jagged edges than the ones in DDS for some reason, but i cant do anything about it.

Note: i had to change the bitmap flag type from ushort to uint since all 8 bits were already in use. Thats why i had to change so many unreleated functions.

Additionally, one thing i was not sure about the bitmap flags. As show in the changed for bmpman.h

I also added 3 new types
#define BMP_TEX_ETC2_RGB8 (1 << 9) //!< ETC2 RGB compressed (24bit, no alpha)
#define BMP_TEX_ETC2_RGBA1 (1 << 10) //!< ETC2 RGBA1 compressed (24bit, 1 alpha)
#define BMP_TEX_ETC2_RGBA8 (1 << 11) //!< ETC2 RGBA8 compressed (32bit, 8 alpha)

But there are actually 6 new texture types
BM_TYPE_ETC2_RGB, //!< 24 bit, no alpha
BM_TYPE_ETC2_SRGB, //!< 24 bit, no alpha, signed
BM_TYPE_ETC2_RGBA1, //!< 24 bit, 1 bit alpha
BM_TYPE_ETC2_SRGBA1, //!< 24 bit, 1 bit alpha, signed
BM_TYPE_ETC2_RGBA_EAC, //!< 32 bit, 8 bit alpha
BM_TYPE_ETC2_SRGBA_EAC //!< 32 bit, 8 bit alpha, signed

I only added 3 because their signed and non signed version shares all their properties, it just the GPU that will handle them diferently. This way i would not sure 6 of the new 8 avail texture flags. I could easily change it to 6 if this decision is wrong.

Comment thread code/ktxutils/ktxutils.h Outdated
@BMagnu BMagnu merged commit fe18b47 into scp-fs2open:master May 26, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants