Texture format: Difference between revisions

From Trickstart wiki
No edit summary
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 11: Line 11:
|0x4
|0x4
|0x2
|0x2
|version, set to 2 for .ps2 files, 3 for .pc,  4 for .dc, 5 for .ps2 (w. aplha?)
|version, number 2-5
|-
|-
|0x6
|0x6
Line 34: Line 34:
=== Version 2 (PS2) ===
=== Version 2 (PS2) ===


* Not much is known, other that it's vastly different to PC & DC versions
* Paletted image. Instead of first uncompressed pixel at 0xA it has an unsigned short with number of colours in a palette, then a list of colours (ARGB, 4 bytes per colour), and an uncompressed paletted image (1 byte per pixel)


=== Version 3 (PC) ===
=== Version 3 (PC) ===
Line 50: Line 50:
=== Version 4 (DC) ===
=== Version 4 (DC) ===


* Uses the same compression as version 3, but the resulting files are swizzled for Dreamcast GPU, so untwiddling is needed
* Same as version 3, but the resulting files are swizzled for Dreamcast GPU, so untwiddling is needed


=== Version 5(PS2) ===
=== Version 5 (PS2) ===


* not much is known, might also contain alpha channel data
* Same as version 3, with red and blue channels swapped


=== Unpacked image data (PC and DC) ===
=== Unpacked image data (versions 3-5) ===
Uncompressed image data uses 2 bytes for each pixel, in A1 R5 G5 B5 format. In some places game uses additional file with greyscale alpha channel to compensate for 1bit alpha (5 bits instead of 1).
Uncompressed image data uses 2 bytes for each pixel, in A1 R5 G5 B5 format. In some places game uses additional file with greyscale alpha channel to compensate for 1bit alpha (5 bits instead of 1).

Latest revision as of 17:14, 26 October 2022

Engine supports maximum size of 256x256 pixels. On Windows textures use .pc extension, on Dreamcast they use .DC extension, and on Playstation2 they use .ps2 extension

Offset Size Description
0x0 0x4 Magic, T54 4D 21 1A (TM!\x1A)
0x4 0x2 version, number 2-5
0x6 0x2 width
0x8 0x2 height
0xA 0x2 first pixel
0xC ?? Compressed data, until EOF
  • compressed image data starts at 0xA, see pc_unpack.py for implementation details

Version 2 (PS2)

  • Paletted image. Instead of first uncompressed pixel at 0xA it has an unsigned short with number of colours in a palette, then a list of colours (ARGB, 4 bytes per colour), and an uncompressed paletted image (1 byte per pixel)

Version 3 (PC)

  • Each pixel is written on 2 bytes, little endian, after converting to big endian the algorithm looks like this:
  • If the 15th bit is 1, then stream data as long as each compressed pixel 15th bit is set
    • Else
      • If 14th bit is set copy previously unpacked data
        • bits 11-13 - number of pixels to repeat - 2, so if this number is set to 7, then repeat 9 pixels, minimum 2 pixels
        • bits 0-10 - offset - back head for copying that many pixels
        • else - add transparent pixels
          • bits 0-13 - how many transparent pixels to add
  • 00 00 marks the end of compressed data

Version 4 (DC)

  • Same as version 3, but the resulting files are swizzled for Dreamcast GPU, so untwiddling is needed

Version 5 (PS2)

  • Same as version 3, with red and blue channels swapped

Unpacked image data (versions 3-5)

Uncompressed image data uses 2 bytes for each pixel, in A1 R5 G5 B5 format. In some places game uses additional file with greyscale alpha channel to compensate for 1bit alpha (5 bits instead of 1).