Try   HackMD

The AGH file format

This is not official documentation. The information in this note has been compiled from my own research and investigation.

Artifact Graphics Hierarchy (.agh) is an image format used by MMO Istaria: Chronicles of the Gifted for the Artifact engine.
It is a container for the .dds image format, used to store textures for DirectX.


Texture types

Istaria's AGH textures come in six different types:

Uncompressed types:

- Type 0 (8bpp, L)

This type uses a single byte per pixel, which stores Luminance. This allows a grayscale texture.

- Type 3 (16bpp, AL)

This type uses two bytes per pixel, which store Alpha and Luminance. This allows a grayscale texture with transparency.

- Type 5 (24bpp, RGB)

This type uses three bytes per pixel, which store Rred, Green, and Blue. This allows a colored texture.

- Type 7 (32bpp, RGBA)

This type uses four bytes per pixel, which store Red, Green, Blue, and Alpha. This allows a colored texture with transparency.

Compressed types:

- Type 14 (DXT1)

This type is identical to type 7, but it has been compressed with BC1 compression. This type is deprecated.

- Type 15 (DXT3)

This type is identical to type 7, but it has been compressed with BC2 compression. Textures generated with /aghdds are of this type.


AGH file structure

[AGH Header] - 128 bytes
[DDS Header] (if compressed) - 128 bytes
[Image]

[AGH Header] structure

Dword Empty: 00 00 00 00
[TYPE Dword] 
Dword Width: The width of the texture.
Dword Height: The height of the texture.
Dword Mipmap Count: The number of mipmaps, including the original texture.
[Color Dword]
Dword Size of texture: The number of bytes describing the texture, including the surrounding [TYPE Dword] and [AGH Marker]
Dword Size of largest mipmap: Same as above, but for the largest mipmap
Dword Size of next largest mipmap
...
Dword Size of smallest mipmap
... (empty)
Dword Compressed: 10 00 00 00 if compressed, otherwise empty
9 * Dword Empty: 00 00 00 00

[TYPE Dword]:

This dword stores the type of texture:

Uncompressed:
00 00 00 00: Type 0 (8bpp)
03 00 00 00: Type 3 (16bpp)
05 00 00 00: Type 5 (24bpp)
07 00 00 00: Type 7 (32bpp)

Compressed:
0E 00 00 00: Type 14 (DXT1)
0F 00 00 00: Type 15 (DXT3)

[Color Dword]:

While the texture is being loaded, this ABGR color is displayed as a placeholder.
It represents the ABGR value of a pixel on the left edge of the image. The exact location of this pixel varies depending on the image size. In images of 32x, 64x, 128x, and 256x respectively, it is located at the appropriate white pixel shown here:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Istaria's default file conversions leave this dword empty if the file has mipmaps, but it can safely be set to any desired value.

[Image] structure

Istaria reads textures upside-down. All image data in an .agh is flipped vertically from its original image.

Non mipmapped:
[TYPE Dword] - 4 bytes
[Image data]
[AGH Marker] - 4 bytes
Mipmapped:
[TYPE Dword] - 4 bytes
[Smallest mipmap]
[AGH Marker] - 4 bytes
[TYPE Dword] - 4 bytes
[Next smallest mipmap]
[AGH Marker] - 4 bytes
...
[TYPE Dword] - 4 bytes
[Largest mipmap]
[AGH Marker] - 4 bytes
[TYPE Dword] - 4 bytes
[Image data]
[AGH Marker] - 4 bytes

[AGH Marker]:

This dword is always the following, for any agh file:
DE EE ED DE


Comparison to DDS files

[DDS Header] - 128 bytes
[Image]

[Image] structure

Non mipmapped:
[Image data]
Mipmapped:
[Image data]
[Largest mipmap]
[Next largest mipmap]
...
[Smallest mipmap]

References and further reading