# 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](https://docs.microsoft.com/en-us/windows/win32/direct3ddds/dx-graphics-dds-pguide), 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 **L**uminance. This allows a grayscale texture. ##### - Type 3 (16bpp, **AL**) This type uses two bytes per pixel, which store **A**lpha and **L**uminance. This allows a grayscale texture with transparency. ##### - Type 5 (24bpp, **RGB**) This type uses three bytes per pixel, which store **R**red, **G**reen, and **B**lue. This allows a colored texture. ##### - Type 7 (32bpp, **RGBA**) This type uses four bytes per pixel, which store **R**ed, **G**reen, **B**lue, and **A**lpha. 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](https://docs.microsoft.com/en-us/windows/win32/direct3d10/d3d10-graphics-programming-guide-resources-block-compression?redirectedfrom=MSDN#bc1). This type is deprecated. ##### - Type 15 (DXT3) This type is identical to type 7, but it has been compressed with [BC2 compression](https://docs.microsoft.com/en-us/windows/win32/direct3d10/d3d10-graphics-programming-guide-resources-block-compression?redirectedfrom=MSDN#bc2). 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: ![](https://i.imgur.com/FaGtk4w.png) 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 * [AGH DDS Conversion thread on Istaria forums](https://community.istaria.com/forum/showthread.php?2555-AGH-gt-DDS-and-vice-versa-questions) * [Fridlekh's AGH Viewer page](https://sites.google.com/site/fridlekh/) * [#modding channel on Istaria's official Discord](https://discord.gg/DCDZ7Qk) * [DDS format MS Docs](https://docs.microsoft.com/en-us/windows/win32/direct3ddds/dx-graphics-dds-pguide) * [Block Compression MS Docs](https://docs.microsoft.com/en-us/windows/win32/direct3d10/d3d10-graphics-programming-guide-resources-block-compression) * [Torque3D Texture Compression documentation](http://docs.garagegames.com/torque-3d/official/content/documentation/Artist%20Guide/Formats/TextureCompression.html) * [Wikipedia page on DXTn compression](https://en.wikipedia.org/wiki/S3_Texture_Compression) * [Polycount Wiki page on DXT compression](http://wiki.polycount.com/wiki/DXT)