TXTR (Tropical Freeze): Difference between revisions
Jump to navigation
Jump to search
→PAK Metadata
>Aruki No edit summary |
>Aruki |
||
(11 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
The '''TXTR''' format is Tropical Freeze's texture format. The image data in the GPU buffer is compressed using [[LZSS Compression|LZSS compression]]. | The '''TXTR''' format is Tropical Freeze's texture format. The image data in the GPU buffer is compressed using [[LZSS Compression|LZSS compression]]. | ||
{{research| | {{research|moderate|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.}} | ||
__TOC__ | __TOC__ | ||
Line 13: | Line 13: | ||
{| class="wikitable" | {| class="wikitable" | ||
! Offset | ! Offset | ||
! Type | ! style="width:110px;"|Type | ||
! | ! style="width:100px;"|Count | ||
! | ! style="width:170px;"|Name | ||
! Notes | ! Notes | ||
|- | |- | ||
| 0x0 | | 0x0 | ||
| [[Chunk Descriptor (Tropical Freeze)|Chunk Descriptor]] | | [[Chunk Descriptor (Tropical Freeze)|Chunk Descriptor]] | ||
| | | 1 | ||
| '''HEAD Chunk Descriptor''' | | '''HEAD Chunk Descriptor''' | ||
| | | | ||
Line 26: | Line 26: | ||
| 0x18 | | 0x18 | ||
| u32 | | u32 | ||
| | | 1 | ||
| | | [[#Texture Type|'''Texture Type''']] | ||
| | | Describes the type/dimensionality of the texture (2D texture, 3D texture, cubemap, array of 2D images, etc). | ||
|- | |- | ||
| 0x1C | | 0x1C | ||
| u32 | | u32 | ||
| | | 1 | ||
| ''' | | [[#Texture Format|'''Texture Format''']] | ||
| | | Describes the format that the image data is encoded in. | ||
|- | |- | ||
| 0x20 | | 0x20 | ||
| u32 | | u32 | ||
| | | 1 | ||
| '''Width''' | | '''Width''' | ||
| | | Texture X resolution. | ||
|- | |- | ||
| 0x24 | | 0x24 | ||
| u32 | | u32 | ||
| | | 1 | ||
| '''Height''' | | '''Height''' | ||
| | | Texture Y resolution. | ||
|- | |- | ||
| 0x28 | | 0x28 | ||
| u32 | | u32 | ||
| | | 1 | ||
| '''Depth''' | | '''Depth''' | ||
| | | Texture Z resolution. | ||
|- | |- | ||
| 0x2C | | 0x2C | ||
| u32 | | u32 | ||
| | | 1 | ||
| | | '''Tile Mode''' | ||
| | | Indicates how the texture image data is tiled. | ||
|- | |- | ||
| 0x30 | | 0x30 | ||
| u32 | | u32 | ||
| | | 1 | ||
| '''Swizzle''' | | '''Swizzle''' | ||
| | | Indicates how the texture image data is swizzled. | ||
|- | |- | ||
| 0x34 | | 0x34 | ||
| u32 | | u32 | ||
| | | 1 | ||
| | | '''Mipmap Count''' | ||
| | | | ||
|- | |- | ||
| 0x38 | | 0x38 | ||
| u32 | | u32 | ||
| | | ''Mipmap Count'' | ||
| | | '''Mipmap Sizes''' | ||
| | | The size of the base level mipmap is calculated with padding and alignment taken into account. The size of subsequent mipmaps is calculated as Width*Height*Depth*BPP/8. This does '''not''' take padding and alignment into account, and so it does not accurately reflect the amount of space the mipmap takes up in the file, and it cannot be used to accurately locate and read mipmap data. The offset and size needs to be calculated from the other parameters in the header. The game calculates this data by calling GX2CalcSurfaceSizeAndAlignment. | ||
|- | |- | ||
| | | {{none}} | ||
| u32 | | u32 | ||
| | | 1 | ||
| {{unknown|Unknown}} | | {{unknown|Unknown}} | ||
| | | This parameter is part of NTextureFormat::STextureSamplerData (along with the next 4 parameters) | ||
|- | |- | ||
| | | {{none}} | ||
| u8 | | u8 | ||
| 1 | | 1 | ||
| | | [[#Texture Filter|'''Texture Filter''']] | ||
| | | Determines how the texture is filtered when sampled. | ||
|- | |- | ||
| | | {{none}} | ||
| u8 | | u8 | ||
| 1 | | 1 | ||
| | | [[#Texture Wrap|'''Texture Wrap X''']] | ||
| | | Determines how the texture wraps on the X coordinate. | ||
|- | |- | ||
| | | {{none}} | ||
| u8 | | u8 | ||
| 1 | | 1 | ||
| | | [[#Texture Wrap|'''Texture Wrap Y''']] | ||
| | | Determines how the texture wraps on the Y coordinate. | ||
|- | |- | ||
| | | {{none}} | ||
| u8 | | u8 | ||
| 1 | | 1 | ||
| { | | [[#Texture Wrap|'''Texture Wrap Z''']] | ||
| | | Determines how the texture wraps on the Z coordinate. | ||
|} | |||
=== Texture Type === | |||
This enum basically maps directly to a GX2SurfaceDim enum. | |||
{| class="wikitable" | |||
! ID | |||
! Type | |||
|- | |||
| 0 | |||
| 1D Texture | |||
|- | |||
| 1 | |||
| 2D Texture | |||
|- | |||
| 2 | |||
| 3D Texture | |||
|- | |||
| 3 | |||
| Cube Texture | |||
|- | |||
| 4 | |||
| 1D Texture Array | |||
|- | |||
| 5 | |||
| 2D Texture Array | |||
|- | |||
| 6 | |||
| Multisampled 2D Texture | |||
|- | |||
| 7 | |||
| Multisampled 2D Texture Array | |||
|} | |} | ||
== | === Texture Format === | ||
{| class="wikitable" | {| class="wikitable" | ||
! ID | ! 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 | | 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 | | 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 | | 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). | |||
{| class="wikitable" | |||
! ID | |||
! GX2TexMipFilterType | |||
|- | |||
| 0 | |||
| GX2_TEX_MIP_FILTER_POINT | |||
|- | |||
| 1 | |||
| GX2_TEX_MIP_FILTER_LINEAR | |||
|} | |||
=== Texture Wrap === | |||
Invalid values default to 0 (clamp). | |||
{| class="wikitable" | |||
! ID | |||
! GX2TexClamp | |||
|- | |||
| 0 | |||
| GX2_TEX_CLAMP_CLAMP | |||
|- | |||
| 1 | |||
| GX2_TEX_CLAMP_WRAP | |||
|- | |||
| 2 | |||
| GX2_TEX_CLAMP_MIRROR | |||
|- | |||
| 3 | |||
| GX2_TEX_CLAMP_MIRROR_ONCE | |||
|} | |} | ||
Line 135: | Line 294: | ||
! Offset | ! Offset | ||
! Type | ! Type | ||
! | ! Count | ||
! | ! Name | ||
! Notes | ! Notes | ||
|- | |- | ||
| 0x0 | | 0x0 | ||
| u32 | | u32 | ||
| | | 1 | ||
| {{unknown|Unknown}} | | {{unknown|Unknown}} | ||
| | | Always 4 | ||
|- | |- | ||
| 0x4 | | 0x4 | ||
| u32 | | u32 | ||
| | | 1 | ||
| {{unknown|Unknown}} | | {{unknown|Unknown}} | ||
| | | | ||
Line 153: | Line 312: | ||
| 0x8 | | 0x8 | ||
| u32 | | u32 | ||
| | | 1 | ||
| '''GPU | | '''GPU Section Offset''' | ||
| Relative to the start of the file | | Relative to the start of the file | ||
|- | |- | ||
| 0xC | | 0xC | ||
| u32 | | u32 | ||
| | | 1 | ||
| | | '''Base Alignment''' | ||
| | | Alignment of the surface image data | ||
|- | |- | ||
| 0x10 | | 0x10 | ||
| u32 | | u32 | ||
| | | 1 | ||
| '''GPU | | '''GPU Data Start''' | ||
| This is the offset to the start of the GPU data, immediately after the GPU section header. | | This is the offset to the start of the GPU data, immediately after the GPU section header. | ||
|- | |- | ||
| 0x14 | | 0x14 | ||
| u32 | | u32 | ||
| | | 1 | ||
| '''GPU | | '''GPU Section Size''' | ||
| Matches the size from the GPU section header. | | Matches the size from the GPU section header. | ||
|- | |- | ||
| 0x18 | | 0x18 | ||
| u32 | | u32 | ||
| | | 1 | ||
| '''Compressed | | '''Compressed Buffer Count''' | ||
| | | | ||
|- | |- | ||
| 0x1C | | 0x1C | ||
| [[#Compressed Buffer|Compressed Buffer] | | [[#Compressed Buffer|Compressed Buffer]] | ||
| | | ''Compressed Buffer Count'' | ||
| '''Compressed | | '''Compressed Buffer Array''' | ||
| | | | ||
|} | |} | ||
Line 195: | Line 354: | ||
! Offset | ! Offset | ||
! Type | ! Type | ||
! | ! Name | ||
! Notes | ! Notes | ||
|- | |- |