Getting the Shaders Getting the Shaders on Android ...

Report 9 Downloads 48 Views
Setup Before running the game on the mobile device (Android or iOS) you will need to have the remote Shader Compiler running on a PC. The mobile device system CFG files (system_android_es3.cfg and system_ios_ios.cfg) also need to be setup to connect to the remote shader compiler on the PC. Build, deploy and run the game on the mobile device. Every area of every level needs to be explored to ensure that all shader permutations that are needed for the game are generated. Once all areas are explored the game can be exited.

Getting the Shaders Once the game has been run and all shaders have been generated the next step is to get the shaders off of the mobile device.

Getting the Shaders on Android On Android the shaders will be located in the user directory in the top level directory where the game assets are stored. This is generally in /storage/sdcard0/[Game Project Name]. You will want to execute the adb pull command to get the shaders off of the device onto a PC machine. Example of the command is: adb pull /storage/sdcard0/[Game Project Name]/user [Lumberyard Root Directory]\cache\[Game Project Name]\es3\user Note: The game has a couple of options of where it puts the shaders in the user directory. The batch files that are executed later on in this process expects that the shaders be located in Cache\[Game Project Name]\es3\user\cache\shaders. If there are not shaders in that directory they are located in Cache\[Game Project Name]\es3\user\shaders\cache\ and should be moved to the previous directory.

Getting the Shaders on iOS In Xcode select the “Window” menu and select the devices option.

Click on the settings wheel to bring up the container menu and select the download the container option.

Then go into the container package (it is the file that has the xcappdata extension) in the Mac finder, right click on it and select the “Show Package Contents” option. This will open the container for browsing in the finder.

Copy the shaders folder from the AppData/Documents folder onto a PC in the [Lumberyard Root Directory]\Cache\[Game Project Name]\ios\user.

Building the Shader PAK files Building for iOS: You can run the batch file BuildShaderPak_Metal.bat from a command prompt and supply the [Game Project Name] as the first argument: BuildShaderPak_Metal.bat [Game Project Name] Building for Android You can run the batch file BuildShaderPak_ES3.bat from the command prompt and supply the shaderlist_gles3.txt file that is generated by the remote shader compiler and the game project name to build the shaders for. This shader list file will be located under the Cache folder where the remote shader compiler executable is located. Example path is: [Lumberyard Root Directory]\dev\Tools\CrySCompileServer\x64\profile\Cache\[Game Project Name]\ShaderList_GLES3.txt. Example command: BuildShaderPak_ES3.bat Tools\CrySCompileServer\x64\profile\Cache\FeatureTests\ShaderList_GLES3.txt SamplesProject

Deploying the Shaders When the .bat file is done there will be two shader pak files in the [Lumberyard Root Directory]\Build\[Platform]\[Game Project Name]\[Platform] directory:  

ShaderCache.pak – Contains all compiled shaders; used only when the shader cannot be found in the current level’s shader cache. ShaderCacheStartup.pak – Contains subset of compiled shaders that are needed to speed up startup of the engine.

There are two options to enable the game to run the shaders from the pak files. 1. Rename ShaderCache.pak to shaders.pak and copy the pak files to to the directory [Lumberyard Root Directory]\cache\[Game Project Name]\es3\[game project name] for android or [Lumberyard Root Directory]\cache\[Game Project Name]\ios\[game project name] for iOS platforms. At this point when you run the game it will try to load the shaders from the Shaders.pak file first. 2. Copy the shaders*.pak files to the directory [Lumberyard Root Directory]\cache\[Game Project Name]\es3\[game project name] for android or [Lumberyard Root Directory]\cache\[Game Project Name]\ios\[game project name] for iOS platforms.. Then update the android.cfg or ios.cfg file and set r_ShadersPreactivate to the value of 3 to have the game preload all the shaders from the ShaderCache.pak. Doing this means that all the shaders that have been put in the ShaderCache.pak file are loaded into memory and stay in memory until the game is exited. Once the shader pak files are in the correct cache location deploy the assets to the device and the game will use those shaders and not connect to the remote shader compiler unless it cannot find a shader. If this happens then the whole process to get the shaders from the device and create the pak files needs to be repeated.