Glossary · File formats

KTX2 and Basis Universal

In short

KTX2 is a Khronos Group container format for GPU textures. With Basis Universal compression a texture is stored once and converted in the browser into whatever format the visitor's graphics card can use directly [1].

The problem with JPEG and PNG

A JPEG is small to download, but on the graphics card it is decompressed and occupies its full size in memory. GPUs have their own compressed texture formats that are smaller in memory and faster to sample [3]. Unfortunately no single format is supported everywhere [3].

The fix: one universal intermediate format

Basis Universal stores the texture once and transcodes it at run time into a format the visitor's GPU understands [1][3]. In glTF this is handled by the KHR_texture_basisu extension, aimed at more efficient transmission and a smaller GPU memory footprint [2]. There are two modes [1]:

  • ETC1S: much less GPU memory than JPEG or PNG and often smaller files, at lower quality than UASTC.
  • UASTC: higher quality, still with noticeable memory savings.

The trade-off

MDN notes that compressed texture formats look worse than JPEG and are generally only acceptable for colours, not for normals or coordinates [3]. For normal maps it is therefore worth checking whether UASTC is good enough or another format serves better.

When KTX2 pays off

  • many or large textures, such as high-resolution wood, fabric or stone;
  • scenes that run close to the GPU memory limit on phones;
  • variants with many colour textures loaded one after another.

With a few small textures the effort often outweighs the benefit. The GLB files in our example configurators currently use WebP textures (the EXT_texture_webp extension); gltfpack can produce either [4]. The guide CAD to web 3D puts textures in the wider preparation process.

Related terms

  • Texture maps

    Texture maps are images that assign material properties point by point across a 3D surface: colour, surface structure, roughness, metalness or shading. They sit on the model through UV coordinates.

  • GLB

    GLB is the binary form of glTF: the JSON description, geometry and textures are packed into one file. GLB is a common delivery format for 3D models on websites.

  • Meshopt compression

    Meshopt is a glTF compression method, defined in the EXT_meshopt_compression extension, that shrinks geometry and animation data. According to the specification its decoders run at around 1 GB per second on modern desktop hardware.

  • Draw calls

    A draw call is a single drawing command sent to the graphics card, such as "draw this mesh with this material". Each call carries overhead, so a few large calls are generally faster than many small ones.

More in our guides

Sources

  1. Khronos Group: KTX – GPU Texture Container Format
  2. Khronos Group: KHR_texture_basisu (glTF extension)
  3. MDN Web Docs: WebGL best practices
  4. meshoptimizer: gltfpack

← All terms in the glossary