Shaders
Creating a custom shader in CryENGINE is relatively easy, and can be done simply by copying an existing shader (.cfx
) and its extension file (.ext
). For the sake of this example, copy Illum.ext
from Engine/Shaders
and name it MyShader.ext
. Then copy Engine/Shaders/HWScripts/CryFX/Illum.cfx
and rename it to MyShader.cfx
.
Note that creating custom shaders should be thought out properly; if it is possible to simply use an existing shader, that would be the best option. This is due to the fact that CryENGINE is already reaching the viable limit of the number of shader permutations.
Note
As stated earlier in the chapter, custom shader authoring was not enabled in the CryENGINE Free SDK at the time this book was written.
The shader description
Each shader needs to define a description, which sets its options. Options are set in the global Script
variable, as shown in the following code:
float Script : STANDARDSGLOBAL < string Script = "Public;" ...