You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb none #jira none #preflight 635ab63d015611ae3af1a47e #fyi sebastien.hillaire [CL 22813356 by Charles deRousiers in ue5-main branch]
457 lines
22 KiB
C++
457 lines
22 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "Strata.h"
|
|
#include "SceneTextureParameters.h"
|
|
#include "SceneRendering.h"
|
|
#include "ScreenPass.h"
|
|
#include "ShaderCompiler.h"
|
|
#include "PixelShaderUtils.h"
|
|
#include "BasePassRendering.h"
|
|
#include "IndirectLightRendering.h"
|
|
#include "StrataVisualizationData.h"
|
|
|
|
|
|
static TAutoConsoleVariable<int32> CVarStrataDebugAdvancedVisualizationShaders(
|
|
TEXT("r.Strata.Debug.AdvancedVisualizationShaders"),
|
|
0,
|
|
TEXT("Enable advanced strata material debug visualization shaders. Base pass shaders can output such advanced data."),
|
|
ECVF_ReadOnly | ECVF_RenderThreadSafe);
|
|
|
|
bool IsStrataAdvancedVisualizationShadersEnabled()
|
|
{
|
|
return CVarStrataDebugAdvancedVisualizationShaders.GetValueOnRenderThread() > 0;
|
|
}
|
|
|
|
namespace Strata
|
|
{
|
|
// Forward declarations
|
|
void AddStrataInternalClassificationTilePass(
|
|
FRDGBuilder& GraphBuilder,
|
|
const FViewInfo& View,
|
|
const FRDGTextureRef* DepthTexture,
|
|
const FRDGTextureRef* ColorTexture,
|
|
EStrataTileType TileMaterialType,
|
|
const bool bDebug);
|
|
|
|
static bool StrataDebugVisualizationCanRunOnPlatform(EShaderPlatform Platform)
|
|
{
|
|
// On some consoles, this ALU heavy shader (and with optimisation disables for the sake of low compilation time) would spill registers. So only keep it for the editor.
|
|
return GetMaxSupportedFeatureLevel(Platform) >= ERHIFeatureLevel::SM5 && IsPCPlatform(Platform);
|
|
}
|
|
|
|
class FMaterialPrintInfoCS : public FGlobalShader
|
|
{
|
|
DECLARE_GLOBAL_SHADER(FMaterialPrintInfoCS);
|
|
SHADER_USE_PARAMETER_STRUCT(FMaterialPrintInfoCS, FGlobalShader);
|
|
|
|
using FPermutationDomain = TShaderPermutationDomain<>;
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
SHADER_PARAMETER(uint32, BSDFIndex)
|
|
SHADER_PARAMETER_STRUCT_REF(FViewUniformShaderParameters, ViewUniformBuffer)
|
|
SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FStrataGlobalUniformParameters, Strata)
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FSceneTextureParameters, SceneTextures)
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(ShaderPrint::FShaderParameters, ShaderPrintParameters)
|
|
SHADER_PARAMETER_RDG_BUFFER_UAV(RWBuffer<uint>, RWPositionOffsetBuffer)
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
static FPermutationDomain RemapPermutation(FPermutationDomain PermutationVector)
|
|
{
|
|
return PermutationVector;
|
|
}
|
|
|
|
static bool ShouldCompilePermutation(const FGlobalShaderPermutationParameters& Parameters)
|
|
{
|
|
return Strata::IsStrataEnabled() && StrataDebugVisualizationCanRunOnPlatform(Parameters.Platform) && EnumHasAllFlags(Parameters.Flags, EShaderPermutationFlags::HasEditorOnlyData);
|
|
}
|
|
|
|
static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
|
|
{
|
|
FGlobalShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
|
|
|
|
// Stay debug and skip optimizations to reduce compilation time on this long shader.
|
|
OutEnvironment.CompilerFlags.Add(CFLAG_Debug);
|
|
OutEnvironment.SetDefine(TEXT("SHADER_MATERIALPRINT"), 1);
|
|
}
|
|
};
|
|
IMPLEMENT_GLOBAL_SHADER(FMaterialPrintInfoCS, "/Engine/Private/Strata/StrataVisualize.usf", "MaterialPrintInfoCS", SF_Compute);
|
|
|
|
class FVisualizeMaterialCountPS : public FGlobalShader
|
|
{
|
|
DECLARE_GLOBAL_SHADER(FVisualizeMaterialCountPS);
|
|
SHADER_USE_PARAMETER_STRUCT(FVisualizeMaterialCountPS, FGlobalShader);
|
|
|
|
using FPermutationDomain = TShaderPermutationDomain<>;
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
SHADER_PARAMETER(uint32, ViewMode)
|
|
SHADER_PARAMETER_STRUCT_REF(FViewUniformShaderParameters, ViewUniformBuffer)
|
|
SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FStrataGlobalUniformParameters, Strata)
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FSceneTextureParameters, SceneTextures)
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(ShaderPrint::FShaderParameters, ShaderPrintParameters)
|
|
RENDER_TARGET_BINDING_SLOTS()
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
static FPermutationDomain RemapPermutation(FPermutationDomain PermutationVector)
|
|
{
|
|
return PermutationVector;
|
|
}
|
|
|
|
static bool ShouldCompilePermutation(const FGlobalShaderPermutationParameters& Parameters)
|
|
{
|
|
return Strata::IsStrataEnabled() && StrataDebugVisualizationCanRunOnPlatform(Parameters.Platform) && EnumHasAllFlags(Parameters.Flags, EShaderPermutationFlags::HasEditorOnlyData);
|
|
}
|
|
|
|
static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
|
|
{
|
|
FGlobalShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
|
|
|
|
// Stay debug and skip optimizations to reduce compilation time on this long shader.
|
|
OutEnvironment.CompilerFlags.Add(CFLAG_Debug);
|
|
OutEnvironment.SetDefine(TEXT("SHADER_MATERIALCOUNT"), 1);
|
|
}
|
|
};
|
|
IMPLEMENT_GLOBAL_SHADER(FVisualizeMaterialCountPS, "/Engine/Private/Strata/StrataVisualize.usf", "VisualizeMaterialPS", SF_Pixel);
|
|
|
|
|
|
class FStrataSystemInfoCS : public FGlobalShader
|
|
{
|
|
DECLARE_GLOBAL_SHADER(FStrataSystemInfoCS);
|
|
SHADER_USE_PARAMETER_STRUCT(FStrataSystemInfoCS, FGlobalShader);
|
|
|
|
using FPermutationDomain = TShaderPermutationDomain<>;
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
SHADER_PARAMETER(uint32, bAdvancedDebugEnabled)
|
|
SHADER_PARAMETER(uint32, bEnergyConservation)
|
|
SHADER_PARAMETER(uint32, bEnergyPreservation)
|
|
SHADER_PARAMETER(uint32, bDbufferPass)
|
|
SHADER_PARAMETER(uint32, ClassificationCMask)
|
|
SHADER_PARAMETER(uint32, ClassificationAsync)
|
|
SHADER_PARAMETER(uint32, Classification8bits)
|
|
SHADER_PARAMETER(uint32, bRoughRefraction)
|
|
SHADER_PARAMETER(uint32, bTileOverflowUseMaterialData)
|
|
SHADER_PARAMETER(float, TileOverflowRatio)
|
|
SHADER_PARAMETER_RDG_BUFFER_SRV(Buffer<uint>, ClassificationTileDrawIndirectBuffer)
|
|
SHADER_PARAMETER_STRUCT_REF(FViewUniformShaderParameters, ViewUniformBuffer)
|
|
SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FStrataGlobalUniformParameters, Strata)
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FSceneTextureParameters, SceneTextures)
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(ShaderPrint::FShaderParameters, ShaderPrintParameters)
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
static FPermutationDomain RemapPermutation(FPermutationDomain PermutationVector)
|
|
{
|
|
return PermutationVector;
|
|
}
|
|
|
|
static bool ShouldCompilePermutation(const FGlobalShaderPermutationParameters& Parameters)
|
|
{
|
|
return Strata::IsStrataEnabled() && StrataDebugVisualizationCanRunOnPlatform(Parameters.Platform) && EnumHasAllFlags(Parameters.Flags, EShaderPermutationFlags::HasEditorOnlyData);
|
|
}
|
|
|
|
static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
|
|
{
|
|
FGlobalShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
|
|
|
|
// Stay debug and skip optimizations to reduce compilation time on this long shader.
|
|
OutEnvironment.CompilerFlags.Add(CFLAG_Debug);
|
|
OutEnvironment.SetDefine(TEXT("SHADER_SYSTEMINFO"), 1);
|
|
}
|
|
};
|
|
IMPLEMENT_GLOBAL_SHADER(FStrataSystemInfoCS, "/Engine/Private/Strata/StrataVisualize.usf", "MainCS", SF_Compute);
|
|
|
|
class FMaterialDebugStrataTreeCS : public FGlobalShader
|
|
{
|
|
DECLARE_GLOBAL_SHADER(FMaterialDebugStrataTreeCS);
|
|
SHADER_USE_PARAMETER_STRUCT(FMaterialDebugStrataTreeCS, FGlobalShader);
|
|
|
|
using FPermutationDomain = TShaderPermutationDomain<>;
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
SHADER_PARAMETER_STRUCT_REF(FViewUniformShaderParameters, ViewUniformBuffer)
|
|
SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FStrataGlobalUniformParameters, Strata)
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(ShaderPrint::FShaderParameters, ShaderPrintParameters)
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
static FPermutationDomain RemapPermutation(FPermutationDomain PermutationVector)
|
|
{
|
|
return PermutationVector;
|
|
}
|
|
|
|
static bool ShouldCompilePermutation(const FGlobalShaderPermutationParameters& Parameters)
|
|
{
|
|
return Strata::IsStrataEnabled() && StrataDebugVisualizationCanRunOnPlatform(Parameters.Platform) && EnumHasAllFlags(Parameters.Flags, EShaderPermutationFlags::HasEditorOnlyData);
|
|
}
|
|
|
|
static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
|
|
{
|
|
FGlobalShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
|
|
|
|
// Stay debug and skip optimizations to reduce compilation time on this long shader.
|
|
OutEnvironment.CompilerFlags.Add(CFLAG_Debug);
|
|
OutEnvironment.SetDefine(TEXT("SHADER_DEBUGSTRATATREE_CS"), 1);
|
|
}
|
|
};
|
|
IMPLEMENT_GLOBAL_SHADER(FMaterialDebugStrataTreeCS, "/Engine/Private/Strata/StrataVisualize.usf", "MaterialDebugStrataTreeCS", SF_Compute);
|
|
|
|
class FMaterialDebugStrataTreePS : public FGlobalShader
|
|
{
|
|
DECLARE_GLOBAL_SHADER(FMaterialDebugStrataTreePS);
|
|
SHADER_USE_PARAMETER_STRUCT(FMaterialDebugStrataTreePS, FGlobalShader);
|
|
|
|
using FPermutationDomain = TShaderPermutationDomain<>;
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
SHADER_PARAMETER_STRUCT_REF(FViewUniformShaderParameters, ViewUniformBuffer)
|
|
SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FStrataGlobalUniformParameters, Strata)
|
|
SHADER_PARAMETER_STRUCT_REF(FReflectionUniformParameters, ReflectionStruct)
|
|
SHADER_PARAMETER_STRUCT_REF(FReflectionCaptureShaderData, ReflectionCapture)
|
|
SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FForwardLightData, ForwardLightData)
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FSkyDiffuseLightingParameters, SkyDiffuseLighting)
|
|
RENDER_TARGET_BINDING_SLOTS()
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
static FPermutationDomain RemapPermutation(FPermutationDomain PermutationVector)
|
|
{
|
|
return PermutationVector;
|
|
}
|
|
|
|
static bool ShouldCompilePermutation(const FGlobalShaderPermutationParameters& Parameters)
|
|
{
|
|
return Strata::IsStrataEnabled() && StrataDebugVisualizationCanRunOnPlatform(Parameters.Platform) && EnumHasAllFlags(Parameters.Flags, EShaderPermutationFlags::HasEditorOnlyData);
|
|
}
|
|
|
|
static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
|
|
{
|
|
FGlobalShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
|
|
|
|
// Stay debug and skip optimizations to reduce compilation time on this long shader.
|
|
OutEnvironment.CompilerFlags.Add(CFLAG_Debug);
|
|
OutEnvironment.SetDefine(TEXT("SHADER_DEBUGSTRATATREE_PS"), 1);
|
|
}
|
|
};
|
|
IMPLEMENT_GLOBAL_SHADER(FMaterialDebugStrataTreePS, "/Engine/Private/Strata/StrataVisualize.usf", "MaterialDebugStrataTreePS", SF_Pixel);
|
|
|
|
static void AddVisualizeMaterialPropertiesPasses(FRDGBuilder& GraphBuilder, const FViewInfo& View, FScreenPassTexture& ScreenPassSceneColor, EShaderPlatform Platform)
|
|
{
|
|
// Force ShaderPrint on.
|
|
ShaderPrint::SetEnabled(true);
|
|
ShaderPrint::RequestSpaceForLines(1024);
|
|
ShaderPrint::RequestSpaceForCharacters(1024);
|
|
FRDGBufferUAVRef PrintOffsetBufferUAV = nullptr;
|
|
|
|
FRDGBufferRef PrintOffsetBuffer = GraphBuilder.CreateBuffer(FRDGBufferDesc::CreateBufferDesc(4, 2), TEXT("Strata.DebugPrintPositionOffset"));
|
|
PrintOffsetBufferUAV = GraphBuilder.CreateUAV(PrintOffsetBuffer, PF_R32_UINT);
|
|
AddClearUAVPass(GraphBuilder, PrintOffsetBufferUAV, 50u);
|
|
const uint32 MaxBSDFCount = 8;
|
|
|
|
for (uint32 BSDFIndex=0; BSDFIndex < MaxBSDFCount; ++BSDFIndex)
|
|
{
|
|
FMaterialPrintInfoCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FMaterialPrintInfoCS::FParameters>();
|
|
PassParameters->BSDFIndex = BSDFIndex;
|
|
PassParameters->RWPositionOffsetBuffer = PrintOffsetBufferUAV;
|
|
PassParameters->ViewUniformBuffer = View.ViewUniformBuffer;
|
|
PassParameters->Strata = Strata::BindStrataGlobalUniformParameters(View);
|
|
PassParameters->SceneTextures = GetSceneTextureParameters(GraphBuilder, View);
|
|
ShaderPrint::SetParameters(GraphBuilder, View.ShaderPrintData, PassParameters->ShaderPrintParameters);
|
|
|
|
TShaderMapRef<FMaterialPrintInfoCS> ComputeShader(View.ShaderMap);
|
|
FComputeShaderUtils::AddPass(GraphBuilder, RDG_EVENT_NAME("Strata::VisualizeMaterial(Print, BSDF=%d)", BSDFIndex), ComputeShader, PassParameters, FIntVector(1, 1, 1));
|
|
}
|
|
}
|
|
|
|
static void AddVisualizeMaterialCountPasses(FRDGBuilder & GraphBuilder, const FViewInfo & View, FScreenPassTexture & ScreenPassSceneColor, EShaderPlatform Platform)
|
|
{
|
|
ShaderPrint::SetEnabled(true);
|
|
ShaderPrint::RequestSpaceForLines(1024);
|
|
ShaderPrint::RequestSpaceForCharacters(1024);
|
|
|
|
FRDGTextureRef SceneColorTexture = ScreenPassSceneColor.Texture;
|
|
FRHIBlendState* PreMultipliedColorTransmittanceBlend = TStaticBlendState<CW_RGB, BO_Add, BF_One, BF_SourceAlpha, BO_Add, BF_Zero, BF_One>::GetRHI();
|
|
|
|
FVisualizeMaterialCountPS::FParameters* PassParameters = GraphBuilder.AllocParameters<FVisualizeMaterialCountPS::FParameters>();
|
|
PassParameters->ViewUniformBuffer = View.ViewUniformBuffer;
|
|
PassParameters->ViewMode = 2;
|
|
PassParameters->Strata = Strata::BindStrataGlobalUniformParameters(View);
|
|
PassParameters->SceneTextures = GetSceneTextureParameters(GraphBuilder, View);
|
|
PassParameters->RenderTargets[0] = FRenderTargetBinding(SceneColorTexture, ERenderTargetLoadAction::ELoad);
|
|
ShaderPrint::SetParameters(GraphBuilder, View.ShaderPrintData, PassParameters->ShaderPrintParameters);
|
|
|
|
FVisualizeMaterialCountPS::FPermutationDomain PermutationVector;
|
|
TShaderMapRef<FVisualizeMaterialCountPS> PixelShader(View.ShaderMap, PermutationVector);
|
|
|
|
FPixelShaderUtils::AddFullscreenPass<FVisualizeMaterialCountPS>(GraphBuilder, View.ShaderMap, RDG_EVENT_NAME("Strata::VisualizeMaterial(Draw)"), PixelShader, PassParameters, ScreenPassSceneColor.ViewRect, PreMultipliedColorTransmittanceBlend);
|
|
}
|
|
|
|
float GetStrataTileOverflowRatio(const FViewInfo& View);
|
|
bool IsClassificationCoord8bits();
|
|
bool IsClassificationAsync();
|
|
bool SupportsCMask(const FStaticShaderPlatform InPlatform);
|
|
bool DoesStrataTileOverflowUseMaterialData();
|
|
|
|
static void AddVisualizeSystemInfoPasses(FRDGBuilder& GraphBuilder, const FViewInfo& View, FScreenPassTexture& ScreenPassSceneColor, EShaderPlatform Platform)
|
|
{
|
|
// Force ShaderPrint on.
|
|
ShaderPrint::SetEnabled(true);
|
|
ShaderPrint::RequestSpaceForLines(1024);
|
|
ShaderPrint::RequestSpaceForCharacters(1024);
|
|
|
|
FStrataSystemInfoCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FStrataSystemInfoCS::FParameters>();
|
|
PassParameters->bAdvancedDebugEnabled = IsStrataAdvancedVisualizationShadersEnabled() ? 1u : 0u;
|
|
PassParameters->bEnergyConservation = View.ViewState ? View.ViewState->ShadingEnergyConservationData.bEnergyConservation : false;;
|
|
PassParameters->bEnergyPreservation = View.ViewState ? View.ViewState->ShadingEnergyConservationData.bEnergyPreservation : false;;
|
|
PassParameters->bDbufferPass = IsStrataDbufferPassEnabled(View.GetShaderPlatform()) ? 1 : 0;
|
|
PassParameters->ClassificationCMask = SupportsCMask(View.GetShaderPlatform()) ? 1 : 0;
|
|
PassParameters->ClassificationAsync = IsClassificationAsync() ? 1 : 0;
|
|
PassParameters->Classification8bits = IsClassificationCoord8bits() ? 1 : 0;
|
|
PassParameters->TileOverflowRatio = GetStrataTileOverflowRatio(View);
|
|
PassParameters->bTileOverflowUseMaterialData = DoesStrataTileOverflowUseMaterialData() ? 1 : 0;
|
|
PassParameters->bRoughRefraction = IsStrataOpaqueMaterialRoughRefractionEnabled() ? 1 : 0;
|
|
PassParameters->ClassificationTileDrawIndirectBuffer = GraphBuilder.CreateSRV(View.StrataViewData.ClassificationTileDrawIndirectBuffer, PF_R32_UINT);
|
|
PassParameters->ViewUniformBuffer = View.ViewUniformBuffer;
|
|
PassParameters->Strata = Strata::BindStrataGlobalUniformParameters(View);
|
|
PassParameters->SceneTextures = GetSceneTextureParameters(GraphBuilder, View);
|
|
ShaderPrint::SetParameters(GraphBuilder, View.ShaderPrintData, PassParameters->ShaderPrintParameters);
|
|
|
|
TShaderMapRef<FStrataSystemInfoCS> ComputeShader(View.ShaderMap);
|
|
FComputeShaderUtils::AddPass(GraphBuilder, RDG_EVENT_NAME("Strata::VisualizeSystemInfo"), ComputeShader, PassParameters, FIntVector(1, 1, 1));
|
|
}
|
|
|
|
// Draw each material layer independently
|
|
static void AddVisualizeAdvancedMaterialPasses(FRDGBuilder& GraphBuilder, const FViewInfo& View, FScreenPassTexture& ScreenPassSceneColor, EShaderPlatform Platform)
|
|
{
|
|
if (!IsStrataAdvancedVisualizationShadersEnabled())
|
|
{
|
|
return;
|
|
}
|
|
|
|
ShaderPrint::SetEnabled(true);
|
|
ShaderPrint::RequestSpaceForLines(1024);
|
|
ShaderPrint::RequestSpaceForCharacters(1024);
|
|
|
|
FRDGTextureRef SceneColorTexture = ScreenPassSceneColor.Texture;
|
|
FRHIBlendState* PreMultipliedColorTransmittanceBlend = TStaticBlendState<CW_RGB, BO_Add, BF_One, BF_SourceAlpha, BO_Add, BF_Zero, BF_One>::GetRHI();
|
|
{
|
|
FMaterialDebugStrataTreeCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FMaterialDebugStrataTreeCS::FParameters>();
|
|
PassParameters->ViewUniformBuffer = View.ViewUniformBuffer;
|
|
PassParameters->Strata = Strata::BindStrataGlobalUniformParameters(View);
|
|
ShaderPrint::SetParameters(GraphBuilder, View.ShaderPrintData, PassParameters->ShaderPrintParameters);
|
|
|
|
TShaderMapRef<FMaterialDebugStrataTreeCS> ComputeShader(View.ShaderMap);
|
|
FComputeShaderUtils::AddPass(GraphBuilder, RDG_EVENT_NAME("Strata::StrataAdvancedVisualization(Print)"), ComputeShader, PassParameters, FIntVector(1, 1, 1));
|
|
}
|
|
|
|
{
|
|
FMaterialDebugStrataTreePS::FParameters* PassParameters = GraphBuilder.AllocParameters<FMaterialDebugStrataTreePS::FParameters>();
|
|
PassParameters->ViewUniformBuffer = View.ViewUniformBuffer;
|
|
PassParameters->Strata = Strata::BindStrataGlobalUniformParameters(View);
|
|
PassParameters->ReflectionStruct = CreateReflectionUniformBuffer(View, UniformBuffer_SingleFrame);
|
|
PassParameters->ReflectionCapture = View.ReflectionCaptureUniformBuffer;
|
|
PassParameters->ForwardLightData = View.ForwardLightingResources.ForwardLightUniformBuffer;
|
|
PassParameters->RenderTargets[0] = FRenderTargetBinding(SceneColorTexture, ERenderTargetLoadAction::ELoad);
|
|
|
|
const float DynamicBentNormalAO = 0.0f;
|
|
FSkyLightSceneProxy* NullSkyLight = nullptr;
|
|
PassParameters->SkyDiffuseLighting = GetSkyDiffuseLightingParameters(NullSkyLight, DynamicBentNormalAO);
|
|
|
|
FMaterialDebugStrataTreePS::FPermutationDomain PermutationVector;
|
|
TShaderMapRef<FMaterialDebugStrataTreePS> PixelShader(View.ShaderMap, PermutationVector);
|
|
|
|
FPixelShaderUtils::AddFullscreenPass<FMaterialDebugStrataTreePS>(GraphBuilder, View.ShaderMap, RDG_EVENT_NAME("Strata::StrataAdvancedVisualization(Draw)"), PixelShader, PassParameters, ScreenPassSceneColor.ViewRect, PreMultipliedColorTransmittanceBlend);
|
|
}
|
|
}
|
|
|
|
bool ShouldRenderStrataRoughRefractionRnD();
|
|
void StrataRoughRefractionRnD(FRDGBuilder& GraphBuilder, const FViewInfo& View, FScreenPassTexture& ScreenPassSceneColor);
|
|
|
|
static FStrataVisualizationData::FViewMode GetStrataVisualizeMode(const FViewInfo & View)
|
|
{
|
|
FStrataVisualizationData::FViewMode Out = FStrataVisualizationData::FViewMode::None;
|
|
if (IsStrataEnabled() && StrataDebugVisualizationCanRunOnPlatform(View.GetShaderPlatform()))
|
|
{
|
|
// Variable defined in StrataVisualizationData.h/.cpp
|
|
static const auto CVarStrataViewMode = IConsoleManager::Get().FindConsoleVariable(FStrataVisualizationData::GetVisualizeConsoleCommandName());
|
|
const uint32 ViewMode = CVarStrataViewMode && CVarStrataViewMode->AsVariableInt() ? CVarStrataViewMode->AsVariableInt()->GetValueOnRenderThread() : 0;
|
|
switch (ViewMode)
|
|
{
|
|
case 1: return FStrataVisualizationData::FViewMode::MaterialProperties;
|
|
case 2: return FStrataVisualizationData::FViewMode::MaterialCount;
|
|
case 3: return FStrataVisualizationData::FViewMode::AdvancedMaterialProperties;
|
|
case 4: return FStrataVisualizationData::FViewMode::MaterialClassification;
|
|
case 5: return FStrataVisualizationData::FViewMode::DecalClassification;
|
|
case 6: return FStrataVisualizationData::FViewMode::RoughRefractionClassification;
|
|
case 7: return FStrataVisualizationData::FViewMode::StrataInfo;
|
|
}
|
|
|
|
const FStrataVisualizationData& VisualizationData = GetStrataVisualizationData();
|
|
if (View.Family && View.Family->EngineShowFlags.VisualizeStrata)
|
|
{
|
|
Out = VisualizationData.GetViewMode(View.CurrentStrataVisualizationMode);
|
|
}
|
|
}
|
|
return Out;
|
|
}
|
|
|
|
bool ShouldRenderStrataDebugPasses(const FViewInfo& View)
|
|
{
|
|
return GetStrataVisualizeMode(View) != FStrataVisualizationData::FViewMode::None || ShouldRenderStrataRoughRefractionRnD();
|
|
}
|
|
|
|
FScreenPassTexture AddStrataDebugPasses(FRDGBuilder& GraphBuilder, const FViewInfo& View, FScreenPassTexture& ScreenPassSceneColor)
|
|
{
|
|
check(IsStrataEnabled());
|
|
|
|
const FStrataVisualizationData::FViewMode DebugMode = GetStrataVisualizeMode(View);
|
|
if (DebugMode != FStrataVisualizationData::FViewMode::None)
|
|
{
|
|
RDG_EVENT_SCOPE(GraphBuilder, "Strata::VisualizeMaterial");
|
|
|
|
const bool bDebugPass = true;
|
|
if (DebugMode == FStrataVisualizationData::FViewMode::MaterialProperties)
|
|
{
|
|
AddVisualizeMaterialPropertiesPasses(GraphBuilder, View, ScreenPassSceneColor, View.GetShaderPlatform());
|
|
}
|
|
if (DebugMode == FStrataVisualizationData::FViewMode::MaterialCount)
|
|
{
|
|
AddVisualizeMaterialCountPasses(GraphBuilder, View, ScreenPassSceneColor, View.GetShaderPlatform());
|
|
}
|
|
if (DebugMode == FStrataVisualizationData::FViewMode::AdvancedMaterialProperties)
|
|
{
|
|
AddVisualizeAdvancedMaterialPasses(GraphBuilder, View, ScreenPassSceneColor, View.GetShaderPlatform());
|
|
}
|
|
else if (DebugMode == FStrataVisualizationData::FViewMode::StrataInfo)
|
|
{
|
|
AddVisualizeSystemInfoPasses(GraphBuilder, View, ScreenPassSceneColor, View.GetShaderPlatform());
|
|
}
|
|
else if (DebugMode == FStrataVisualizationData::FViewMode::DecalClassification)
|
|
{
|
|
if (IsStrataDbufferPassEnabled(View.GetShaderPlatform()))
|
|
{
|
|
AddStrataInternalClassificationTilePass(GraphBuilder, View, nullptr, &ScreenPassSceneColor.Texture, EStrataTileType::EDecalSimple, bDebugPass);
|
|
AddStrataInternalClassificationTilePass(GraphBuilder, View, nullptr, &ScreenPassSceneColor.Texture, EStrataTileType::EDecalSingle, bDebugPass);
|
|
AddStrataInternalClassificationTilePass(GraphBuilder, View, nullptr, &ScreenPassSceneColor.Texture, EStrataTileType::EDecalComplex, bDebugPass);
|
|
}
|
|
}
|
|
else if (DebugMode == FStrataVisualizationData::FViewMode::RoughRefractionClassification)
|
|
{
|
|
if (IsStrataOpaqueMaterialRoughRefractionEnabled())
|
|
{
|
|
AddStrataInternalClassificationTilePass(GraphBuilder, View, nullptr, &ScreenPassSceneColor.Texture, EStrataTileType::EOpaqueRoughRefraction, bDebugPass);
|
|
AddStrataInternalClassificationTilePass(GraphBuilder, View, nullptr, &ScreenPassSceneColor.Texture, EStrataTileType::EOpaqueRoughRefractionSSSWithout, bDebugPass);
|
|
}
|
|
}
|
|
else if (DebugMode == FStrataVisualizationData::FViewMode::MaterialClassification)
|
|
{
|
|
AddStrataInternalClassificationTilePass(GraphBuilder, View, nullptr, &ScreenPassSceneColor.Texture, EStrataTileType::EComplex, bDebugPass);
|
|
AddStrataInternalClassificationTilePass(GraphBuilder, View, nullptr, &ScreenPassSceneColor.Texture, EStrataTileType::ESingle, bDebugPass);
|
|
AddStrataInternalClassificationTilePass(GraphBuilder, View, nullptr, &ScreenPassSceneColor.Texture, EStrataTileType::ESimple, bDebugPass);
|
|
}
|
|
}
|
|
|
|
StrataRoughRefractionRnD(GraphBuilder, View, ScreenPassSceneColor);
|
|
|
|
return MoveTemp(ScreenPassSceneColor);
|
|
}
|
|
|
|
} // namespace Strata
|