Difference between revisions of "TEX0 (File Format)"

From Custom Mario Kart
Jump to navigation Jump to search
Line 10: Line 10:
  
 
{| class="wikitable"
 
{| class="wikitable"
! Offset !! Size !! Description
+
! Offset !! Type !! Description
 
|-
 
|-
| 0x00 || 4 || Unknown, always 0 in Mario Kart Wii.
+
| 0x00 || UInt32 || {{Unknown-left|Bit Flag (0x01 - Use cifmt, meaning unknown). }}
 
|-
 
|-
| 0x04 || 2 || Pixel width of the image.
+
| 0x04 || UInt16 || Pixel width of the image.
 
|-
 
|-
| 0x06 || 2 || Pixel height of the image.
+
| 0x06 || UInt16 || Pixel height of the image.
 
|-
 
|-
| 0x08 || 4 || [[Image Formats|Image format]]
+
| 0x08 || UInt32 || [[Image Formats|Image format]]
 
|-
 
|-
| 0x0c || 4 || Number of images ('''=N'''; 1..8 seen in Mario Kart Wii). In the data area the main image comes first followed by '''N-1''' [[mipmap]]s. Each mipmap has half the width and height of the previous image, rounded down.
+
| 0x0c || UInt32 || Number of mipmaps.
 
|-
 
|-
| 0x10 || 4 || Unknown, always 0 in Mario Kart Wii.
+
| 0x10 || Float || Minimal mipmap used. Always 0.
 
|-
 
|-
| 0x14 || 4 || The number of images minus 1 ('''=''' the number of mipmaps '''=''' N-1) as single precision floating point.
+
| 0x14 || Float || Maximum mipmap used.  
 
|-
 
|-
| 0x18 || 4 || Unknown, always 0 in Mario Kart Wii.
+
| 0x18 || UInt32 || {{Unknown-left|Unused. Offset to absolute path of intermediate file.}}
 
|-
 
|-
 
| 0x1c || colspan=2 {{unknown|End of header/Start of a filler}}
 
| 0x1c || colspan=2 {{unknown|End of header/Start of a filler}}

Revision as of 08:13, 6 April 2023

Overview

This page describes the Mario Kart Wii TEX0 file format, as found within BRRES files. They are a type of texture files.

File Format

File Header

Offset Type Description
0x00 String The magic "TEX0" to identify the sub file. See »BRRES Sub Files« for other magics.
0x04 UInt32 Length of the sub file.
0x08 UInt32 Sub file version number. The number of sections (N) is dependent of this version number. See »BRRES Sub Files« for details.
0x0C Int32 Offset to outer BRRES File.
0x10 Int32[N] N section offsets. N is implied in the version number (offset 0x08).
0x10+N*4 Int32 String offset to the name of this sub file. This name equal to the name of the entry name of the BRRES Index Group pointing to this data.
0x14+N*4 End of this header

TEX0 Header

The TEX0 header follows direct behind the file header. For TEX0 version 3 it starts at offset 0x18 and has the following layout:

Offset Type Description
0x00 UInt32 Bit Flag (0x01 - Use cifmt, meaning unknown).
0x04 UInt16 Pixel width of the image.
0x06 UInt16 Pixel height of the image.
0x08 UInt32 Image format
0x0c UInt32 Number of mipmaps.
0x10 Float Minimal mipmap used. Always 0.
0x14 Float Maximum mipmap used.
0x18 UInt32 Unused. Offset to absolute path of intermediate file.
0x1c End of header/Start of a filler

Image Data (Section 0)

The start of section 0 is defined in the file header. It contains the image data (see TPL and Image Formats for details).

Most TEX0 files contain additional mipmaps after the main image. These mipmaps have the same image format as the main image. Each mipmap has half the width and height of the previous image rounded down.

During rendering, the mipmaps are used for textures that are distant. To render a given texture, the Wii generally computes how big it appears on screen, and then interpolates between the mipmap bigger and smaller than this size to produce texture information quickly. This behavior can be controlled by the materials sections within BRRES files. See Mipmap on Wikipedia for more details.

Image Formats
ID Name Bits per pixel Block width Block height Block size Type
0x00 I4 4 8 8 32 bytes Gray
0x01 I8 8 8 4 32 bytes Gray
0x02 IA4 8 8 4 32 bytes Gray + Alpha
0x03 IA8 16 4 4 32 bytes Gray + Alpha
0x04 RGB565 16 4 4 32 bytes Color
0x05 RGB5A3 16 4 4 32 bytes Color + Alpha
0x06 RGBA32 (RGBA8) 32 4 4 64 bytes Color + Alpha
0x08 C4 (CI4) 4 8 8 32 bytes Palette (IA8, RGB565, RGB5A3)
0x09 C8 (CI8) 8 8 4 32 bytes Palette (IA8, RGB565, RGB5A3)
0x0A C14X2 (CI14x2) 16 4 4 32 bytes Palette (IA8, RGB565, RGB5A3)
0x0E CMPR 4 8 8 32 bytes Color + optional Alpha (compressed)

Tools

The following tools can handle TEX0 files:

Links

All about BRRES files

BRRES fileIndex GroupSub Files

CHR0CLR0MDL0PAT0SCN0SHP0SRT0TEX0