PAA File Format: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
Line 27: Line 27:
  UCHAR data; // size * bytes of actual data
  UCHAR data; // size * bytes of actual data
  }
  }
Source(Open Paa)
ftp://www.armedassault.info/_hosted/rau/flea/Projects/texviewsource.rar
Bin
ftp://www.armedassault.info/_hosted/rau/flea/MyUtils/alternativetexview.rar


[[Image:Paacformat.gif]]
[[Image:Paacformat.gif]]

Revision as of 12:59, 18 November 2006

Template:unsupported-doc

PAA texture file structure

Introduction

PAA is basic texture file format used in OFP and OFP:R. While engine also supports JPG textures, using PAA textures can result in much better performance.

Main Format

PAA texture file consists of type information, one or more "tags" and actual texture and mipmap data.

Every PAA file starts with type information

UWORD	type;	// 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 {
	UCHAR	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
	UCHAR	data; 		// size * bytes of actual data
}

Paacformat.gif

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 OFFSTAG points to start of each mipmap structure 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;		// actual texture data 
};

Note that 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" (width*height/2 bytes).

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)

paa alpha channel default.jpg

FLAGTAGG = 2, alpha channel interpolation disabled

paa alpha channel no interpolation.jpg


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