文件地址:
Program\Engine_Updating\Engine\Source\Runtime\Engine\Private\Materials\MeshMaterialShader.cpp
FShaderCompileJob* FMeshMaterialShaderType::BeginCompileShader(
uint32 ShaderMapId,
EShaderPlatform Platform,
const FMaterial* Material,
FShaderCompilerEnvironment* MaterialEnvironment,
FVertexFactoryType* VertexFactoryType,
const FShaderPipelineType* ShaderPipeline,
TArray<FShaderCommonCompileJob*>& NewJobs
)
{
FShaderCompileJob* NewJob = new FShaderCompileJob(ShaderMapId, VertexFactoryType, this);
NewJob->Input.SharedEnvironment = MaterialEnvironment;
FShaderCompilerEnvironment& ShaderEnvironment = NewJob->Input.Environment;
<span style="color:#ff6666;"> if (Material->IsUseCachePointIndirectLighting())
{
ShaderEnvironment.SetDefine(TEXT("CACHED_POINT_INDIRECT_LIGHTING"), 1);
if (Material->IsUsePrecomputedSHLightColorScale())
{
ShaderEnvironment.SetDefine(TEXT("ENABLE_PRECOMPUTED_SH_LIGHTING_SCALE"), 1);
}
}</span>
// apply the vertex factory changes to the compile environment
check(VertexFactoryType);
VertexFactoryType->ModifyCompilationEnvironment(Platform, Material, ShaderEnvironment);
添加了這一段,可以強行在shader編譯時候控制環境變量,根前一章的一起做,可以強行改變shader效果。