Repository navigation
Asset: Images
Images can be of two main types: streamed & loaded.
Streamed images are not always loaded into memory and are stored in packed files known as "image files".
Image files store compressed images (using LZ4 compression) one after the other, as if they were "packed". Image file names follow this pattern:
imagefile{number}.pak
where number is the index of the file, starting from 1. The image asset references streamed images using the image file index and the start & end offset of the image within the file. Note that this reference isn't part of the asset structure itself but is included in the fastfile, more information about this can be found here.
Loaded images are always loaded into memory and their pixels are stored within the image asset itself. These are often used for UI images.
Zonetool normally dumps images as .<game>Image (ex. .h2Image for h2), this format works for both streamed & loaded images, but the actual image's pixels are only dumped if it is not a streamed image. In the case of a streamed image only the image's reference is dumped (image file index and offset).
Dumping as .dds is also supported but requires a modification in zonetool's code.
When targeting a different game streamed images's pixels are also dumped, this is necessary since if we dump images for a different game we won't have access to the source game's image files. In this case the images are dumped to the streamed_images folder, rather than the images folder.
Streamed images are composed of up to 4 levels of "quality" which we will call "streams". The individual streams are dumped to separate files with the following format:
{image}_stream{stream index}.pixels
where stream index belongs to [0, 3], with 3 being the highest level of quality. Note that the stream doesn't correspond to the mip level, each stream could have different number of mips, and usually stream 0 has multiple mip levels, while the others only have 1.
Upon parsing zonetool will generate a new custom image file containing the required streamed images, this image file won't follow the regular naming scheme but will have the same name as the fastfile we are currently building ({fastfile}.pak). The related code can be found here. Internally the images will still reference the image file with a number, which differs for each game and usually is simply an image file number that doesn't exist on that game. The game this image file is loaded on should then be modified to redirect imagefile{dummy number}.pak to {fastfile}.pak. An implementation of this can be found here.
Parsing of custom images is supported for loaded images, but not custom streamed images.
Currently these formats are supported:
ddstgaiwi
Zonetool tries to parse images with this priority:
.<game>Image-
.<game>Image+.pixels(dumped streamed images) .dds.tga.iwi
When an image is missing zonetool will generate a dummy image which will always be red. Note that depending on the techset that is used this image may not appear as red, so if you notice textures that shouldn't be one solid color this probably means you are missing images.
struct GfxImageLoadDef
{
char levelCount;
char numElements;
char pad[2];
int flags;
int format;
int resourceSize;
char data[1];
};
struct GfxTexture
{
union
{
ID3D11Texture1D* linemap;
ID3D11Texture2D* map;
ID3D11Texture3D* volmap;
ID3D11Texture2D* cubemap;
GfxImageLoadDef* loadDef;
};
ID3D11ShaderResourceView* shaderView;
ID3D11ShaderResourceView* shaderViewAlternate;
};
struct Picmip
{
unsigned char platform[2];
};
struct GfxImageStreamData
{
unsigned short width;
unsigned short height;
union
{
unsigned char bytes[4];
unsigned int pixelSize;
};
};
enum MapType : std::uint8_t
{
MAPTYPE_NONE = 0x0,
MAPTYPE_INVALID1 = 0x1,
MAPTYPE_1D = 0x2,
MAPTYPE_2D = 0x3,
MAPTYPE_3D = 0x4,
MAPTYPE_CUBE = 0x5,
MAPTYPE_ARRAY = 0x6,
MAPTYPE_COUNT = 0x7,
};
struct GfxImage
{
GfxTexture texture;
DXGI_FORMAT imageFormat;
MapType mapType;
unsigned char semantic;
unsigned char category;
unsigned char flags;
Picmip picmip;
char __pad0[2];
unsigned int dataLen1;
unsigned int dataLen2;
unsigned short width;
unsigned short height;
unsigned short depth;
unsigned short numElements;
unsigned char levelCount;
unsigned char streamed;
char __pad1[2];
unsigned char* pixelData;
GfxImageStreamData streams[4];
const char* name;
};