If anyone else is getting the following errors
during compilation of Shader Files inheriting from FGlobalShader after transitioning to 4.19, here’s the two fixes you need:
- Change the arguments of ModifyCompilationEnvironment from EShaderPlatform to const FGlobalShaderPermutationParameters&:
example:
from
void FMyShaderDeclaration::ModifyCompilationEnvironment(EShaderPlatform Platform, FShaderCompilerEnvironment& OutEnvironment)
{
FGlobalShader::ModifyCompilationEnvironment(Platform, OutEnvironment);
OutEnvironment.CompilerFlags.Add(CFLAG_StandardOptimization);
}
to
void FMyShaderDeclaration::ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& PermutationParams, FShaderCompilerEnvironment& OutEnvironment)
{
FGlobalShader::ModifyCompilationEnvironment(PermutationParams, OutEnvironment);
OutEnvironment.CompilerFlags.Add(CFLAG_StandardOptimization);
}
- Add the ShouldCompilePermutation method for each shader:
example:
static bool ShouldCompilePermutation(const FGlobalShaderPermutationParameters& PermutationParams)
{
// Useful when adding a permutation of a particular shader
return true;
}
It works, but there's probably a more reasonable approach than simply returning true here. I'd be grateful if someone could provide some info about that.
All of this only applies to your project when you’re using global shaders (necessary for compute shaders), especially when using the popular UE4ShaderPluginDemo or one of its forks. For more information about how to set up Global Shaders see this blogpost: Yet another blog...: Adding Global shaders to UE4 v2.0
Adding this so others don’t have to search the web as long as I had to:
Unreal Engine Global Compute Pixel Shader FGlobalShader Compile Error Permutation Transition Uprade 4.19 ModifyCompilationEnvironment Modify Compilation Environment ShouldCompilePermutation Should Compile Permutation EShaderPlatform FGlobalShaderPermutationParameters InPermutationId PermutationId IMPLEMENT_SHADER_TYPE3 IMPLEMENT_SHADER_TYPE implement shader type