Table of Contents

Enum KtxTextureFormat

Namespace
Egami.Formats.Extended.Ktx
Assembly
Egami.Formats.Extended.dll

The formats the KTX 2 writer writes, each a Vulkan VkFormat (or a Basis Universal format, VkFormat 0); Srgb picks the _SRGB form where there is one.

public enum KtxTextureFormat

Fields

Astc10x10 = 46

ASTC_10x10_UNORM_BLOCK (or _SRGB): LDR ASTC, 1.28 bits a pixel.

Astc10x5 = 43

ASTC_10x5_UNORM_BLOCK (or _SRGB): LDR ASTC, 2.56 bits a pixel.

Astc10x6 = 44

ASTC_10x6_UNORM_BLOCK (or _SRGB): LDR ASTC, 2.13 bits a pixel.

Astc10x8 = 45

ASTC_10x8_UNORM_BLOCK (or _SRGB): LDR ASTC, 1.6 bits a pixel.

Astc12x10 = 47

ASTC_12x10_UNORM_BLOCK (or _SRGB): LDR ASTC, 1.07 bits a pixel.

Astc12x12 = 48

ASTC_12x12_UNORM_BLOCK (or _SRGB): LDR ASTC, 0.89 bits a pixel.

Astc4x4 = 35

ASTC_4x4_UNORM_BLOCK (or _SRGB): LDR ASTC, 8 bits a pixel.

Astc5x4 = 36

ASTC_5x4_UNORM_BLOCK (or _SRGB): LDR ASTC, 6.4 bits a pixel.

Astc5x5 = 37

ASTC_5x5_UNORM_BLOCK (or _SRGB): LDR ASTC, 5.12 bits a pixel.

Astc6x5 = 38

ASTC_6x5_UNORM_BLOCK (or _SRGB): LDR ASTC, 4.27 bits a pixel.

Astc6x6 = 39

ASTC_6x6_UNORM_BLOCK (or _SRGB): LDR ASTC, 3.56 bits a pixel.

Astc8x5 = 40

ASTC_8x5_UNORM_BLOCK (or _SRGB): LDR ASTC, 3.2 bits a pixel.

Astc8x6 = 41

ASTC_8x6_UNORM_BLOCK (or _SRGB): LDR ASTC, 2.67 bits a pixel.

Astc8x8 = 42

ASTC_8x8_UNORM_BLOCK (or _SRGB): LDR ASTC, 2 bits a pixel.

Bc1 = 19

BC1_RGBA_UNORM_BLOCK (or _SRGB): RGB with 1-bit alpha, 4 bits a pixel.

Bc2 = 20

BC2_UNORM_BLOCK (or _SRGB): RGB with explicit 4-bit alpha, 8 bits a pixel.

Bc3 = 21

BC3_UNORM_BLOCK (or _SRGB): RGB with interpolated alpha, 8 bits a pixel.

Bc4 = 22

BC4_UNORM_BLOCK: one channel, the raster's gray, 4 bits a pixel.

Bc5 = 23

BC5_UNORM_BLOCK: red and green, for normal maps, 8 bits a pixel.

Bc6h = 24

BC6H_UFLOAT_BLOCK: unsigned half-float RGB for HDR, 8 bits a pixel; negatives become 0.

Bc6hSigned = 25

BC6H_SFLOAT_BLOCK: signed half-float RGB for HDR, 8 bits a pixel.

Bc7 = 26

BC7_UNORM_BLOCK (or _SRGB): RGBA at 8 bits a pixel, the best quality of the 8-bit BC formats.

Bgr565 = 16

R5G6B5_UNORM_PACK16: 16-bit colour.

Bgra4444 = 18

A4R4G4B4_UNORM_PACK16: 4 bits a channel.

Bgra5551 = 17

A1R5G5B5_UNORM_PACK16: 15-bit colour and 1-bit alpha.

Bgra8 = 1

B8G8R8A8_UNORM (or _SRGB): 8-bit BGRA.

D16 = 71

D16_UNORM: 16-bit depth, the raster's gray.

D32F = 72

D32_SFLOAT: float depth, the raster's gray.

EacR11 = 31

EAC_R11_UNORM_BLOCK: one 11-bit channel, the raster's gray, 4 bits a pixel.

EacR11Signed = 32

EAC_R11_SNORM_BLOCK: one signed 11-bit channel; the raster's 0 to 1 maps to −1 to 1, as the reader maps back.

EacRg11 = 33

EAC_R11G11_UNORM_BLOCK: red and green, 11 bits each, for normal maps, 8 bits a pixel.

EacRg11Signed = 34

EAC_R11G11_SNORM_BLOCK: signed red and green; the raster's 0 to 1 maps to −1 to 1, as the reader maps back.

Etc1 = 27

ETC1, stored as ETC2_R8G8B8_UNORM_BLOCK (or _SRGB), of which it is the subset every ETC1 decoder reads: RGB at 4 bits a pixel.

Etc1s = 49

Basis Universal ETC1S with BasisLZ supercompression: shared endpoint and selector codebooks (BasisQuality sets their size), the smallest files, transcodable to any GPU format. An alpha channel gets its own slices when the raster has transparent pixels.

Etc2Rgb = 28

ETC2_R8G8B8_UNORM_BLOCK (or _SRGB): RGB at 4 bits a pixel, with ETC2's T, H and planar modes.

Etc2RgbA1 = 29

ETC2_R8G8B8A1_UNORM_BLOCK (or _SRGB): RGB with 1-bit alpha (punch-through) at 4 bits a pixel.

Etc2Rgba = 30

ETC2_R8G8B8A8_UNORM_BLOCK (or _SRGB): RGB with EAC alpha, 8 bits a pixel.

R11G11B10F = 14

