Skip to content
Mark Callow edited this page Apr 2, 2020 · 33 revisions

The KTX File Format and Tools

Important
Under construction. Please ignore. Seems no way to make private until its ready.

KTX (Khronos Texture) is a lightweight file format for OpenGL® and Vulkan® textures. KTX files contain all the parameters needed for texture loading. A single file can contain anything from a simple base-level 2D texture through to a cubemap array texture with mipmaps. Texture payloads can be in Basis Universal or UASTC formats, which can be transcoded to any GPU-supported format, in any of the block-compressed formats supported by OpenGL family and Vulkan APIs and extensions or in an uncompressed format. Basis Universal is a supercompressed block-compressed format. Other formats can be supercompressed with Zstandard (zstd).

Format Specification

The original file format specification was created by Khronos’s OpenGL ES and ARB-OpenGL ES Convergence Working Groups. The Version 2.0 file format specification was created by the 3D Formats Working Group which is also responsible for glTF™️.

Software

The software in this repo includes libktx, a library for reading and writing KTX files, a set of command line tools and .wasm modules for libktx and msc_basis_transcoder, a Basis image transcoder, together with Javascript wrappers for them. See the repo’s README.md for details.

At present there are no downloadable binaries. You will need to build the software for yourself.

Using KTX Files

Creation

toktx, one of the tools in this repo, can be used to create KTX and KTX 2 files using .png or Netpbm files as input. When creating the latter it can encode to Basis Universal or UASTC and can supercompress with zstd. It can create any texture structure: 1D, 2D, 3D, 1D & 2D arrays, cube maps and cube map arrays.

gltfpack can be used to create textures encoded to Basis Universal format within a KTX2 container (-tc flag). Compression is performed using the basisu executable and is thus only available in native builds.

Other software that can be used to create and edit KTX version 1 files and are expected to be updated for version 2 include:

  • The Adreno1 texture tool from Qualcomm, a GUI tool for compression and visualization of textures.

  • Mali Texture Compression Tool2 from ARM, a GUI tool that can create and view files with either compressed or uncompressed textures.

  • PVRTexTool3 from Imagination Technology, a GUI tool that can create and view files with either compressed or uncompressed textures.

  • Compressonator, from AMD’s GPUOpen initiative, is a set of tools to allow artists and developers to more easily create compressed texture assets or model mesh optimizations and easily visualize the quality impact of various compression and rendering technologies. There is a glTF fork of Compressonator which in theory should support KTX 2 sooner but it is not receiving much love at the moment.


1 Included in the Adreno SDK which can be downloaded from the Adreno GPU Tools and Resources page.

2 One of the PowerVR Tools. Download the PowerVR Tools Installer, run it and select the tools you wish to download and install.

Viewing

In addition to the above mentioned GUI tools, PicoPixel can be used for viewing KTX files & more and for debugging image handling in your applications.

Using KTX 2 files in glTF

T.B.C.

Using KTX files natively

See the libktx documentation for complete details of the API and examples of its use. The examples under Usage Overview on the Introduction page provide a concise summary

Reporting Problems

To report problems or suggest new functionality, please use the issues list in the GitHub repository.

Discussion and Questions

Use the KTX forum of the Khronos Group Community Forums for discussion and questions.

Clone this wiki locally