How to use KTX2 / BASIS compressed normals

If I use KTX2 normal maps compressed with the separate_rg_to_color_alpha option, is there an additional step necessary to load them correctly?

Ping @bghgary and @Evgeni_Popov :slight_smile:

Nope. It will just work. If you are compressing non-color maps, it’s probably best to use UASTC for the compression. It’s bigger, but it will have much less artifacts.


Thanks @bghgary! Unfortunately, UASTC isn’t really an option for what we’re trying to do. It looks great, but the output files are too big.

1 Like

Just a quick follow-up on this. I took a look at the Khronos examples page and they are using KTX2 files for their demo. I notice they are not compressing their normal maps but instead are using JPG for those files, but KTX2 for everything else. Have you guys been able to get one of the usual GLTF models like the damaged helmet to work with just KTX2, and if so, can you share how that was done?

Pinging @bghgary

1 Like

Sorry for the slow response. It’s been a busy couple of days.

I would not use the Khronos Sample Viewer as a reference for how to do things right now. It is currently being reworked including the KTX part, so stay tuned.

If you look at the medium post for the 4.2 release, there is a PG with the FlightHelmet using KTX.

Right now, the easiest way to get a glTF asset to be compressed with KTX for its textures is to use glTF-Transform which is what I did for the aforementioned playground.

I did this to get the FlightHelmet glTF compressed:

> gltf-transform etc1s FlightHelmet.gltf output1\FlightHelmet.gltf --slots "baseColorTexture" -v
> gltf-transform uastc output1\FlightHelmet.gltf output2\FlightHelmet.gltf --zstd 22 --slots "!baseColorTexture" -v

The Khronos 3D formats working group (of which I’m a member) is working on better documentation and tooling for KTX.

If you look at the medium post for the 4.2 release, there is a PG with the FlightHelmet using KTX.

For some reason that PG is throwing an error. We have gotten the normal maps working using toktx, so now we just need to try some different settings to optimize our output. We’ll update this post when we’ve got it dialed in. :slight_smile:

What kind of error? It would be good to know if there is an issue here.

Hmm, that’s odd. Can you open an incognito/in-private browser window to make sure it’s not a caching issue? Also, make sure you have the playground set to the 4.2 or the latest version.

Yep, that fixed it. Thanks!

1 Like

hey @bghgary , the above commands were super helpful, my model went from 25 mb to 7mb by using it. I wanted to ask couple of things if you could enlighten me:

  1. I encountered few warnings for POT like: “warn: Texture dimensions 512x367 are NPOT, and may fail in older APIs (including WebGL 1.0) on certain devices.” , I presume it is necessary to correct those for better performance , right?

  2. I have created some standard /custom material texture in babylonjs, which are not embedded in GLB model , how would I go about to compress them? (I couldn’t find a command for this on glTF-Trsnform)

  3. in above commands you are only using baseColorTexture, should I also process on other texture types? here is a small pic from inspect after running above command:

  4. what are these parameters for? --zstd 22 --slots and which other parameters are available? couldn’t find in docs.

  5. are there some other helpful commands to process my model from glTF-Transform? I see that draco and weld would be helpful. here are what I am using now

    gltf-transform weld scene.glb scene1.glb
    gltf-transform draco scene1.glb scene2.glb
    gltf-transform etc1s scene2.glb scene3.glb --slots “baseColorTexture” -v
    gltf-transform uastc scene3.glb scene4.glb --zstd 22 --slots “!baseColorTexture” -v



I’m not sure. Maybe ask on the GitHub? Issues · donmccurdy/glTF-Transform (

The commands I sent will compress all the textures. Only the color texture uses ETC1S where as everything else uses UASTC.

--zstd specifies the zstd compression level. --slots indicate which texture slots to apply the command to. I’m not sure. I got this information from Don :slight_smile:

Seems like you got all of them.

1 Like

Thanks @bghgary , I figured that we could use toktx for external images compression, with toktx --t2 --bcmp image_out.ktx2 image_in.png, I found one of your answer where you mentioned to use .ktx2 instead of .basis , any particular reason for that? I guess it contains more then 1 textures type inside?

.ktx2 is backed by the Khronos Group. .basis is not backed by any standards committee.

1 Like