更改shader的編譯環境。

文件地址:

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效果。



發佈了90 篇原創文章 · 獲贊 25 · 訪問量 21萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章