This document provides information on the Resource Compiler (often referred as "RC"). For most users, the RC is a tool that runs in the background.
However, it is often important to understand the reasons for why the RC exists, as well as the essential role it plays in game development with CRYENGINE.
CRYENGINE has the concept of source and target resources. Source resources are stored in a lossless format (without lossy compression) and can have asset-specific metadata. For example, the compression quality that should be used. These source assets are not used directly by the engine, but must be compiled to a platform-optimized format. In this process, the source data gets pre-processed and often compressed to reduce the memory requirements and speed up the loading in the game. The target format can be different on individual platforms. PC and consoles have a different endianness and support different texture compression schemes. The source to target transformation (compilation) is done by the Resource Compiler (RC), which you can find in the "RC" sub-folder of the Tools folder.
One of the primary purposes of the RC is to compress textures by using the ResourceCompilerImage module. All source textures are stored in the lossless TIF format and get converted to the DDS format. The CryTIF Plugin can be used to export a TIF file from Photoshop and open a dialog box where the meta data, like the desired compression scheme, can be chosen.
The Resource Compiler is invoked from the following tools:
The Resource Compiler supports different presets that specify the options that should be applied when compiling an image asset. When starting the RC, it loads the main settings and presets from the main configuration file: rc.ini.
A preset file for image compilation (TIF to DDS) looks like this:
; diffuse colour textures without alpha channel
[Albedo]
pixelformat=BC1
pixelformat:es3=ETC2
rgbweights=ciexyz
powof2=1
mipmaps=1
colorspace=sRGB,auto
;discardalpha=1
filemasks=*_diff*
; diffuse colour textures with alpha channel for alphablend
[AlbedoWithOpacity]
pixelformat=BC7t
pixelformat:es3=ETC2A
rgbweights=ciexyz
powof2=1
mipmaps=1
colorspace=sRGB,auto
filemasks=*_diff*
The following example opens the user dialog box so that the user can modify the parameters stored in the TIF file.
Note that when using the dialog box, it is possible to generate the .dds file by using Generate DDS button.
Tools\rc\rc c:\temp\test.tif /userdialog
Multiple directories and file types can be processed recursively with the . or *. extension:
Tools\rc\rc c:\*.tif /refresh
Same command, but with skipping compilation of .tif files that already have .dds files:
Tools\rc\rc c:\*.tif
Use quotes to compile assets with special characters (for example, spaces) in the path:
Tools\rc\rc "c:\data folder\*.tif"
The following Image shows the user interface that can be invoked with /userdialog or by using the CryTIF Plugin for Photoshop. The CryTIF Plugin documentation has more information.
RC User Dialog Box for selecting the TIF to DDS Option.
The RC Dialog can only be invoked when processing SRF and TIF files.
This is optional, you may use it if you want to use Collada as intermediate format. Otherwise collada files are automatically converted to during export process.
To process your Collada file with RC from command line, you have to do two steps:
rc.exe "fullpath"\walk.dae
cd SDKFolder
rc.exe path\to\walk.i_caf /animConfigFolder=Animations /sourceroot=GameSDK_Source /targetroot=GameSDK /SkipDBA /refresh
To double check if the files were updated, hit refresh in Windows Explorer so you can see if the file is a different size (re-processed), or check the time-stamp.
Also be sure to specify the following arguments:
The Resource Compiler can be used to generate a dump of the CGF. The syntax to make this operation is the following:
rc.exe /refresh /debugdump filename.cgf
This will create a new text file with the .dump extension with information on the data contained in the CGF file.
Since the CHR and CGA are also using the file structure of the CGF, it's possible to make a dump on these file as well. You just need to use the overwriteextension command-line parameter:
rc.exe /refresh /debugdump /overwriteextension=cgf filename.chr
The following are some more examples of how you can run the Resource Compiler from the command line:
rc myassset.tif /userdialog
Tools/rc/rc.exe c:\temp\*.tif /refresh /wait
The following is a list of useful command line arguments, specified as key-value pairs. Further details and a complete list of keys can be retrieved by using rc.exe with the /help argument (refer to the sample file, RCkeys.txt.log).
If you run rc.exe without any argument, then RC pops up a dialog showing version of the RC and folders:
If you're looking for a more permanent/frequent-use solution, you can create a file called rc_options.txt inside the RC folder that is being used. This can be used to apply specific settings every time the RC is invoked. Below is an example:
Any parameter can be used in this file to automate the RC to suit your needs. To get a full list of available parameters, open the RC folder in the command prompt and type rc /help.
If there is an alpha channel the chosen pixel format is adjusted so that the alpha channel can be used.
e.g. X8R8G8B8 becomes A8R8G8B8. If there is no alpha channel the format is adjusted as well. The system tries to be intelligent (Use a similar texture format quality).
That means you don't need a new preset to support textures with alpha channel. Below the right preview window you can see the used texture format (CryTIFPlugin).
The DDS file format includes additional meta data (a proprietary extension mechanism):
void CImageObjectBase::AppendExtendedData( FILE *out )
{
uint32 dwStartMagicWord = swizzle32('CExt'); // Crytek Extended -start
fwrite(&dwStartMagicWord,4,1,out);
uint32 dwChunkName = swizzle32('AvgC'); // Chunk AverageColor
fwrite(&dwChunkName,4,1,out);
uint32 dwChunkSize = 4;
fwrite(&dwChunkSize,4,1,out);
fwrite(&m_colAverageARGB,4,1,out);
uint32 dwEndMagicWord = swizzle32('CEnd'); // Crytek Extended - end
fwrite(&dwEndMagicWord,4,1,out);
}
This is an sample of the new dds file (the build now does for all DDS files that are created from TIF):
005555a0h: 21 22 22 23 25 25 25 27 5B 5C 5C 5F 5A 5A 5B 5E ; !""#%%%'[\\_ZZ[^
005555b0h: 58 58 58 5A 60 60 61 63 70 70 71 74 6D 6D 6E 70 ; XXXZ``acppqtmmnp
005555c0h: 2B 2C 2C 2E 2D 2D 2E 30 39 39 3A 3B 58 59 59 5C ; +,,.--.099:;XYY\
005555d0h: 33 34 34 36 43 45 78 74 41 76 67 43 04 00 00 00 ; 3446CExtAvgC....
005555e0h: 33 34 34 36 43 45 6E 64 ; 3446CEnd
Exported i_caf files contain animation in uncompressed format. To be loaded in the engine they first need to be compressed into .caf files.
For a local use during production this is normally done by automatic invocation of RC in Sandbox. See: Exporting Animations.
To do a full build on your local PC you can use following command line:
cd C:\CryENGINE
Tools\rc\rc.exe *.i_caf /animConfigFolder=Animations /p=PC /sourceroot=GameSDK_Source /targetroot=C:\Build\GameSDK /refresh
An animation source file is processed by the RC to output a compressed CAF file used by CRYENGINE. The compression involves the following steps:
Remove data in channels with no moves (same to the bind pose within the whole duration)
Remove some key-frames based on error thresholds
Quantize quaternions
Create animation databases (optional)
If you are experiencing an error or warning dialog when processing an asset you may want to refer to our Troubleshooting section of our documentation for more information.