The format of the SR3 texture files.

Although I've written a utility to unpack and repack the Saints Row texture files I haven't explained the format of the file. So here it is for those that are interested.

As with most SR3 files the data is split between 2 files. The cpeg_pc / cvbm_pc file contains the header information. The gpeg_pc / gvbm_pc contains the actual texture data.

The cpeg_pc and cvbm_pc files are the same except that the cvbm_pc files always only contain one texture. The cpeg_pc can in some cases have 0 textures defined, in which case there will not be a corresponding gpeg_pc file.

The format of the cpeg_pc / cvbm_pc files is:

This is a pseudo c header file. Any undefined arrays of the type char i.e. char FOO[]; means that the data is a null terminated c type string.

Code:
// Set up structures used by file.  
enum <unsigned int> TEXTURETYPES
{
    D3DFMT_DXT1=400,
    D3DFMT_DXT3,
    D3DFMT_DXT5,
    D3DFMT_R5G6B5,
    D3DFMT_A1R5G5B5,
    D3DFMT_A4R4G4B4,
    D3DFMT_R8G8B8,
    D3DFMT_A8R8G8B8,
    D3DFMT_V8U8,
    D3DFMT_CxV8U8,
    D3DFMT_A8,
    D3DFMT_DXT5alt=701
};    
 
struct TEXTURERECORD
{
    unsigned int64 FileOffsetOfData;
    unsigned short Width;
    unsigned short Height;
    TEXTURETYPES TextureEnum;
    unsigned char Unk_Flags[6];
    unsigned char HasAlpha;
    unsigned char Unk_Flags2[12];
    unsigned char NumberOfMipLevels;
    unsigned int SizeOfData;
    unsigned short Unknown3[16]; // Always filled with zeros?  
};  
 
struct TEXTURENAME
{
    char Name[];
};  
 
// This is the actual start of the file data.  
 
struct FILE
{
    char Magic[4]; // Always GEKV
    int Version; // Always 13
    int SizeOf_cpeg_pc;
    int SizeOf_gpeg_pc;
    int NumberOfTextures;
    short NumberOfTexturesDup;
    short Unknown3;  
    TEXTURERECORD TextureData[NumberOfTextures];  
    TEXTURENAME TextureName[NumberOfTextures];
} File;

The gpeg_pc/gvbm_pc file is a collection of DDS texture file data but with the header taken off i.e. remove the first 128 bytes. Each block of texture data is pointed to by the TextureData[TextureNumber].FileOffsetOfData record. It looks like each block of texture data is aligned to 16 bytes.
 
Thanks for taking the time to put this together. :)
 
I thank you for the info.;)

As you probably noticed, the one .dds file that seems to be most edited is f_ideal_d.tga.DDS

Would you please give us the details of the above mentioned .dds file.
For example, when saving this file after editing, a dialog window opens that asks how should this file be saved as. ( mipmaps, dxt3, dxt5, etc. )

Please let us know exactly which image settings to use when saving this file.:cool:

Thank you.;)
 
I thank you for the info.;)

As you probably noticed, the one .dds file that seems to be most edited is f_ideal_d.tga.DDS

Would you please give us the details of the above mentioned .dds file.
For example, when saving this file after editing, a dialog window opens that asks how should this file be saved as. ( mipmaps, dxt3, dxt5, etc. )

Please let us know exactly which image settings to use when saving this file.:cool:

Thank you.;)

The original texture format is DXT1, no alpha channel and it doesn't have mipmaps. So you can stick with that.

As it doesn't have an alpha channel there is no point in saving it as a DXT5 texture. (The colour quality is the same for DXT1 and DXT5 it's only the alpha channel that's improved using DXT5. Don't bother with DXT3 as no one else does). The rule basically is: no alpha channel use DXT1, if it has an alpha channel use DXT5.

If you want the best colour quality then save it as R8G8B8 although the file size will be 4 times larger. (I think).

You can also try saving it with mipmaps to improve the quality and speed up the rendering, again at the cost of the file size. Using mipmaps basically means it saves several versions of the texture at different sizes. (It halves the texture size for each level of the mipmap).
 
I thank you scanti for your very informative reply above.:D
Keep up the good work there.:cool:
 
Scanti i need help:mad: how do i properly repack my edited DDS files to cpeg_pc format again after editing the files? Maybe im in the wrong place but ok i was able to properly extract my pistol_gang_high.str2_pc file correctly. Then i was able to get the DDS images from the cpeg_pc file and edit he images with gimp. Now how do i put them back to cpeg_pc so can use gibbs to create the str2_pc file correctly without errors? Any help appreciated i been at this for days searching these forums to figure this out:confused: and i think im confusing Voltarox trying to help:p
 
Back
Top