Skip to content
Mark Callow edited this page Apr 27, 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 format is both block-compressed and supercompressed. 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. Xcode projects, Visual Studio solutions and CMake files for linux and web builds are available (all generated from GYP masters). See the repo’s BUILDING.md for complete instructions.

Using KTX Files

Creation

toktx, one of the tools in this repo, can be used to create KTX and KTX 2 files using .jpg, Netpbm or .png files as input. When creating the latter it can encode to Basis Universal or UASTC (under development) and can supercompress with zstd (under development). 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

There are also tools that focus on viewing. These include:

  • PicoPixel which can be used for viewing KTX files & more and for debugging image handling in your applications. Windows only.

  • Image Viewer and Tonemapper which can be used for viewing, image comparisons and statistics, tonemapping and mipmap generation. This has experimental KTX 2 support. Windows only.

Using KTX files on the Web

libktx

A JS binding for libktx is available for use with a .wasm compilation of the library. See its documentation for details of how to use it.

Container-independent transcoder for JS parsers.

There is also a JS binding for and a .wasm module of a container-independent transcoder for images encoded in Basis Universal format so those who wish to write their own parser in JS can do so. See its documentation for details of how to use it.

THREE.js loader

There is a prototype loader in THREE.js. See ???.

Babylon.js loader

There is a prototype loader in Babylon.js. See khronosTextureContainer2.ts.

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