KTX (Khronos Texture Format)

1. Introduction

In Castle Game Engine we fully support KTX, Khronos Texture Format.

There’s nothing special you need to do to use KTX files in Castle Game Engine. Just load images in KTX format and display them as usual, see using images in the manual.

KTX in castle-image-viewer

2. Tooling

Our Castle Image Viewer supports KTX and allows to view each subimage of a KTX file.

We also have example utility image_decompose that allows to extract all subimages from a KTX file.

You may find example KTX images inside our demo models. Also KTX-Software has some samples (look in tests subdirectory).

3. Features

KTX is an excellent image format with a number of graphic features useful when it comes to using it for textures and 3D:

  • Can utilize GPU compression (images are compressed not only on disk, but also in GPU memory). We support these GPU-compressed formats in KTX:

    • S3TC (DXT* formats, often available on desktops),

    • ATITC (ATI compression, available on some mobile devices),

    • PVRTC (PowerVR compression, available on some mobile devices),

    • ETC1 (Ericsson compression, often available on mobile devices, but without alpha support).

    • More compressed formats can be trivially added, just submit a bugreport with a sample KTX file.

  • Textures can have explicit mipmaps (allows texture have better quality when viewer from far away).

  • Volume (3D) textures.

  • Configurable orientation of the image data in file. KTX data may be specified in top-to-bottom or bottom-to-top order. For 3D images, the slices can additionally be in front-to-back or back-to-front order. We support all these possibilities.

  • Cube map can be stored — this means that we effectively have 6 images (for skyboxes, reflections, etc.). TODO: We don’t support cubemap yet, but we plan to add it. Submit a bugreport with a sample KTX file to make it happen sooner!

We support KTX 1 right now. We plan to support KTX 2 (with KHR_texture_basisu) in the future too.

4. Advanced Usage

While we have no guaranteed API to access KTX subimages directly, you can use CastleInternalCompositeImage unit. This way you can explicitly iterate over items of a texture array in KTX, for any purpose.

Warning
As the name suggests, CastleInternalCompositeImage is an internal unit and its API may change arbitrarily in the future.

To improve this documentation just edit this page and create a pull request to cge-www repository.