vault backup: 2024-03-18 16:08:45

This commit is contained in:
BlueRose 2024-03-18 16:08:45 +08:00
parent 03151864cc
commit be0e3fd499
2 changed files with 91 additions and 1 deletions

View File

@ -339,7 +339,97 @@ bool FMaterialInstanceResource::GetParameterValue(EMaterialParameterType Type, c
} }
``` ```
### 是否需要Toon
### BasePass EncodeGBufferToMRT/DecodeGBufferDataDirect逻辑笔记
主要逻辑位于FShaderCompileUtilities::WriteGBufferInfoAutogen():
```c++
void FShaderCompileUtilities::WriteGBufferInfoAutogen(EShaderPlatform TargetPlatform, ERHIFeatureLevel::Type FeatureLevel = ERHIFeatureLevel::SM5)
{
FGBufferParams DefaultParams = FetchGBufferParamsPipeline(TargetPlatform, GBL_Default);
FScopeLock MapLock(&GCriticalSection);
// For now, the logic always calculates the new GBuffer, and if it's the first time, write it, otherwise check it hasn't changed. We are doing this for
// debugging, and in the near future it will only calculate the GBuffer on the first time only.
FGBufferInfo DefaultBufferInfo = FetchFullGBufferInfo(DefaultParams);
FString AutoGenDirectory = GetAutoGenDirectory(TargetPlatform);
FString AutogenHeaderFilename = AutoGenDirectory / TEXT("AutogenShaderHeaders.ush");
FString AutogenHeaderFilenameTemp = AutoGenDirectory / TEXT("AutogenShaderHeaders_temp.ush");
if (GLastGBufferIsValid[TargetPlatform])
{
const bool bSame = IsGBufferInfoEqual(GLastGBufferInfo[TargetPlatform], DefaultBufferInfo);//判断GBufferInfo是否相同不同则触发断言
check(bSame);
}
else
{
GLastGBufferIsValid[TargetPlatform] = true;
// should cache this properly, and serialize it, but this is a temporary fix.
GLastGBufferInfo[TargetPlatform] = DefaultBufferInfo;
FString OutputFileData;
OutputFileData += TEXT("// Copyright Epic Games, Inc. All Rights Reserved.\n");
OutputFileData += TEXT("\n");
OutputFileData += TEXT("#pragma once\n");
OutputFileData += TEXT("\n");
OutputFileData += TEXT("#if FEATURE_LEVEL >= FEATURE_LEVEL_SM5\n");
OutputFileData += TEXT("float SampleDeviceZFromSceneTexturesTempCopy(float2 UV)\n");
OutputFileData += TEXT("{\n");
OutputFileData += TEXT("\treturn SceneDepthTexture.SampleLevel(SceneDepthTextureSampler, UV, 0).r;\n");
OutputFileData += TEXT("}\n");
OutputFileData += TEXT("#endif\n");
OutputFileData += TEXT("\n");
OutputFileData += TEXT("#ifndef GBUFFER_LAYOUT\n");
OutputFileData += TEXT("#define GBUFFER_LAYOUT 0\n");
OutputFileData += TEXT("#endif\n");
OutputFileData += TEXT("\n");
for (uint32 Layout = 0; Layout < GBL_Num; ++Layout)
{
FGBufferParams Params = FetchGBufferParamsPipeline(TargetPlatform, (EGBufferLayout)Layout);
FGBufferInfo BufferInfo = FetchFullGBufferInfo(Params);
OutputFileData.Appendf(TEXT("#if GBUFFER_LAYOUT == %u\n\n"), Layout);
OutputFileData += CreateGBufferEncodeFunction(BufferInfo);
OutputFileData += TEXT("\n");
OutputFileData += CreateGBufferDecodeFunctionDirect(BufferInfo);
OutputFileData += TEXT("\n");
//OutputFileData += TEXT("#if SHADING_PATH_DEFERRED\n");
OutputFileData += TEXT("#if FEATURE_LEVEL >= FEATURE_LEVEL_SM5\n");
OutputFileData += TEXT("\n");
OutputFileData += CreateGBufferDecodeFunctionVariation(BufferInfo, EGBufferDecodeType::CoordUV, FeatureLevel);
OutputFileData += TEXT("\n");
OutputFileData += CreateGBufferDecodeFunctionVariation(BufferInfo, EGBufferDecodeType::CoordUInt, FeatureLevel);
OutputFileData += TEXT("\n");
OutputFileData += CreateGBufferDecodeFunctionVariation(BufferInfo, EGBufferDecodeType::SceneTextures, FeatureLevel);
OutputFileData += TEXT("\n");
OutputFileData += CreateGBufferDecodeFunctionVariation(BufferInfo, EGBufferDecodeType::SceneTexturesLoad, FeatureLevel);
OutputFileData += TEXT("\n");
OutputFileData += TEXT("#endif\n");
OutputFileData += TEXT("\n");
OutputFileData += TEXT("#endif\n");
OutputFileData += TEXT("\n");
}
...
}
```
写入内容与这2句获取的FGbufferInfo有关`FGBufferParams Params = FetchGBufferParamsPipeline(TargetPlatform, (EGBufferLayout)Layout);``FGBufferInfo BufferInfo = FetchFullGBufferInfo(Params);`
![[ShaderGenerationUtil_CreateGBufferEncodeFunction.png|1200]]
## 是否需要Toon
在材质中: 在材质中:
```c++ ```c++
FMaterialRelevance UMaterialInterface::GetRelevance_Internal(const UMaterial* Material, ERHIFeatureLevel::Type InFeatureLevel) const FMaterialRelevance UMaterialInterface::GetRelevance_Internal(const UMaterial* Material, ERHIFeatureLevel::Type InFeatureLevel) const

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB