KTX2 compressed textures come out "Darker" than the originals

Hi, I have 2 glbs here, one is a ktxcompressed version. tldr i used the following script to create the compressed version:

gltf-transform etc1s hotel-3R9pgjEI.glb hotel-3R9pgjEI-ktx.glb

when placed side by side I notice the compressed version is dark to the point of looking texturless but i realized if I zoom in I can actually see the texture clearly. Anyone have an idea of what is causing this? I saw this happen with another gltf but that file is bigger and not really my work so I would have to ask permission before posting it here but here is the comparison I am referring to:

Notice how the texture on the left is darker on the lower image. To reiterate, I can see the texture if I get real close to the object so It definitely not missing or anything.

I’m not a pro at ktx2 compression and my end goal is to improve performance on mobile for a project I have been working on so please feel free to recommend better ways to compress this that will make it more effective. Ideally I want the two file to act exactly the same.

attached below you will find the two files in questions

PS: this is the same issue when compressing using etc1s and uastc.

hotel-3R9pgjEI.glb (325.5 KB)
hotel-3R9pgjEI-ktx.glb (358.2 KB)

I don’t totally understand what’s happening here, but I can tell you it has something to do with mipmaps. Devices that don’t support WebGL 2 will require your texture dimensions to be in powers of two. And, apparently, this issue is fixed on devices that do support WebGL 2 if you resize the textures to powers of two. glTF Transform has a flag to do that for you:

gltf-transform etc1s hotel-3R9pgjEI.glb hotel-3R9pgjEI-ktx.glb --power-of-two

The tell here is how the distance or viewing angle changes the result — WebGL changes between mipmaps at different distances and angles.

Feel free to file a bug about it anyway, I’m curious what’s actually going on here. :slight_smile:

1 Like

Yup works perfectly after that change. I just learned something new :slight_smile: . Also I’ll file an issue about it soon. Thanks for the help