UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PostProcessCompositePrimitivesCommon.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "ScreenPass.h"
9
10//UE_ENABLE_DEBUG_DRAWING i.e. !(UE_BUILD_SHIPPING || UE_BUILD_TEST) || WITH_EDITOR
11//Only available in Debug/Development/Editor builds due to current use cases, but can be extended in future
12#if UE_ENABLE_DEBUG_DRAWING
13
16{
17public:
18 static const uint32 kMSAASampleCountMax = 8;
19
20 class FSampleCountDimension : SHADER_PERMUTATION_RANGE_INT("MSAA_SAMPLE_COUNT", 1, kMSAASampleCountMax + 1);
21 class FMSAADontResolve : SHADER_PERMUTATION_BOOL("MSAA_DONT_RESOLVE");
22 using FPermutationDomain = TShaderPermutationDomain<FSampleCountDimension, FMSAADontResolve>;
23
24 static bool ShouldCompilePermutation(const FPermutationDomain& PermutationVector, const EShaderPlatform Platform)
25 {
26 const int32 SampleCount = PermutationVector.Get<FSampleCountDimension>();
28
29 // Only use permutations with valid MSAA sample counts.
30 if (!FMath::IsPowerOfTwo(SampleCount))
31 {
32 return false;
33 }
34 if (!RHISupportsMSAA(Platform) && (SampleCount > 1 || bMSAADontResolve))
35 {
36 return false;
37 }
38
39 return IsPCPlatform(Platform);
40 }
41
43 {
44 const FPermutationDomain PermutationVector(Parameters.PermutationId);
46 }
47
49 FCompositePrimitiveShaderBase(const ShaderMetaType::CompiledShaderInitializerType& Initializer)
51 {}
52};
53
55{
56 enum class EBasePassType : uint32
57 {
59 Mobile,
60 MAX
61 };
62 // [Required] The type of base pass to use for rendering editor primitives.
63 EBasePassType BasePassType = EBasePassType::MAX;
64
65 // [Optional] Render to the specified output. If invalid, a new texture is created and returned.
66 FScreenPassRenderTarget OverrideOutput;
67
68 // [Optional] Render the depth to the specified output.
70
71 // [Required] The scene color to composite with editor primitives.
73
74 // [Required] The scene depth to composite with editor primitives.
76
77 // [Optional] Lens distortion applied on the scene color.
78 FLensDistortionLUT LensDistortionLUT;
79
80 bool bUseMetalMSAAHDRDecode = false;
81};
82
83// Constructs a new view suitable for rendering debug primitives.
84const FViewInfo* CreateCompositePrimitiveView(const FViewInfo& ParentView, FIntRect ViewRect, uint32 NumMSAASamples);
85
87 FRDGBuilder& GraphBuilder,
88 const FViewInfo& View,
92
93void PopulateDepthPass(FRDGBuilder& GraphBuilder,
94 const FViewInfo& View,
100 uint32 NumMSAASamples,
101 bool bForceDrawColor = false,
102 bool bUseMetalPlatformHDRDecode = false);
103
104
106{
107public:
108 class FWriteDepth : SHADER_PERMUTATION_BOOL("WRITE_DEPTH");
109
110 using FPermutationDomain = TShaderPermutationDomain<FWriteDepth, FSampleCountDimension, FMSAADontResolve>;
111
112 DECLARE_GLOBAL_SHADER(FCompositePostProcessPrimitivesPS);
113 SHADER_USE_PARAMETER_STRUCT(FCompositePostProcessPrimitivesPS, FCompositePrimitiveShaderBase);
114
115 BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
116 SHADER_PARAMETER_STRUCT_REF(FViewUniformShaderParameters, View)
117 SHADER_PARAMETER_STRUCT(FScreenPassTextureViewportParameters, Color)
118 SHADER_PARAMETER_STRUCT(FScreenPassTextureViewportParameters, Depth)
119 SHADER_PARAMETER_STRUCT(FScreenPassTextureViewportParameters, EditorPrimitives)
120 SHADER_PARAMETER_ARRAY(FVector4f, SampleOffsetArray, [FCompositePrimitiveShaderBase::kMSAASampleCountMax])
121
122 SHADER_PARAMETER_RDG_TEXTURE(Texture2D, UndistortingDisplacementTexture)
123 SHADER_PARAMETER_SAMPLER(SamplerState, UndistortingDisplacementSampler)
124 SHADER_PARAMETER_RDG_TEXTURE(Texture2D, EditorPrimitivesDepth)
125 SHADER_PARAMETER_RDG_TEXTURE(Texture2D, EditorPrimitivesColor)
126 SHADER_PARAMETER_RDG_TEXTURE(Texture2D, ColorTexture)
127 SHADER_PARAMETER_SAMPLER(SamplerState, ColorSampler)
128 SHADER_PARAMETER_RDG_TEXTURE(Texture2D, DepthTexture)
129 SHADER_PARAMETER_SAMPLER(SamplerState, DepthSampler)
130
131 SHADER_PARAMETER(FScreenTransform, PassSvPositionToViewportUV)
132 SHADER_PARAMETER(FScreenTransform, ViewportUVToColorUV)
133 SHADER_PARAMETER(FScreenTransform, ViewportUVToDepthUV)
134 SHADER_PARAMETER(FScreenTransform, ViewportUVToEditorPrimitivesUV)
135 SHADER_PARAMETER(uint32, bOpaqueEditorGizmo)
136 SHADER_PARAMETER(uint32, bCompositeAnyNonNullDepth)
137 SHADER_PARAMETER(FVector2f, DepthTextureJitter)
138 SHADER_PARAMETER(uint32, bProcessAlpha)
139 SHADER_PARAMETER(float, OccludedDithering)
140 SHADER_PARAMETER(float, OccludedBrightness)
143
144 static bool ShouldCompilePermutation(const FPermutationDomain& PermutationVector, const EShaderPlatform Platform)
145 {
146 const int32 SampleCount = PermutationVector.Get<FSampleCountDimension>();
148
149 // Only use permutations with valid MSAA sample counts.
150 if (!FMath::IsPowerOfTwo(SampleCount))
151 {
152 return false;
153 }
154 if (!RHISupportsMSAA(Platform) && (SampleCount > 1 || bMSAADontResolve))
155 {
156 return false;
157 }
158
159 return true;
160 }
161
163 {
164 const FPermutationDomain PermutationVector(Parameters.PermutationId);
166 }
167
169 {
170 FCompositePrimitiveShaderBase::ModifyCompilationEnvironment(Parameters, OutEnvironment);
171 }
172};
173
174#endif //#if UE_ENABLE_DEBUG_DRAWING
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
bool RHISupportsMSAA(const FStaticShaderPlatform Platform)
Definition DataDrivenShaderPlatformInfo.h:1115
bool IsPCPlatform(const FStaticShaderPlatform Platform)
Definition DataDrivenShaderPlatformInfo.h:922
#define DECLARE_GLOBAL_SHADER(ShaderClass)
Definition GlobalShader.h:408
const bool
Definition NetworkReplayStreaming.h:178
#define SHADER_PARAMETER_RDG_TEXTURE(ShaderType, MemberName)
Definition ShaderParameterMacros.h:1752
#define SHADER_PARAMETER_ARRAY(MemberType, MemberName, ArrayDecl)
Definition ShaderParameterMacros.h:1696
#define SHADER_PARAMETER_SAMPLER(ShaderType, MemberName)
Definition ShaderParameterMacros.h:1740
#define BEGIN_SHADER_PARAMETER_STRUCT(StructTypeName, DllStorage)
Definition ShaderParameterMacros.h:1482
#define SHADER_PARAMETER_STRUCT_REF(StructType, MemberName)
Definition ShaderParameterMacros.h:1909
#define RENDER_TARGET_BINDING_SLOTS()
Definition ShaderParameterMacros.h:1955
#define END_SHADER_PARAMETER_STRUCT()
Definition ShaderParameterMacros.h:1485
#define SHADER_PARAMETER_STRUCT(StructType, MemberName)
Definition ShaderParameterMacros.h:1847
#define SHADER_PARAMETER(MemberType, MemberName)
Definition ShaderParameterMacros.h:1684
#define SHADER_USE_PARAMETER_STRUCT(ShaderClass, ShaderParentClass)
Definition ShaderParameterStruct.h:62
#define SHADER_PERMUTATION_RANGE_INT(InDefineName, Start, Count)
Definition ShaderPermutation.h:499
#define SHADER_PERMUTATION_BOOL(InDefineName)
Definition ShaderPermutation.h:482
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition GlobalShader.h:269
static bool ShouldCompilePermutation(const FShaderPermutationParameters &)
Definition Shader.h:860
Definition RenderGraphBuilder.h:49
Definition RenderGraphResources.h:571
Definition SceneRendering.h:1132
FSolverCollisionParticles class
Definition PBDSoftsEvolutionFwd.h:38
void ModifyCompilationEnvironment(EShaderPlatform Platform, FDecalBlendDesc DecalBlendDesc, EDecalRenderStage DecalRenderStage, FShaderCompilerEnvironment &OutEnvironment)
Definition DecalRenderingCommon.cpp:959
bool ShouldCompilePermutation(ELightmapQuality LightmapQuality, const FMeshMaterialShaderPermutationParameters &Parameters)
Definition LightMapRendering.cpp:48
Definition GlobalShader.h:73
Definition LensDistortion.h:8
static constexpr UE_FORCEINLINE_HINT bool IsPowerOfTwo(T Value)
Definition UnrealMathUtility.h:519
Definition ScreenPass.h:83
Definition ScreenPass.h:41
Definition ShaderCore.h:544
const int32 PermutationId
Definition ShaderPermutation.h:32
const EShaderPlatform Platform
Definition ShaderPermutation.h:29
Definition ShaderPermutation.h:229