In this Topic

Overview

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 process 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 Export Textures with CryTIF - Photoshop page 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:


Presets

The Resource Compiler supports different presets that specifies 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*

Calling the RC from the Command Line

The following examples allows opening 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 Resource Compiler Dialog

The following image shows the user interface that can be invoked with /userdialog or by using the Export Textures with CryTIF - Photoshop for Photoshop. The Export Textures with CryTIF - Photoshop documentation has more information about using a source texture (.tif) in CRYENGINE.

Pic1: RC User Dialog Box for selecting the TIF to DDS Option.

The RC Dialog can only be invoked when processing SRF and TIF files.

Processing a Collada File from the Command Line

This is optional, you may use it if you want to use Collada as intermediate format. Otherwise collada files are automatically converted during export process.

To process your Collada file with RC from command line, you have to perform the following steps: 

  1. Process the Collada file directly with RC from the command line to output an uncompressed *.caf file.
rc.exe "fullpath"\walk.dae

 2. Process the *.i_caf file that you got from Step 1 again with RC from the command line specifying the sub-folder name that contains SkeletonList.xml and DBATable.json to output a compressed *.caf file.

From engine version 5.6 onwards, the skeleton list is not used anymore, which means that you can ignore any references to it on this page.


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, refresh the Windows Explorer so that 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: 

Creating a Dump Log from Compiled Assets

The Resource Compiler can be used to generate a dump of the CGF. The syntax to perform this operation is mentioned below:

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

Command Line Arguments

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).

If you run rc.exe without any argument, then RC pops up a dialog showing version of the RC and folders:

Pic2: A dialog showing version of the RC and folders.

RC_Options.txt

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:

Pic3: A sample rc_options.txt file.

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.

Automatic Adjustments

If there is an alpha channel, the chosen pixel format is adjusted so that the alpha channel can be used.

For example, X8R8G8B8 becomes A8R8G8B8. If there is no alpha channel the format is adjusted as well. The system tries to be intelligent by using 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).

Output in the Extended DDS Format

The DDS file format includes additional meta data (a proprietary extension mechanism) as mentioned below:

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);
}

A sample of the new dds file (the build now does for all DDS files that are created from TIF) is provided below:

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

Common Animation Related Usage

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 local use during production, this is normally done by automatic invocation of RC in Sandbox.

To perform 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

Animation Compression Details

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)


How to use the Resource Compiler manually to process specific assets