From CloudModding OoT Wiki

The CTXB format (CTR Texture Binary) is an image format used in Ocarina of Time 3D, Majora's Mask 3D, Luigi's Mansion 3D, and Ever Oasis

Note: Nearly all this information was gathered from the source code of Scarlet.

CTXB chunk

The CTXB chunk is first chunk encountered in the file. It encompasses the entire file and contains a TEX chunk.

Offset Type Description
0000 char[4] magic "ctxb" ("CTR Texture Binary")
0004 u32 FileSize
0008 u32 Number of TEX chunks
000C u32 Unknown
0010 u32 Offset to TEX chunk
0014 u32 Offset to texture data


TEX chunk

The TEX chunk contains textures.

Offset Type Description
0000 char[4] magic "tex " ("Textures?")
0004 u32 size of chunk
0008 u32 # of textures
000C Texture[# of textures] array of textures

Texture

Each Texture is:

Offset Type Description
0000 u32 Length of texture data in bytes
0004 u16 Mipmap Count
0006 u8 IsETC1 (if TextureFormat is ETC1RGB8NativeDMP or ETC1AlphaRGB8A4NativeDMP)
0007 u8 IsCubemap (see CubemapData)
0008 u16 Width
000A u16 Height
000C u16 (PicaTextureFormat) Texture color format
000E u16 (PicaDataType) Texture data type (If 0, just use the texture color format by itself. Also see PicaTextureFormat)
0010 u32 Texture data offset, relative to the Texture data pointer from the CMB chunk
0014 char[16] Texture name

CubemapData

Note: Cubemap entries come after all texture entries

Each Cubemap entry is:

Offset Type Description Coordinate
0000 u32 Right DataOffset (+X)
0004 u32 Left DataOffset (-X)
0008 u32 Bottom DataOffset (-Y)
000C u32 Top DataOffset (+Y)
0010 u32 Front DataOffset (-Z)
0014 u32 Back DataOffset (+Z)

PicaTextureFormat

PicaTextureFormat can be:

Value Description
0x6752 RGBANativeDMP
0x6754 RGBNativeDMP
0x6756 AlphaNativeDMP
0x6757 LuminanceNativeDMP
0x6758 LuminanceAlphaNativeDMP
0x675A ETC1RGB8NativeDMP
0x675B ETC1AlphaRGB8A4NativeDMP

PicaTextureFormat interacts with PicaDataType as follows:

PicaTextureFormat PicaDataType Resulting texture data format
ETC1RGB8NativeDMP 0 ETC1
ETC1AlphaRGB8A4NativeDMP 0 ETC1A4
RGBANativeDMP u8 (unsigned byte) RGBA8
RGBNativeDMP u8 (unsigned byte) RGB8
RGBANativeDMP UnsignedShort4444 RGBA4
RGBANativeDMP UnsignedShort5551 RGBA5551
RGBNativeDMP UnsignedShort565 RGB565
LuminanceAlphaNativeDMP UnsignedByte44DMP LA4
LuminanceAlphaNativeDMP u8 (unsigned byte) LA8
AlphaNativeDMP u8 (unsigned byte) A8
LuminanceNativeDMP u8 (unsigned byte) L8
LuminanceNativeDMP Unsigned4BitsDMP L4

PicaDataType

PicaDataType can be:

Value Description
0x1400 s8 (byte)
0x1401 u8 (unsigned byte)
0x1402 s16 (short)
0x1403 u16 unsigned short
0x1404 s32 (int)
0x1405 u32 (unsigned int)
0x1406 f32 (float)
0x6760 UnsignedByte44DMP
0x6761 Unsigned4BitsDMP
0x8033 UnsignedShort4444
0x8034 UnsignedShort5551
0x8363 UnsignedShort565