更改shader的编译环境。

来源:互联网 发布:最强网络神豪笔趣阁 编辑:程序博客网 时间:2024/06/05 14:27

文件地址:

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 environmentcheck(VertexFactoryType);VertexFactoryType->ModifyCompilationEnvironment(Platform, Material, ShaderEnvironment);

添加了这一段,可以强行在shader编译时候控制环境变量,根前一章的一起做,可以强行改变shader效果。



1 0