B10G11R11_UFLOAT_PACK32: unsigned 11-, 11- and 10-bit floats, for HDR colour without alpha.

R16 = 5

R16_UNORM: one 16-bit channel, the raster's gray.

R16SInt = 58

R16_SINT: signed integers. The raster's 0 to the full scale map to the type's minimum to maximum, as the reader maps back.

R16UInt = 57

R16_UINT: unsigned integers.

R32F = 10

R32_SFLOAT: one float channel, the raster's gray.

R32SInt = 64

R32_SINT: signed integers. The raster's float values round to the nearest integer and clamp to the type's range.

R32UInt = 63

R32_UINT: unsigned integers. The raster's float values round to the nearest integer and clamp to the type's range.

R8 = 3

R8_UNORM (or _SRGB): one 8-bit channel, the raster's gray.

R8SInt = 52

R8_SINT: signed integers. The raster's 0 to the full scale map to the type's minimum to maximum, as the reader maps back.

R8UInt = 51

R8_UINT: unsigned integers.

Rg16 = 6

R16G16_UNORM: red and green, 16 bits each.

Rg16SInt = 60

R16G16_SINT: signed integers. The raster's 0 to the full scale map to the type's minimum to maximum, as the reader maps back.

Rg16UInt = 59

R16G16_UINT: unsigned integers.

Rg32SInt = 66

R32G32_SINT: signed integers. The raster's float values round to the nearest integer and clamp to the type's range.

Rg32UInt = 65

R32G32_UINT: unsigned integers. The raster's float values round to the nearest integer and clamp to the type's range.

Rg8 = 4

R8G8_UNORM (or _SRGB): red and green, 8 bits each, as two-channel normal maps keep them.

Rg8SInt = 54

R8G8_SINT: signed integers. The raster's 0 to the full scale map to the type's minimum to maximum, as the reader maps back.

Rg8UInt = 53

R8G8_UINT: unsigned integers.

Rgb10A2 = 13

A2B10G10R10_UNORM_PACK32: 10-bit RGB and 2-bit alpha.

Rgb16 = 7

R16G16B16_UNORM: 16-bit RGB.

Rgb32SInt = 68

R32G32B32_SINT: signed integers. The raster's float values round to the nearest integer and clamp to the type's range.

Rgb32UInt = 67

R32G32B32_UINT: unsigned integers. The raster's float values round to the nearest integer and clamp to the type's range.

Rgb8 = 2

R8G8B8_UNORM (or _SRGB): 8-bit RGB.

Rgb9E5 = 15

E5B9G9R9_UFLOAT_PACK32: three 9-bit mantissas sharing an exponent, for HDR colour without alpha.

RgbF32 = 11

R32G32B32_SFLOAT: float RGB.

Rgba16 = 8

R16G16B16A16_UNORM: 16-bit RGBA.

Rgba16SInt = 62

R16G16B16A16_SINT: signed integers. The raster's 0 to the full scale map to the type's minimum to maximum, as the reader maps back.

Rgba16UInt = 61

R16G16B16A16_UINT: unsigned integers.

Rgba32SInt = 70

R32G32B32A32_SINT: signed integers. The raster's float values round to the nearest integer and clamp to the type's range.

Rgba32UInt = 69

R32G32B32A32_UINT: unsigned integers. The raster's float values round to the nearest integer and clamp to the type's range.

Rgba8 = 0

R8G8B8A8_UNORM (or _SRGB): 8-bit RGBA.

Rgba8SInt = 56

R8G8B8A8_SINT: signed integers. The raster's 0 to the full scale map to the type's minimum to maximum, as the reader maps back.

Rgba8UInt = 55

R8G8B8A8_UINT: unsigned integers.

RgbaF16 = 9

R16G16B16A16_SFLOAT: half-float RGBA.

RgbaF32 = 12

R32G32B32A32_SFLOAT: float RGBA.

Uastc = 50

Basis Universal UASTC LDR 4 × 4: 8 bits a pixel, near BC7 in quality, transcodable to any GPU format; usually paired with Zstandard and UastcRdo.

Examples

// With no options: the nearest uncompressed format (R8G8B8A8_SRGB for 8-bit colour) and the full mip chain.
using (FileStream output = File.Create("duck.ktx2"))
{
    image.Save(output, Ktx2Format.Info);
}

// A GPU block format: BC7 for desktop, ASTC or ETC2 for mobile; effort runs 0 (fastest) to 6 (best).
using (FileStream output = File.Create("duck-astc.ktx2"))
{
    image.Save(output, Ktx2Format.Info, new Ktx2WriterOptions { Format = KtxTextureFormat.Astc6x6, Effort = 3 });
}

// Basis Universal, which a viewer transcodes to whatever its GPU reads: UASTC with RDO and Zstandard (glTF's usual
// pick), or ETC1S for the smallest files.
using (FileStream output = File.Create("duck-uastc.ktx2"))
{
    image.Save(output, Ktx2Format.Info, new Ktx2WriterOptions
    {
        Format = KtxTextureFormat.Uastc,
        UastcRdo = 2,
        Supercompression = KtxSupercompression.Zstandard,
    });
}

using (FileStream output = File.Create("duck-etc1s.ktx2"))
{
    image.Save(output, Ktx2Format.Info, new Ktx2WriterOptions { Format = KtxTextureFormat.Etc1s, BasisQuality = 128 });
}

// Six faces into a cube map; SaveAll without Cube writes a texture array.
using RasterList faces = Raster.LoadAll("sky.ktx2", context);
using (FileStream output = File.Create("sky-bc1.ktx2"))
{
    Raster.SaveAll(faces, output, Ktx2Format.Info, new Ktx2WriterOptions { Cube = true, Format = KtxTextureFormat.Bc1 });
}