Material (.MAT) Files are used to store texture information in Jedi Knight and Mysteries of the Sith. There are several different types of texture that can be stored in .MAT files.


MAT2 files are used by the original Sith Engine. They can support 8-bit textures that reference an external palette, 16-bit textures and 16-bit textures with an optional transparent bit, as well as single solid colors. MAT2 files can contain multiple frames.

Texture Format Outline:


For each MATHEADER.MatRecordCount

For each MATHEADER.MatRecordCount
	Followed by bitmap data for the texture, followed by bitmap data for each mipmap

Color Format Outline:


For each MATHEADER.MatRecordCount

The following example structures are taken from the Sith 2 Project:

	char Magic[4];				// Must/should be 'MAT '
	__int32 Version;			// Should be 0x20, 0x32 for 16-bit

	__int32 Type;				// 0 = color, 1 = ?, 2 = texture
	__int32 MatRecordCount;		// Number of MAT records
	__int32 TextureCount;		// Number of textures

	// Surface format should be built from the below values:
	__int32 Transparency;          // Unknown (perhaps transparency?)
                                                // In Infernal Machine MATs, this is usually 1,
                                                // even for non-transparent MATs. IM MATs
                                                // with ARGB4444 format seem to have it as 2.
                                                // Not recommended to be used for determing transparency.

	__int32 Bitdepth;			// Number of bits per pixel, valid formats: 8 (converted), 16, 32

	__int32 BlueBits;			// 0, 5, 8
	__int32 GreenBits;			// 0, 6 (16-bit 565), 5 (16-bit 1555), 8
	__int32 RedBits;			// 0, 5, 8

        // The shift offset for the location of the R, G and B color values
        // in the bitmap data. The color data is extracted by shifting
        // the opposite direction of these values.
	__int32 RedShl;                  // 11 for RGB565, 10 for ARGB1555
	__int32 GreenShl;                // 5
	__int32 BlueShl;                 // 0

        // The amount to shift the extracted color values to expand them from
        // 5 or 6 bit values to 8 bit values. Unsure if JK actually uses these.
	__int32 RedShr;                 // 3
	__int32 GreenShr;               // 2
	__int32 BlueShr;                // 3

	__int32 Unknown1;
	__int32 Unknown2;
	__int32 Unknown3;

	__int32 RecordType;			// 0 = color, 8 = texture
	__int32 TransparentColor;	// if 16-bit or 32-bit, RGB. If 8-bit, palette offset
	__int32 Unknown1;			// Padding, most likely
	__int32 Unknown2;			// More padding
	__int32 Unknown3;			// Yet more padding

	__int32 Unknown4;			// Further padding

	__int32 Unknown5;
	__int32 Unknown6;
	__int32 Unknown7;
	__int32 Unknown8;

	__int32 SizeX;
	__int32 SizeY;
	__int32 TransparentBool;	// Use transparency? std bool, 0 = false, !0 = true
	__int32 Unknown1;
	__int32 Unknown2;

	__int32 MipmapCount;		// Ignored; using hardware mipmapping

	__int32 RecordType; // 0
	__int32 ColorNum; // index into palette
	float Unknown1;
	float Unknown2;
	float Unknown3;
	float Unknown4;

MAT3 Files

MAT3 files are an extended metafile format used by Sith 2 for storing more advanced textures. They support 32-bit textures with alpha channels in addition to specular, relief, photoemissive and skin color information. They also support dynamic effects through embedded COG Scripts.

Texture Format Outline:

char Magic[4];				// Must/should be 'MAT '
__int32 Version;			// Should be 0x30
float x_scale;
float y_scale;
int seqcount;				// Number of frames

for each seqcount
	int metacount;			// Number of layers

	for each metacount
		char meta[32];		// Layer name/properties
		int chunksize;
		BYTE chunk[chunksize];	// Raw data.  A COG file for "script"s, and a DDS file for other types.

Valid meta types currently include "diffuse", "gloss", "bump", and "script". There may only be one "script" per MAT3 file.

You can download a MAT3 assembler/disassembler here.

  • Create:
This page was last modified 00:45, 30 April 2012.   This page has been accessed 4,811 times.