Difference between revisions of "FF7/TEX format"
my_wiki>Aali |
m (9 revisions imported) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | == TEX Texture Data Format for PC by [[User:Mirex|Mirex]] (Edits by [[User:Aali|Aali]]) == | + | == TEX Texture Data Format for PC by [[User:Mirex|Mirex]] (Edits by [[User:Aali|Aali]]) == |
FF7 PC texture consists of header, an optional palette and bitmap data. Usually data are stored like palletized picture, with bitmap pixels referencing to palette. Color 0 (in palette its usually black) is usually used as transparent color. | FF7 PC texture consists of header, an optional palette and bitmap data. Usually data are stored like palletized picture, with bitmap pixels referencing to palette. Color 0 (in palette its usually black) is usually used as transparent color. | ||
Line 9: | Line 9: | ||
''The tex format is actually very flexible and can take almost any non-paletted format as long as you describe it properly in the header.'' | ''The tex format is actually very flexible and can take almost any non-paletted format as long as you describe it properly in the header.'' | ||
− | + | {| style="margin-bottom: 0px" | |
− | + | ! style="border: 1px solid black; vertical-align: middle; width: 51px; height: 26px; background-color: rgb(230, 230, 230)" | Offset | |
− | + | ! style="border: 1px solid black; vertical-align: middle; width: 126px; height: 26px; background-color: rgb(230, 230, 230)" | Size | |
− | Offset | + | ! style="border: 1px solid black; vertical-align: middle; width: 222px; height: 26px; background-color: rgb(230, 230, 230)" | Description |
− | + | |- | |
− | Size | + | | style="border-style: solid none solid solid; border-color: black; border-width: 1px; vertical-align: top" | |
− | + | | style="border-style: solid solid solid none; border-color: black; border-width: 1px" colspan="2" | Header | |
− | Description | + | |- |
− | + | | style="border: 1px solid black" | 0x00 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Version, must be 1, or FF7 won't load the file | |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0x04 | |
− | Header | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Unknown | |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0x08 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | 0x00 | + | | style="border: 1px solid black" | Color key flag |
− | + | |- | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | 0x0C |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | Version, must be 1, or FF7 won't load the file | + | | style="border: 1px solid black" | Unknown |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0x10 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Unknown | |
− | 0x04 | + | |- |
− | + | | style="border: 1px solid black" | 0x14 | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Minimum bits per color (D3D driver uses these to determine which texture format to convert to on load) | |
− | Unknown | + | |- |
− | + | | style="border: 1px solid black" | 0x18 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Maximum bits per color | |
− | + | |- | |
− | 0x08 | + | | style="border: 1px solid black" | 0x1C |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | Minimum alpha bits |
− | + | |- | |
− | Color key flag | + | | style="border: 1px solid black" | 0x20 |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Maximum alpha bits | |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0x24 | |
− | 0x0C | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Minimum bits per pixel | |
− | 4 bytes (long) | + | |- |
− | + | | style="border: 1px solid black" | 0x28 | |
− | Unknown | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Maximum bits per pixel | |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0x2C | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | 0x10 | + | | style="border: 1px solid black" | Unknown |
− | + | |- | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | 0x30 |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | Unknown | + | | style="border: 1px solid black" | Number of palettes |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0x34 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Number of colors per palette | |
− | 0x14 | + | |- |
− | + | | style="border: 1px solid black" | 0x38 | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Bit depth | |
− | Minimum bits per color (D3D driver uses these to determine which texture format to convert to on load) | + | |- |
− | + | | style="border: 1px solid black" | 0x3C | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Image Width | |
− | + | |- | |
− | 0x18 | + | | style="border: 1px solid black" | 0x40 |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | Image Height |
− | + | |- | |
− | Maximum bits per color | + | | style="border: 1px solid black" | 0x44 |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Pitch or bytes per row, usually ignored and assumed to be bytes per pixel * width | |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0x48 | |
− | 0x1C | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Unknown | |
− | 4 bytes (long) | + | |- |
− | + | | style="border: 1px solid black" | 0x4C | |
− | Minimum alpha bits | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Palette flag (this indicates the presence of a palette) | |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0x50 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | 0x20 | + | | style="border: 1px solid black" | Bits per index, always 0 for non-paletted images |
− | + | |- | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | 0x54 |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | Maximum alpha bits | + | | style="border: 1px solid black" | Indexed-to-8bit flag, never used in FF7 |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0x58 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Palette size, always number of palettes * colors per palette | |
− | 0x24 | + | |- |
− | + | | style="border: 1px solid black" | 0x5C | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Number of colors per palette (again, may be 0 sometimes, the other value will be used anyway) | |
− | Minimum bits per pixel | + | |- |
− | + | | style="border: 1px solid black" | 0x60 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Runtime data, ignored on load | |
− | + | |- | |
− | 0x28 | + | | style="border: 1px solid black" | 0x64 |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | Bits per pixel |
− | + | |- | |
− | Maximum bits per pixel | + | | style="border: 1px solid black" | 0x68 |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Bytes per pixel, always use this to determine how much data to read, if this is 1 you read 1 byte per pixel, regardless of bit depth | |
− | + | |- | |
− | + | | style="border-style: solid none solid solid; border-color: black; border-width: 1px; vertical-align: top" | | |
− | 0x2C | + | | style="border-style: solid solid solid none; border-color: black; border-width: 1px" colspan="2" | Pixel format (all 0 for paletted images) |
− | + | |- | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | 0x6C |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | Unknown | + | | style="border: 1px solid black" | Number of red bits |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0x70 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Number of green bits | |
− | 0x30 | + | |- |
− | + | | style="border: 1px solid black" | 0x74 | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Number of blue bits | |
− | Number of palettes | + | |- |
− | + | | style="border: 1px solid black" | 0x78 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Number of alpha bits | |
− | + | |- | |
− | 0x34 | + | | style="border: 1px solid black" | 0x7C |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | Red bitmask |
− | + | |- | |
− | Number of colors per palette | + | | style="border: 1px solid black" | 0x80 |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Green bitmask | |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0x84 | |
− | 0x38 | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Blue bitmask | |
− | 4 bytes (long) | + | |- |
− | + | | style="border: 1px solid black" | 0x88 | |
− | Bit depth | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Alpha bitmask | |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0x8C | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | 0x3C | + | | style="border: 1px solid black" | Red shift |
− | + | |- | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | 0x90 |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | Image Width | + | | style="border: 1px solid black" | Green shift |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0x94 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Blue shift | |
− | 0x40 | + | |- |
− | + | | style="border: 1px solid black" | 0x98 | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Alpha shift | |
− | Image Height | + | |- |
− | + | | style="border: 1px solid black" | 0x9C | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Always 8 - Number of red bits (Not sure what the point of these fields is, they're always ignored anyway) | |
− | + | |- | |
− | 0x44 | + | | style="border: 1px solid black" | 0xA0 |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | 8 - Number of green bits |
− | + | |- | |
− | Pitch or bytes per row, usually ignored and assumed to be bytes per pixel * width | + | | style="border: 1px solid black" | 0xA4 |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | 8 - Number of blue bits | |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0xA8 | |
− | 0x48 | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | 8 - Number of alpha bits | |
− | 4 bytes (long) | + | |- |
− | + | | style="border: 1px solid black" | 0xAC | |
− | Unknown | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Red max | |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0xB0 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | 0x4C | + | | style="border: 1px solid black" | Green max |
− | + | |- | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | 0xB4 |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | Palette flag (this indicates the presence of a palette) | + | | style="border: 1px solid black" | Blue max |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0xB8 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Alpha max | |
− | 0x50 | + | |- |
− | + | | style="border-style: solid none solid solid; border-color: black; border-width: 1px; vertical-align: top" | | |
− | 4 bytes (long) | + | | style="border-style: solid solid solid none; border-color: black; border-width: 1px" colspan="2" | End of pixel format |
− | + | |- | |
− | Bits per index, always 0 for non-paletted images | + | | style="border: 1px solid black" | 0xBC |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Color key array flag (this indicates the presence of a color key array) | |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0xC0 | |
− | 0x54 | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Runtime data | |
− | 4 bytes (long) | + | |- |
− | + | | style="border: 1px solid black" | 0xC4 | |
− | Indexed-to-8bit flag, never used in FF7 | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Reference alpha (more on this later) | |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0xC8 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | 0x58 | + | | style="border: 1px solid black" | Runtime data |
− | + | |- | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | 0xCC |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | Palette size, always number of palettes * colors per palette | + | | style="border: 1px solid black" | Unknown |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0xD0 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Palette index (runtime data) | |
− | 0x5C | + | |- |
− | + | | style="border: 1px solid black" | 0xD4 | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Runtime data | |
− | Number of colors per palette (again, may be 0 sometimes, the other value will be used anyway) | + | |- |
− | + | | style="border: 1px solid black" | 0xD8 | |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Runtime data | |
− | + | |- | |
− | 0x60 | + | | style="border: 1px solid black" | 0xDC |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | 4 bytes (long) | + | | style="border: 1px solid black" | Unknown |
− | + | |- | |
− | Runtime data, ignored on load | + | | style="border: 1px solid black" | 0xE0 |
− | + | | style="border: 1px solid black" | 4 bytes (long) | |
− | + | | style="border: 1px solid black" | Unknown | |
− | + | |- | |
− | + | | style="border: 1px solid black" | 0xE4 | |
− | 0x64 | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Unknown | |
− | 4 bytes (long) | + | |- |
− | + | | style="border: 1px solid black" | 0xE8 | |
− | Bits per pixel | + | | style="border: 1px solid black" | 4 bytes (long) |
− | + | | style="border: 1px solid black" | Unknown | |
− | + | |- | |
− | + | | style="border-style: solid none solid solid; border-color: black; border-width: 1px; vertical-align: top" | | |
− | + | | style="border-style: solid solid solid none; border-color: black; border-width: 1px" colspan="2" | Palette data (ignore this section if palette flag is 0) | |
− | 0x68 | + | |- |
− | + | | style="border: 1px solid black; vertical-align: top" | 0xEC | |
− | 4 bytes (long) | + | | style="border: 1px solid black; vertical-align: top" | Palette size * 4 |
− | + | | style="border: 1px solid black; vertical-align: top" | The raw palette data, always in 32-bit BGRA format | |
− | Bytes per pixel, always use this to determine how much data to read, if this is 1 you read 1 byte per pixel, regardless of bit depth | + | |- |
− | + | | style="border-style: solid none solid solid; border-color: black; border-width: 1px; vertical-align: top" | | |
− | + | | style="border-style: solid solid solid none; border-color: black; border-width: 1px" colspan="2" | Pixel data | |
− | + | |- | |
− | + | | style="border: 1px solid black; vertical-align: top" | Varies | |
− | + | | style="border: 1px solid black; vertical-align: top" colspan="2" | Read width * height * "bytes per pixel" bytes of data. If there's a palette, every pixel is an index into that palette, otherwise use the pixel format specification. | |
− | Pixel format (all 0 for paletted images) | + | |- |
− | + | | style="border-style: solid none solid solid; border-color: black; border-width: 1px; vertical-align: top" | | |
− | + | | style="border-style: solid solid solid none; border-color: black; border-width: 1px" colspan="2" | Color key array | |
− | + | |- | |
− | + | | style="border: 1px solid black; vertical-align: top" | Varies | |
− | 0x6C | + | | style="border: 1px solid black; vertical-align: top" colspan="2" | |
− | |||
− | 4 bytes (long) | ||
− | |||
− | Number of red bits | ||
− | |||
− | |||
− | |||
− | |||
− | 0x70 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Number of green bits | ||
− | |||
− | |||
− | |||
− | |||
− | 0x74 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Number of blue bits | ||
− | |||
− | |||
− | |||
− | |||
− | 0x78 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Number of alpha bits | ||
− | |||
− | |||
− | |||
− | |||
− | 0x7C | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Red bitmask | ||
− | |||
− | |||
− | |||
− | |||
− | 0x80 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Green bitmask | ||
− | |||
− | |||
− | |||
− | |||
− | 0x84 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Blue bitmask | ||
− | |||
− | |||
− | |||
− | |||
− | 0x88 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Alpha bitmask | ||
− | |||
− | |||
− | |||
− | |||
− | 0x8C | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Red shift | ||
− | |||
− | |||
− | |||
− | |||
− | 0x90 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Green shift | ||
− | |||
− | |||
− | |||
− | |||
− | 0x94 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Blue shift | ||
− | |||
− | |||
− | |||
− | |||
− | 0x98 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Alpha shift | ||
− | |||
− | |||
− | |||
− | |||
− | 0x9C | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Always 8 - Number of red bits (Not sure what the point of these fields is, they're always ignored anyway) | ||
− | |||
− | |||
− | |||
− | |||
− | 0xA0 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | 8 - Number of green bits | ||
− | |||
− | |||
− | |||
− | |||
− | 0xA4 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | 8 - Number of blue bits | ||
− | |||
− | |||
− | |||
− | |||
− | 0xA8 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | 8 - Number of alpha bits | ||
− | |||
− | |||
− | |||
− | |||
− | 0xAC | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Red max | ||
− | |||
− | |||
− | |||
− | |||
− | 0xB0 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Green max | ||
− | |||
− | |||
− | |||
− | |||
− | 0xB4 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Blue max | ||
− | |||
− | |||
− | |||
− | |||
− | 0xB8 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Alpha max | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | End of pixel format | ||
− | |||
− | |||
− | |||
− | |||
− | 0xBC | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Color key array flag (this indicates the presence of a color key array) | ||
− | |||
− | |||
− | |||
− | |||
− | 0xC0 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Runtime data | ||
− | |||
− | |||
− | |||
− | |||
− | 0xC4 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Reference alpha (more on this later) | ||
− | |||
− | |||
− | |||
− | |||
− | 0xC8 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Runtime data | ||
− | |||
− | |||
− | |||
− | |||
− | 0xCC | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Unknown | ||
− | |||
− | |||
− | |||
− | |||
− | 0xD0 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Palette index (runtime data) | ||
− | |||
− | |||
− | |||
− | |||
− | 0xD4 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Runtime data | ||
− | |||
− | |||
− | |||
− | |||
− | 0xD8 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Runtime data | ||
− | |||
− | |||
− | |||
− | |||
− | 0xDC | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Unknown | ||
− | |||
− | |||
− | |||
− | |||
− | 0xE0 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Unknown | ||
− | |||
− | |||
− | |||
− | |||
− | 0xE4 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Unknown | ||
− | |||
− | |||
− | |||
− | |||
− | 0xE8 | ||
− | |||
− | 4 bytes (long) | ||
− | |||
− | Unknown | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | Palette data (ignore this section if palette flag is 0) | ||
− | |||
− | |||
− | |||
− | |||
− | 0xEC | ||
− | |||
− | Palette size * 4 | ||
− | |||
− | The raw palette data, always in 32-bit BGRA format | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | Pixel data | ||
− | |||
− | |||
− | |||
− | |||
− | Varies | ||
− | |||
− | Read width * height * "bytes per pixel" bytes of data. If there's a palette, every pixel is an index into that palette, otherwise use the pixel format specification. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | Color key array | ||
− | |||
− | |||
− | |||
− | |||
− | Varies | ||
− | |||
Number of palettes * 1 bytes. | Number of palettes * 1 bytes. | ||
− | + | |} | |
− | |||
− | |||
− | ''Color keying: If the color key flag is zero, no color keying is performed and the color key array is ignored. Otherwise, the current palette index is used to retrieve a single byte from the color key array, this is the new color key flag, zero means don't do color keying. | + | ''Color keying: If the color key flag is zero, no color keying is performed and the color key array is ignored. Otherwise, the current palette index is used to retrieve a single byte from the color key array, this is the new color key flag, zero means don't do color keying.'' If there is no color key array (and the color key flag is not zero), you should always color key. |
− | If there is no color key array (and the color key flag is not zero), you should always color key. | ||
''Reference alpha: Only applies to paletted images, if the alpha value sampled from the palette is 0xFE, this value should be replaced with the reference alpha.'' | ''Reference alpha: Only applies to paletted images, if the alpha value sampled from the palette is 0xFE, this value should be replaced with the reference alpha.'' |
Latest revision as of 05:20, 23 May 2019
TEX Texture Data Format for PC by Mirex (Edits by Aali)
FF7 PC texture consists of header, an optional palette and bitmap data. Usually data are stored like palletized picture, with bitmap pixels referencing to palette. Color 0 (in palette its usually black) is usually used as transparent color.
Pixel values of 0 may or may not be transparent, depending on the color key status, more on that later. This also applies to non-paletted formats.
When bit depth is 16 then data are stored as packed RGB in style RGB555, which means 5 bits per color in one 2 byte entry. I'm not sure if it is used in FF7 at all, its probably used in FF8.
The tex format is actually very flexible and can take almost any non-paletted format as long as you describe it properly in the header.
Offset | Size | Description |
---|---|---|
Header | ||
0x00 | 4 bytes (long) | Version, must be 1, or FF7 won't load the file |
0x04 | 4 bytes (long) | Unknown |
0x08 | 4 bytes (long) | Color key flag |
0x0C | 4 bytes (long) | Unknown |
0x10 | 4 bytes (long) | Unknown |
0x14 | 4 bytes (long) | Minimum bits per color (D3D driver uses these to determine which texture format to convert to on load) |
0x18 | 4 bytes (long) | Maximum bits per color |
0x1C | 4 bytes (long) | Minimum alpha bits |
0x20 | 4 bytes (long) | Maximum alpha bits |
0x24 | 4 bytes (long) | Minimum bits per pixel |
0x28 | 4 bytes (long) | Maximum bits per pixel |
0x2C | 4 bytes (long) | Unknown |
0x30 | 4 bytes (long) | Number of palettes |
0x34 | 4 bytes (long) | Number of colors per palette |
0x38 | 4 bytes (long) | Bit depth |
0x3C | 4 bytes (long) | Image Width |
0x40 | 4 bytes (long) | Image Height |
0x44 | 4 bytes (long) | Pitch or bytes per row, usually ignored and assumed to be bytes per pixel * width |
0x48 | 4 bytes (long) | Unknown |
0x4C | 4 bytes (long) | Palette flag (this indicates the presence of a palette) |
0x50 | 4 bytes (long) | Bits per index, always 0 for non-paletted images |
0x54 | 4 bytes (long) | Indexed-to-8bit flag, never used in FF7 |
0x58 | 4 bytes (long) | Palette size, always number of palettes * colors per palette |
0x5C | 4 bytes (long) | Number of colors per palette (again, may be 0 sometimes, the other value will be used anyway) |
0x60 | 4 bytes (long) | Runtime data, ignored on load |
0x64 | 4 bytes (long) | Bits per pixel |
0x68 | 4 bytes (long) | Bytes per pixel, always use this to determine how much data to read, if this is 1 you read 1 byte per pixel, regardless of bit depth |
Pixel format (all 0 for paletted images) | ||
0x6C | 4 bytes (long) | Number of red bits |
0x70 | 4 bytes (long) | Number of green bits |
0x74 | 4 bytes (long) | Number of blue bits |
0x78 | 4 bytes (long) | Number of alpha bits |
0x7C | 4 bytes (long) | Red bitmask |
0x80 | 4 bytes (long) | Green bitmask |
0x84 | 4 bytes (long) | Blue bitmask |
0x88 | 4 bytes (long) | Alpha bitmask |
0x8C | 4 bytes (long) | Red shift |
0x90 | 4 bytes (long) | Green shift |
0x94 | 4 bytes (long) | Blue shift |
0x98 | 4 bytes (long) | Alpha shift |
0x9C | 4 bytes (long) | Always 8 - Number of red bits (Not sure what the point of these fields is, they're always ignored anyway) |
0xA0 | 4 bytes (long) | 8 - Number of green bits |
0xA4 | 4 bytes (long) | 8 - Number of blue bits |
0xA8 | 4 bytes (long) | 8 - Number of alpha bits |
0xAC | 4 bytes (long) | Red max |
0xB0 | 4 bytes (long) | Green max |
0xB4 | 4 bytes (long) | Blue max |
0xB8 | 4 bytes (long) | Alpha max |
End of pixel format | ||
0xBC | 4 bytes (long) | Color key array flag (this indicates the presence of a color key array) |
0xC0 | 4 bytes (long) | Runtime data |
0xC4 | 4 bytes (long) | Reference alpha (more on this later) |
0xC8 | 4 bytes (long) | Runtime data |
0xCC | 4 bytes (long) | Unknown |
0xD0 | 4 bytes (long) | Palette index (runtime data) |
0xD4 | 4 bytes (long) | Runtime data |
0xD8 | 4 bytes (long) | Runtime data |
0xDC | 4 bytes (long) | Unknown |
0xE0 | 4 bytes (long) | Unknown |
0xE4 | 4 bytes (long) | Unknown |
0xE8 | 4 bytes (long) | Unknown |
Palette data (ignore this section if palette flag is 0) | ||
0xEC | Palette size * 4 | The raw palette data, always in 32-bit BGRA format |
Pixel data | ||
Varies | Read width * height * "bytes per pixel" bytes of data. If there's a palette, every pixel is an index into that palette, otherwise use the pixel format specification. | |
Color key array | ||
Varies |
Number of palettes * 1 bytes. |
Color keying: If the color key flag is zero, no color keying is performed and the color key array is ignored. Otherwise, the current palette index is used to retrieve a single byte from the color key array, this is the new color key flag, zero means don't do color keying. If there is no color key array (and the color key flag is not zero), you should always color key.
Reference alpha: Only applies to paletted images, if the alpha value sampled from the palette is 0xFE, this value should be replaced with the reference alpha.