Introduction
KTX is a container for textures, made by the Khronos Group, the body behind OpenGL and Vulkan. A texture is stored in the form the graphics card uses, often already block-compressed, so it can be loaded without decoding. One file can hold all the mipmap levels, the six faces of a cube map and arrays of layers.
There are two versions, with different identifiers and different headers, so each has
its own page here. KTX 1 (.ktx) describes the data with OpenGL constants.
KTX 2 (.ktx2) uses Vulkan formats, a data format descriptor and optional
supercompression with BasisLZ, Zstandard or zlib. KTX 2 with Basis Universal is the
texture format of the glTF extension KHR_texture_basisu.
Variations
| Format | Variation | About | Open |
|---|---|---|---|
.KTX | Khronos Texture 1 | OpenGL textures with mipmaps, described by OpenGL type and format constants. | Open |
.KTX2 | Khronos Texture 2 | Vulkan and glTF textures with a data format descriptor and supercompression. | Open |
KTX 1
The first version, for OpenGL and OpenGL ES. A 64-byte header names the OpenGL type, format and internal format of the texture, followed by key and value pairs and then the mipmap levels from largest to smallest, each with its size in front. An endianness field lets a file be written in either byte order.
The file starts with AB 4B 54 58 20 31 31 BB 0D 0A 1A 0A («KTX 11»).
KTX 2
The second version, for Vulkan and the web. The header names a Vulkan format, an index gives the position of every section and every mipmap level, a Khronos data format descriptor says exactly how texels are laid out, and levels may be supercompressed. It is always little-endian, and the levels are stored smallest first.
The file starts with AB 4B 54 58 20 32 30 BB 0D 0A 1A 0A («KTX 20»).
Not described
Each version lists its own gaps: KTX 1 and KTX 2 (see their “Not described” sections). In both, the viewer is not yet built and the file opens as raw bytes only.
Links
Software
- KTX-Software tools – Khronos command-line tools that create, check and convert KTX files (Windows, macOS, Linux)
- PVRTexTool – Imagination Technologies’ texture compression and viewing tool (Windows, macOS, Linux)
- Compressonator – AMD’s texture compression tool (Windows, Linux)
Developers
- libktx – Khronos library that reads and writes KTX 1 and KTX 2 (C)
- Basis Universal – encoder and transcoder for supercompressed KTX 2 (C++)
Reference
- KTX – the Khronos page with both specifications