TXTR (Tropical Freeze)
See TXTR (File Format) for the other revisions of this format.
The TXTR format is Tropical Freeze's texture format. The image data in the GPU buffer is compressed using LZSS compression.
This file format needs more research There are a couple unknowns in the header. It would also be good to have some documentation on how to deswizzle/decompress different texture formats. |
Contents
Format
The format starts with the typical form descriptor found in every Tropical Freeze format. Following that, there's a HEAD header section that contains most of the texture parameters, then the GPU section containing the actual compressed image data. This is the structure of the HEAD section:
Offset | Type | Count | Name | Notes |
---|---|---|---|---|
0x0 | Chunk Descriptor | 1 | HEAD Chunk Descriptor | |
0x18 | u32 | 1 | Texture Type | Describes the type/dimensionality of the texture (2D texture, 3D texture, cubemap, array of 2D images, etc). |
0x1C | u32 | 1 | Texture Format | Describes the format that the image data is encoded in. |
0x20 | u32 | 1 | Width | Texture X resolution. |
0x24 | u32 | 1 | Height | Texture Y resolution. |
0x28 | u32 | 1 | Depth | Texture Z resolution. |
0x2C | u32 | 1 | Tile Mode | Indicates how the texture image data is tiled. |
0x30 | u32 | 1 | Swizzle | Indicates how the texture image data is swizzled. |
0x34 | u32 | 1 | Mipmap Count | |
0x38 | u32 | Mipmap Count | Mipmap Sizes | |
u32 | 1 | Unknown | This parameter is part of NTextureFormat::STextureSamplerData (along with the next 4 parameters) | |
u8 | 1 | Texture Filter | Determines how the texture is filtered when sampled. | |
u8 | 1 | Texture Wrap X | Determines how the texture wraps on the X coordinate. | |
u8 | 1 | Texture Wrap Y | Determines how the texture wraps on the Y coordinate. | |
u8 | 1 | Texture Wrap Z | Determines how the texture wraps on the Z coordinate. |
Texture Type
This enum basically maps directly to a GX2SurfaceDim enum.
ID | GX2SurfaceDim |
---|---|
0 | GX2_SURFACE_DIM_1D |
1 | GX2_SURFACE_DIM_2D |
2 | GX2_SURFACE_DIM_3D |
3 | GX2_SURFACE_DIM_CUBE |
4 | GX2_SURFACE_DIM_1D_ARRAY |
5 | GX2_SURFACE_DIM_2D_ARRAY |
6 | GX2_SURFACE_DIM_2D_MSAA |
7 | GX2_SURFACE_DIM_2D_MSAA_ARRAY |
Texture Format
ID | GX2SurfaceFormat |
---|---|
0x00 | GX2_SURFACE_FORMAT_TC_R8_UNORM |
0x01 | GX2_SURFACE_FORMAT_TC_R8_SNORM |
0x02 | GX2_SURFACE_FORMAT_TC_R8_UINT |
0x03 | GX2_SURFACE_FORMAT_TC_R8_SINT |
0x04 | GX2_SURFACE_FORMAT_TCD_R16_UNORM |
0x05 | GX2_SURFACE_FORMAT_TC_R16_SNORM |
0x06 | GX2_SURFACE_FORMAT_TC_R16_UINT |
0x07 | GX2_SURFACE_FORMAT_TC_R16_SINT |
0x08 | GX2_SURFACE_FORMAT_TC_R16_FLOAT |
0x09 | GX2_SURFACE_FORMAT_TC_R32_UINT |
0x0A | GX2_SURFACE_FORMAT_TC_R32_SINT |
0x0B | GX2_SURFACE_FORMAT_INVALID |
0x0C | GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM |
0x0D | GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_SRGB |
0x0E | GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_FLOAT |
0x0F | GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_FLOAT |
0x10 | GX2_SURFACE_FORMAT_TCD_R16_UNORM |
0x11 | GX2_SURFACE_FORMAT_TCD_R16_UNORM |
0x12 | GX2_SURFACE_FORMAT_D_D24_S8_UNORM |
0x13 | GX2_SURFACE_FORMAT_TCD_R32_FLOAT |
0x14 | GX2_SURFACE_FORMAT_T_BC1_UNORM |
0x15 | GX2_SURFACE_FORMAT_T_BC1_SRGB |
0x16 | GX2_SURFACE_FORMAT_T_BC2_UNORM |
0x17 | GX2_SURFACE_FORMAT_T_BC2_SRGB |
0x18 | GX2_SURFACE_FORMAT_T_BC3_UNORM |
0x19 | GX2_SURFACE_FORMAT_T_BC3_SRGB |
0x1A | GX2_SURFACE_FORMAT_T_BC4_UNORM |
0x1B | GX2_SURFACE_FORMAT_T_BC4_SNORM |
0x1C | GX2_SURFACE_FORMAT_T_BC5_UNORM |
0x1D | GX2_SURFACE_FORMAT_T_BC5_SNORM |
0x1E | GX2_SURFACE_FORMAT_TC_R11_G11_B10_FLOAT |
0x1F | GX2_SURFACE_FORMAT_TCD_R32_FLOAT |
0x20 | GX2_SURFACE_FORMAT_TC_R16_G16_FLOAT |
0x21 | GX2_SURFACE_FORMAT_TC_R8_G8_UNORM |
Texture Filter
Invalid values default to 1 (linear).
ID | GX2TexMipFilterType |
---|---|
0 | GX2_TEX_MIP_FILTER_POINT |
1 | GX2_TEX_MIP_FILTER_LINEAR |
Texture Wrap
Invalid values default to 0 (clamp).
ID | GX2TexClamp |
---|---|
0 | GX2_TEX_CLAMP_CLAMP |
1 | GX2_TEX_CLAMP_WRAP |
2 | GX2_TEX_CLAMP_MIRROR |
3 | GX2_TEX_CLAMP_MIRROR_ONCE |
PAK Metadata
The pak metadata for the TXTR format primarily contains compression-related information and provides the values required to decompress it.
Offset | Type | Count | Name | Notes |
---|---|---|---|---|
0x0 | u32 | 1 | Unknown | |
0x4 | u32 | 1 | Unknown | |
0x8 | u32 | 1 | GPU Section Offset | Relative to the start of the file |
0xC | u32 | 1 | Unknown | |
0x10 | u32 | 1 | GPU Data Start | This is the offset to the start of the GPU data, immediately after the GPU section header. |
0x14 | u32 | 1 | GPU Section Size | Matches the size from the GPU section header. |
0x18 | u32 | 1 | Compressed Buffer Count | |
0x1C | Compressed Buffer | Compressed Buffer Count | Compressed Buffer Array |
Compressed Buffer
This is a small struct that defines a compressed data buffer within the GPU section.
Offset | Type | Name | Notes |
---|---|---|---|
0x0 | u32 | Decompressed Size | |
0x4 | u32 | Compressed Size | |
0x8 | u32 | Offset | Relative to after the GPU section header |