WoW:BLP file: Difference between revisions

5 bytes removed ,  19 January 2009
m
WW:MOS; cleanup
m (WW:MOS; cleanup)
Line 1: Line 1:
{{uitech}}
{{uitech}}
'''BLPs''' are Blizzard's texture format, used for many games. World of Warcraft uses the BLP2 format in particular. The BLP file structure consists of a header, up to 16 mipmaps of the texture, and a palette. Texture sizes must be powers of two, though the two dimensions do not have to be equal; 512x256 is valid, but 512x200 is not. The first mipmap (mipmap #0) is the full size image; each subsequent mipmap halves both dimensions. The final mipmap should be 1x1.
 
'''BLP files''' are Blizzard's texture format, used for many games. ''World of Warcraft'' uses the BLP2 format in particular. The BLP file structure consists of a header, up to 16 mipmaps of the texture, and a palette. Texture sizes must be powers of two, though the two dimensions do not have to be equal; 512x256 is valid, but 512x200 is not. The first mipmap (mipmap #0) is the full size image; each subsequent mipmap halves both dimensions. The final mipmap should be 1x1.


=== The .BLP header ===
=== The .BLP header ===
  struct blp2header {
  struct blp2header {
   uint8_t    ident[4];          // "BLP2" magic number
   uint8_t    ident[4];          // "BLP2" magic number
Line 17: Line 17:
  } blp2header;
  } blp2header;


World of Warcraft does not use JPG textures. A discussion of BLP files using JPG compression is beyond the scope of this article. The type flag should always be 1, which indicates the use of either RAW, DXT1, DXT3 or DXT5 compression. Each compression type will be covered separately.
''World of Warcraft'' does not use JPG textures. A discussion of BLP files using JPG compression is beyond the scope of this article. The type flag should always be 1, which indicates the use of either RAW, DXT1, DXT3, or DXT5 compression. Each compression type will be covered separately.


=== The .BLP color palette ===
=== The .BLP color palette ===
 
The header is always followed by a 256-entry color table.  Each entry a 32-bit ARGB 8888 value. This table is only used for RAW images, but is present in all BLPs regardless.
The header is always followed by a 256-entry color table.  Each entry a 32-bit ARGB 8888 value. This table is only used for RAW images, but is present in all BLPs regardless.


=== RAW compression ===
=== RAW compression ===
 
If the <tt>compression</tt> flag is 1, each mipmap is stored as an array of 8-bit values, one per pixel, left to right, top to bottom. Each value is an index to the palette. This is by far the simplest format.
If the <tt>compression</tt> flag is 1, each mipmap is stored as an array of 8-bit values, one per pixel, left to right, top to bottom. Each value is an index to the palette. This is by far the simplest format.


=== DXT1 compression ===
=== DXT1 compression ===
 
If the <tt>compression</tt> flag is 2, all mipmaps are stored using one of DXT1, DXT3, or DXT5. DXT1 offers either no alpha or 1-bit alpha, and so if the <tt>alpha_bits</tt> value is 0 or 1, the mipmap data will be stored as DXT1.  See [[Wikipedia:S3TC|Wikipedia's entry on DXT compression]] for the technical details.
If the <tt>compression</tt> flag is 2, all mipmaps are stored using one of DXT1, DXT3 or DXT5. DXT1 offers either no alpha or 1-bit alpha, and so if the <tt>alpha_bits</tt> value is 0 or 1, the mipmap data will be stored as DXT1.  See [[Wikipedia:S3TC|Wikipedia's entry on DXT compression]] for the technical details.


=== DXT3 compression ===
=== DXT3 compression ===
 
If the <tt>alpha_bits</tt> value is 8, the mipmap data may be in either a DXT3 or DXT5 format. DXT3 alpha data is stored as 4 bits per pixel; DXT3 is identified by an <tt>alpha_type</tt> value of 0, 1, or 8. Again, see [[Wikipedia:S3TC|Wikipedia's entry on DXT compression]] for the technical details.
If the <tt>alpha_bits</tt> value is 8, the mipmap data may be in either a DXT3 or DXT5 format. DXT3 alpha data is stored as 4 bits per pixel; DXT3 is identified by an <tt>alpha_type</tt> value of 0, 1 or 8. Again, see [[Wikipedia:S3TC|Wikipedia's entry on DXT compression]] for the technical details.


=== DXT5 compression ===
=== DXT5 compression ===
 
If the <tt>alpha_type</tt> value is 7, the mipmap data is in DXT5 format. This format was first used for Burning Crusade images. [[Wikipedia:S3TC|Wikipedia's entry on DXT compression]] has the goods again.
If the <tt>alpha_type</tt> value is 7, the mipmap data is in DXT5 format. This format was first used for Burning Crusade images. [[Wikipedia:S3TC|Wikipedia's entry on DXT compression]] has the goods again.


=== DXT2 and DXT4 ===
=== DXT2 and DXT4 ===
 
DXT2 and DXT4 are identical to DXT3 and DXT5, respectively, save that pixel data winds up being premultiplied by alpha that is, each RGBA pixel is not represented by (r, g, b, a) but instead by (ar, ag, ab, a) where all values are normalised to lie between 0 and 1. ''World of Warcraft'' does not use these formats.
DXT2 and DXT4 are identical to DXT3 and DXT5, respectively, save that pixel data winds up being premultiplied by alpha -- that is, each RGBA pixel is not represented by (r, g, b, a) but instead by (ar, ag, ab, a) where all values are normalised to lie between 0 and 1. World of Warcraft does not use these formats.


=== Sample Files ===
=== Sample Files ===
Line 59: Line 53:


=== Conversion Tools ===
=== Conversion Tools ===
 
There exist BLP tools to convert both from and to the BLP format. They can be found in the UI Authors resource list: http://www.wowwiki.com/UI_FAQ/AddOn_Author_Resources#Resources
There exist BLP tools to convert both from and to the BLP format. They can be found in the UI Authors resource list: http://www.wowwiki.com/UI_FAQ/AddOn_Author_Resources#Resources
Anonymous user