PAA File Format: Difference between revisions
m (→Main Format: typo) |
m (→Mipmap data: better worded) |
||
Line 69: | Line 69: | ||
==Mipmap data== | ==Mipmap data== | ||
After end-of-header marker, actual mipmap data follows. Tag | After end-of-header marker, actual mipmap data follows. Tag OFFSTAGG (which is, obviously, a mandatatory tag) contains (up to) 16 offsets. Each offset points to the following struct type (relative to start of the file). | ||
struct Mipmap_Data { | struct Mipmap_Data { | ||
Line 75: | Line 75: | ||
UWORD height; // height of this mipmap | UWORD height; // height of this mipmap | ||
UCHAR size[3]; // size of compressed texture data. this is 24-bit unsigned integer. | UCHAR size[3]; // size of compressed texture data. this is 24-bit unsigned integer. | ||
UCHAR data; | UCHAR data[size]; // actual texture data | ||
}; | }; | ||
Note that | Note that the size reflects the size of data in the file '''not''' the actual size if that data if is compressed. | ||
The size of output data is always | |||
(width*height / 2) | |||
Texture types 0x4444,0x4747,0x1555 and 0x8080 are always stored in compressed format. See [[Pbo_File_Format#Data Compression]] for details. DXT1 textures are stored "as is". | |||
After last mipmap, there are six (6) bytes set to 0x00 to mark end of texture data. | After last mipmap, there are six (6) bytes set to 0x00 to mark end of texture data. |
Revision as of 04:49, 22 November 2006
PAA texture file structure
Introduction
Of the many image file formats 'out there', such as jpeg, such as gif. BI choose to use a specially developed file format (paa) as the base texture file for all engine types.
The reason for this is the raw data within the file can be passed directly to Miscrosft's Direct X as a DCT1 picture without further massaging.
While all engines except Elite also support JPG files, PAA files can result in much better performance.
Main Format
Overall structure of a Paa file is
struct overall { ushort TypeOfPaa; struct HeaderTags {...}; ushort EndofTags; // always zero struct MipMap_DataBlocks{....}; byte EndOfMaps[6]; // always zero };
Every PAA file starts with a TypeOfPaa
ushort TypeOfPaa; // type of texture, known values are // 0xFF01 DXT1 compressed texture (may have 1 bit alpha map, check MSDN documentation for details) // 0x1555 Uncompressed RGBA 5:5:5:1 texture // 0x4444 Uncompressed RGBA 4:4:4:4 texture // 0x4747 Uncompressed Index Palette texture // 0x8080 Uncompressed Luminosity/Alpha map. Actual color of texture is derived from AVGCTAGG tag? // 0xFF05 XBox version only. Most likely DXT5 compressed texture
followed by one or more header tags
struct PAA_Tag { byte name[8]; // name of tag is actually reversed when written in file, // so OFFSTAGG would be written as GGATSFFO. See below for known tags. ULONG tag_size; // size of this tag byte data[tag_size]; // size * bytes of actual data }
followed (obviously) by a EndofTags ushort of zero, indicating, no more tags !!
Known header tags
There are several knowns header tags, of these at least OFFSTAGG is mandatory.
OFFSTAGG This tag has always 16 ULONG entries which contain pointers to actual mipmap data inside file. Note that while 16 offsets are always stored, actual number of mipmaps might be smaller. In this case, offset is marked as 0x00000000. This tag is mandatory.
AVGCTAGG This tag contains average color of texture, probably used in rendering 8:8 luminosity/alpha textures.
FLAGTAGG Marks if texture contains transparency. Value 1 means basic transparency, 2 means alpha channel is not interpolated. This flag should be always present in LOD textures with 1-bit alpha with value of 2 or there will be "ghost outlines" on LOD textures when viewed from distance. Note that this flag must be present in texture file when binarizing model, because Binarize stores information about how to render textures in actual P3D file.
If format not 0x4747 then end of header tag data is marked by UWORD 0x0000, else this is a `size of palette` and next block it`s a palette(sizeof = `size of palette` * 2)
Header tags found in Operation Flashpoint: Elite
Purpose of these headers is not yet known.
MAXCTAGG Contains color of brightest pixel in texture?
SWIZTAGG Found in detail map textures. Seems to always contain 4 bytes of data.
Mipmap data
After end-of-header marker, actual mipmap data follows. Tag OFFSTAGG (which is, obviously, a mandatatory tag) contains (up to) 16 offsets. Each offset points to the following struct type (relative to start of the file).
struct Mipmap_Data { UWORD width; // width of this mipmap UWORD height; // height of this mipmap UCHAR size[3]; // size of compressed texture data. this is 24-bit unsigned integer. UCHAR data[size]; // actual texture data };
Note that the size reflects the size of data in the file not the actual size if that data if is compressed.
The size of output data is always
(width*height / 2)
Texture types 0x4444,0x4747,0x1555 and 0x8080 are always stored in compressed format. See Pbo_File_Format#Data Compression for details. DXT1 textures are stored "as is".
After last mipmap, there are six (6) bytes set to 0x00 to mark end of texture data.
Alpha channel interpolation
These two images visualize difference between alpha channel interpolation (FLAGTAGG header tag value).
FLAGTAGG = 1, interpolated alpha channel (default behaviour)
FLAGTAGG = 2, alpha channel interpolation disabled
Bibliography
Feersum's original posting on BIS forums: Paa/pac texture format documentation MSDN documentation on DXT1 textures: DirectX: Opaque and 1-Bit Alpha Textures