The creation of the ShaderCache.pak suppose that a Remote Shader Compiler is running on a server machine and that contains a set of compiled shader used by the game.
The creation of the ShaderCache.pak will not work if you don't use the Remote Shader Compiler to compile the shaders.
Chapters:
Related Pages:
To create the ShaderCache.pak you need to follow these instructions:
Get the build for which you want to create the ShaderCache.pak. The set of files you really need in this step is:
Please note, that if you are building from a workspace where you have used r_ShadersDebug before, you may have copies of shaders in the <root>\<GameName>\Shaders folder.
These must be deleted before building the ShaderCache.
Copy one of the following files from the Remote Shaders Compiler cache folder and rename into <root>\USER\Shaders\shaderlist.txt. (note the casing on shaderlist)
The following platforms are supported:
Please note that the ShaderList is typically generated by running the game in the appropriate configuration with RSC attached to the game.
For ShaderList_GL4.txt this means you should be using the CryRenderGL.dll as renderer at runtime (with r_driver=GL and running on the target platform)
Write a system.cfg file into the <root> folder as following:
sys_no_crash_dialog=1
d3d9_NullRefDevice=1
sys_vr_support = 0
log_IncludeTime=3
log_Verbosity=3
log_FileVerbosity=3
e_profile_level_loading=0
r_driver=DX11
sys_game_folder=<GameName>
r_ShadersAsyncCompiling=3
r_ShadersAsyncMaxThreads=16
r_ShadersRemoteCompiler=1
r_ShaderCompilerServer=<ShaderCompilerIPAddressOrHostname>
r_ShaderCompilerPort=<ShaderCompilerPort>
r_ShadersUserFolder=1
r_ShadersUseInstanceLookUpTable=1
r_multithreaded=0
r_ShadersSubmitRequestline=0
r_ShadersDX11=0
r_ShadersDurango=0
r_ShadersOrbis=0
-- For the OpenGL renderer support
-- r_driver=GL
-- r_ShadersGL4=0
Then, depending on the platform, change exactly one of the following variables from 0 to 1 in the system.cfg
file:
Target Platform | Variable to change | Target Subfolder |
---|---|---|
PC, DirectX 11 | r_ShadersDX11 | D3D11 |
XBox One | r_ShadersDurango | DURANGO |
Playstation 4 | r_ShadersOrbis | ORBIS |
PC, OpenGL 4 | r_ShadersGL4 | GL4 |
Only one set of shaders can be compiled at one time. Therefore, only set one of the r_ShadersXXX variables to 1 at a time.
When using r_ShadersGL4=1
you must also set r_driver=GL
and you must have the appropriate CryRenderGL.dll in your build.
Generate the files needed for the ShaderCache.pak running the ShaderCacheGen tool with the following command line (The result of the process is logged into the file editor.log):
If a ShaderCache.pak for a PC, Playstation 4 or Xbox One platform is generated the command is:
<root>\bin\win_x64\ShaderCacheGen.exe -noprompt -anygpu /PrecacheShaderList
Packing the shader cache together can be done manually or by using Tools\PakShaders.bat
. It is required that you have gone through Step 1-4 before doing this. The command to invoke packing is:
<root>\Tools\PakShaders.bat <TargetSubfolder>
<TargetSubfolder> can be found in the table in Step 3
The script will create the *.pak files inside the root folder. It processes in an accumulative way, which means when you run the command for different platforms after each other, they will all be merged into the same archives.
Typically, the generated *.pak are copied into the Engine folder in the final build.
For reference, take a look at the pre-built games shipped in the SDK, the shaders in them have been generated with the same method as the one here.
Currently, it only makes sense to pack multiple sets of shaders for the PC platform, specifically, the D3D10, D3D11 and GL4 sets can be combined.
For other platforms, there is no reason to pack any shaders other than for the single supported set on that specific hardware.
If you would rather pack your shader cache manually, please continue reading:
Pack the files into the different pak files. The folder mapping for the different platforms:
The PC platform should copy the data from the following folders:
<root>\USER\Shaders\Cache\D3D9\
<root>\USER\Shaders\Cache\D3D10\
<root>\USER\Shaders\Cache\D3D11\
<root>\USER\Shaders\Cache\GL4\
... into:
Shaders\Cache\D3D9\
Shaders\Cache\D3D10\
Shaders\Cache\D3D11\
Shaders\Cache\GL4\
The Xbox One platform should copy the data from the following folder:
The Playstation 4 platform should copy the data from the following folder: