-
Notifications
You must be signed in to change notification settings - Fork 4
TEX Format
TEX is a texture format and is used throughout Final Fantasy VII. The TEX format consists of a header, an optional palette, and bitmap data. Usually, data are stored as a palletized picture, with bitmap pixels referencing the palette. The color #000000 is often used to denote transparency (but not always; it depends on the color key status; more info later). The TEX format is very flexible and can take almost any non-paletted format as long as it is described properly in the header. This wiki might be a useful reference.
A TEX file's header gives general information about the TEX file.
- This is an unsigned integer and must always equal 1 for Final Fantasy VII to load
- These 4 bytes have unknown function
- This is an unsigned integer
- According to this, this must be 1 (i.e.,
00000001
) to enable transparent color- All the
**ac
files have it as 1
- All the
- These 4 bytes have unknown function
- These 4 bytes have unknown function
- This is an unsigned integer
- The D3D driver uses this to determine which texture format to convert to on load
- This is an unsigned integer
- This is an unsigned integer
- This is an unsigned integer
- This is an unsigned integer
- This is an unsigned integer
- These 4 bytes have unknown function
- This is an unsigned integer
- This is an unsigned integer
- This is an unsigned integer
- This is an unsigned integer
- This is an unsigned integer
- This is an unsigned integer
- This is usually ignored and assumed to be width * bytes-per-pixel
- All the
**ac
files have 0 for this
- These 4 bytes have unknown function
- This is an unsigned integer
- 1 indicates the presence of a palette, otherwise 0
- This is an unsigned integer
- This is always 8 for non-paletted images
- This is an unsigned integer
- This is never used in Final Fantasy VII
- All the
**ac
files have 0 for this
- This is an unsigned integer
-
This wiki, says it's always number of palettes * colors per palette
- However, when I tested it, it was always equal to number of colors per palette (not the product)
- This is an unsigned integer
- The first instance will be used anyways
- This is ignored on load
- This is an unsigned integer
- All the
**ac
files have 8 for this
- This is an unsigned integer
- Always use this to determine how much data to read, regardless of the bit depth
- For example, if this is 1, you read 1 byte per pixel
- All the
**ac
files have 1 for this
This section has information about the pixel format. It seems as though color values are computed by (((value & mask) >> shift) * 255) / max
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
- This is an unsigned integer
- All the
**ac
files have 0 for this
This is some more header information.
- This indicates the presence of a color key array
- I don't know what this does
- This is an unsigned integer
- I don't know what this does
- These 4 bytes have unknown function
- This is an unsigned integer
- I don't know what this does
- These 16 bytes have unknown function
This section holds the palette data. Each palette entry is 4 bytes, and there are "palette size" entries. Note that palette size can be 0 (in which case this section does not exist). Each palette entry is a 32-bit BGRA format color.
-
File Header
- 4 bytes (Version)
- 4 bytes (Unknown 1)
- 4 bytes (Color Key Flag)
- 4 bytes (Unknown 2)
- 4 bytes (Unknown 3)
- 4 bytes (Minimum Number of Bits per Color)
- 4 bytes (Maximum Number of Bits per Color)
- 4 bytes (Minimum Number of Alpha Bits)
- 4 bytes (Maximum Number of Alpha Bits)
- 4 bytes (Minimum Number of Bits per Pixel)
- 4 bytes (Maximum Number of Bits per Pixel)
- 4 bytes (Unknown 4)
- 4 bytes (Number of Palettes)
- 4 bytes (Number of Colors per Palette)
- 4 bytes (Bit Depth)
- 4 bytes (Image Width)
- 4 bytes (Image Height)
- 4 bytes (Number of Bytes per Row)
- 4 bytes (Unknown 5)
- 4 bytes (Palette Flag)
- 4 bytes (Number of Bits per Index)
- 4 bytes (Indexed-to-8bit Flag)
- 4 bytes (Palette Size)
- 4 bytes (Number of Colors per Palette, duplicate)
- 4 bytes (Runtime Data 1)
- 4 bytes (Bits per Pixel)
- 4 bytes (Bytes per Pixel)
-
Pixel Format
- 4 bytes (Number of Red Bits)
- 4 bytes (Number of Green Bits)
- 4 bytes (Number of Blue Bits)
- 4 bytes (Number of Alpha Bits)
- 4 bytes (Number of Red Bitmask)
- 4 bytes (Number of Green Bitmask)
- 4 bytes (Number of Blue Bitmask)
- 4 bytes (Number of Alpha Bitmask)
- 4 bytes (Number of Red Shift)
- 4 bytes (Number of Green Shift)
- 4 bytes (Number of Blue Shift)
- 4 bytes (Number of Alpha Shift)
- 4 bytes (8 - Number of Red Bits)
- 4 bytes (8 - Number of Green Bits)
- 4 bytes (8 - Number of Blue Bits)
- 4 bytes (8 - Number of Alpha Bits)
- 4 bytes (Number of Red Max)
- 4 bytes (Number of Green Max)
- 4 bytes (Number of Blue Max)
- 4 bytes (Number of Alpha Max)
-
File Header 2
- 4 bytes (Color Key Array Flag)
- 4 bytes (Runtime Data 2)
- 4 bytes (Reference Alpha)
- 4 bytes (Runtime Data 3)
- 4 bytes (Unknown 6)
- 4 bytes (Palette Index)
- 8 bytes (Runtime Data 4)
- 16 bytes (Unknown 7)
-
Palette Data
- "Palette Size" Entries
-
Entry 1
- 1 byte (Blue)
- 1 byte (Green)
- 1 byte (Red)
- 1 byte (Alpha)
- ...
-
- Entry "Palette Size"*
- ...
- Entry "Palette Size"*
-
Entry 1
- "Palette Size" Entries
-
Pixel Data
-
"Height" Rows
-
"Width" Columns
- "bytes-per-pixel" bytes (Index in Palette for Pixel Color)
-
"Width" Columns
-
"Height" Rows
Niema Moshiri 2019