Error when loading .ktx2 files with automipmap flag

Babylon.js throws an error when loading my .kxt2 files that i created using the toktx.exe and the --automipmap flag:

Failed to load KTX2 texture data: TypeError: e.mipmaps[0] is undefined

Afaik the difference is that --automipmap texture asks the loader to create mipmaps whereas the --genmipmap texture already includes the mipmaps. Here is a playground with a .kxt2 file created with --automipmap and one .ktx2 file created with --genmimap.

The ktx2 khronos documentation says:
–automipmap Causes the KTX file to be marked to request generation of a mipmap pyramid when the file is loaded.

Additionally: When dropping .jpg in the babylon sandbox mipmaps are created. When dropping .ktx2 files it does not happen.

So does anybody know what’s up with the --automipmap feature? We’d really like to try this option.

Best, Mamu

automipmap is not supported for ktx2 files, generation of mipmaps should be done beforehands. Dropping a .jpg in the sandbox does generate the mipmaps because it is done automatically by the WebGL layer, it is not done by Babylon. But this does not work for compressed textures.

automipmap would be a pain to implement because we would need to decompress the ktx2 file, generate the mipmaps and then recompress the data, for all compressed formats supported by ktx2… Not likely to happen anytime soon :slight_smile:

1 Like