Skip to content

TEX Format

Niema Moshiri edited this page May 27, 2019 · 17 revisions

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 help decode the format.

Section 1: File Header

A TEX file's header gives general information about the TEX file.

4 bytes: Version

  • This is an unsigned integer and must always equal 1 for Final Fantasy VII to load

4 bytes: Unknown 1

  • These 4 bytes have unknown function

4 bytes: Color Key Flag

  • 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

4 bytes: Unknown 2

  • These 4 bytes have unknown function

4 bytes: Unknown 3

  • These 4 bytes have unknown function

4 bytes: Minimum Number of Bits per Color

  • This is an unsigned integer
  • The D3D driver uses this to determine which texture format to convert to on load

4 bytes: Maximum Number of Bits per Color

  • This is an unsigned integer

4 bytes: Minimum Number of Alpha Bits

  • This is an unsigned integer

4 bytes: Maximum Number of Alpha Bits

  • This is an unsigned integer

4 bytes: Minimum Number of Bits per Pixel

  • This is an unsigned integer

4 bytes: Maximum Number of Bits per Pixel

  • This is an unsigned integer

4 bytes: Unknown 4

  • These 4 bytes have unknown function

4 bytes: Number of Palettes

  • This is an unsigned integer

4 bytes: Number of Colors per Palette

  • This is an unsigned integer

4 bytes: Bit Depth

  • This is an unsigned integer

4 bytes: Image Width

  • This is an unsigned integer

4 bytes: Image Height

  • This is an unsigned integer

4 bytes: Number of Bytes per Row

  • 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

4 bytes: Unknown 5

  • These 4 bytes have unknown function

4 bytes: Palette Flag

  • This is an unsigned integer
  • This indicates the presence of a palette
  • All the **ac files have 0 for this

4 bytes: Number of Bits per Index

  • This is an unsigned integer
  • This is always 0 for non-paletted images
  • All the **ac files have 1 for this

4 bytes: Number of Colors per Palette (duplicate)

  • This is an unsigned integer
  • The first instance will be used anyways
  • All the **ac files have 8 for this

4 bytes: Runtime Data

  • This is ignored on load
  • All the **ac files have 0 for this

4 bytes: Bits per Pixel

  • This is an unsigned integer
  • All the **ac files have 0 for this

4 bytes: Bytes per Pixel

  • 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