glTF Transform can be used to take a .glTF 3D model and to compress textures within that model as KTX2. The tool produces .gltf/.glb files as output, not individual .ktx2 files. Typically KTX-Software or the basisu CLI are used to produce individual KTX2 textures with Basis Universal compression.
What tool are you using to create this .ktx2 texture? Could you post the .ktx2 file? The error suggests that there’s something unsupported contained in the texture itself.
issue in this in my react application i have the error got THREE.KTX2Loader: Unsupported vkFormat i dont know why . please help me to solve this issue.
The problem is likely your KTX2 file, not the code – you’ll have to share the file or the steps you used to create it to get help. If you can’t share those, perhaps install the KTX-Software CLI and run ktx info myfile.ktx2 and share the file metadata.
Validation failed
error-4005: Invalid byteLength in Level Index. byteLength must match the expected value.
Level 11 byteLength is 32 but based on the vkFormat, DFD and image sizes the expected value is 8.
error-4006: Invalid uncompressedByteLength in Level Index. For non-supercompressed files the uncompressedByteLength must match the expected value of byteLength.
...
Header
identifier: «KTX 20»\r\n\x1A\n
vkFormat: VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG
...
Key/Value Data
KTXorientation: rd
KTXwriter: PVRTexLib v5.7.0 (25.1@71b40ed7509d)
KTX2 is a container format that supports ~200 texture formats, many of which are supported only on particular types of GPUs. In this case the texture is in the PVRTC format. THREE.KTX2Loader currently does not support this format, and in any case you would need to be using a device that supports WEBGL_compressed_texture_pvrtc to display it — currently that’s about 23% of devices, mainly Apple products.
If you intend to build something widely supported you should probably be using KTX2 with the Basis Universal formats, ETC1S and UASTC, instead. These KTX2 files can be created using KTX-Software or other libraries.
If you just need to use these exact textures as-is, then I think patches in KTX2Loader to add the missing format (VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG) would be necessary. The validation errors might be a problem as well, but I’m not sure about that.
These PVRTC1-in-KTX2 files will be supported in the next release of three.js, r180:
The validation error is suspicious, and probably indicates a bug in the authoring tool, but doesn’t seem to prevent three.js from loading the file correctly. Note that support in KTX2Loader does not guarantee support on every device, you still need a device/GPU that supports WEBGL_compressed_texture_pvrtc or the texture will not be shown.