KTX2(Basis) files and normal maps

I know that this compression tool is still pretty new, but I’m hoping that someone can help figure out some issues I’m seeing when using Basis files. According to the Basis Universal README:

For tangent space normal maps, you should separate X into RGB and Y into Alpha, and provide the compressor with 32-bit/pixel input images. Or use the "-separate_rg_to_color_alpha" command line option which does this for you. The internal texture format that Basis Universal uses (ETC1S) doesn't handle tangent space normal maps encoded into RGB well. You need to separate the channels and recover Z in the pixel shader using z=sqrt(1-x^2-y^2).

Using their alternative encoding params, Babylon fails to load the files. Using the standard settings, this is translating in Babylon to one side of the model looking correct, while the other side looks “inverted”

Are there any examples of KTX2 and Babylon working together using normal maps? And if so, can someone share how they compressed the files and loaded the results?

pinging @bghgary

2-channel normal maps are not supported right now. We have plans to investigate this, but it’s been slow going so far.

Thanks, Gary! Do you think it’s too premature to use this in production?

Yes, certainly. I don’t recommend using any of this yet.

Good to know. FWIW, the file size improvements are very promising and the Basis transcoder is really fast. By my tests, you could cut texture file sizes down by about 80%.

Yes, it works really well for color textures. Non-color textures not so much. The upcoming UASTC encoding will make this much better for non-color textures but they will be bigger.

1 Like