Unable to render normal map correctly with -separate_rg_to_color_alpha using ktx2

Hi all,

I created 2 ktx2 normal maps from the same png file.
One of them is using the -separate_rg_to_color_alpha and the other isn’t:
./basisu -ktx2 -normal_map -mipmap -mip_smallest 4 -separate_rg_to_color_alpha desk.png
./basisu -ktx2 -normal_map -mipmap -mip_smallest 4 desk.png

However, when I am loading the GLTF, they look very different for the texture and I don’t think the one with separate_rg_to_color_alpha is loading correctly:

I included the GLTFs (png, with and without separate_rg_to_color_alpha ktx2) above and want to understand if I am doing anything wrong with the one using separate_rg_to_color_alpha or I need do so something different to load it correctly.

The basisu doc mentions this:

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)

Is this something I need to do manually?

For context, I need to reuse existing assets which are already using the flag separate_rg_to_color_alpha so any help is appreciated!

Thanks!

cc @bghgary if he has any idea ?

This isn’t supported in the glTF extension. You cannot use an RG normal map with glTF using ETC1S. You have to use UASTC.

KTX header fields for ETC1S with BasisLZ payloads

  • supercompressionScheme MUST be 1 (BasisLZ).
  • DFD colorModel MUST be KHR_DF_MODEL_ETC1S .
  • RGB textures MUST use a single KHR_DF_CHANNEL_ETC1S_RGB DFD channel.
  • RGBA textures MUST use two DFD channels: KHR_DF_CHANNEL_ETC1S_RGB and KHR_DF_CHANNEL_ETC1S_AAA .
  • Red textures MUST use a single KHR_DF_CHANNEL_ETC1S_RRR DFD channel.
  • Red-Green textures MUST use two DFD channels: KHR_DF_CHANNEL_ETC1S_RRR and KHR_DF_CHANNEL_ETC1S_GGG .
1 Like

Thanks @bghgary!

This isn’t supported in the glTF extension . You cannot use an RG normal map with glTF using ETC1S. You have to use UASTC.

For me to understand it better, is it the RG normal map (separate_rg_to_color_alpha) = ETC1S mode?
Or UASTC can use the separate_rg_to_color_alpha flag?

Sorry, what I said is not quite right. RG normal maps are not supported by glTF right now. You can’t use that flag to create KTX2 normal textures and use it in glTF, regardless of ETC1S or UASTC.