2019-12-26 14:45:42 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2019-06-18 16:58:24 -04:00
|
|
|
#include "ScreenPass.h"
|
2019-10-01 13:03:04 -04:00
|
|
|
#include "OverridePassSequence.h"
|
2022-01-13 13:39:51 -05:00
|
|
|
#include "Strata/Strata.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
|
|
|
|
|
class UMaterialInterface;
|
2022-06-27 06:03:01 -04:00
|
|
|
struct FSceneWithoutWaterTextures;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2019-06-18 16:58:24 -04:00
|
|
|
const uint32 kPostProcessMaterialInputCountMax = 5;
|
|
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
using FPostProcessMaterialChain = TArray<const UMaterialInterface*, TInlineAllocator<10>>;
|
|
|
|
|
|
|
|
|
|
FPostProcessMaterialChain GetPostProcessMaterialChain(const FViewInfo& View, EBlendableLocation Location);
|
|
|
|
|
|
2019-06-18 16:58:24 -04:00
|
|
|
/** Named post process material slots. Inputs are aliased and have different semantics
|
|
|
|
|
* based on the post process material blend point, which is documented with the input.
|
|
|
|
|
*/
|
|
|
|
|
enum class EPostProcessMaterialInput : uint32
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2019-06-18 16:58:24 -04:00
|
|
|
// Always Active. Color from the previous stage of the post process chain.
|
|
|
|
|
SceneColor = 0,
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2019-06-18 16:58:24 -04:00
|
|
|
// Always Active.
|
|
|
|
|
SeparateTranslucency = 1,
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2019-06-18 16:58:24 -04:00
|
|
|
// Replace Tonemap Only. Half resolution combined bloom input.
|
|
|
|
|
CombinedBloom = 2,
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2019-06-18 16:58:24 -04:00
|
|
|
// Buffer Visualization Only.
|
|
|
|
|
PreTonemapHDRColor = 2,
|
|
|
|
|
PostTonemapHDRColor = 3,
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2019-06-18 16:58:24 -04:00
|
|
|
// Active if separate velocity pass is used--i.e. not part of base pass; Not active during Replace Tonemap.
|
|
|
|
|
Velocity = 4
|
2014-03-14 14:13:41 -04:00
|
|
|
};
|
2019-06-18 16:58:24 -04:00
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FPostProcessMaterialParameters, )
|
2020-06-23 18:40:00 -04:00
|
|
|
SHADER_PARAMETER_STRUCT_REF(FViewUniformShaderParameters, View)
|
|
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FSceneTextureShaderParameters, SceneTextures)
|
2022-01-13 13:39:51 -05:00
|
|
|
SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FStrataGlobalUniformParameters, Strata)
|
2019-10-01 13:03:04 -04:00
|
|
|
SHADER_PARAMETER_STRUCT(FScreenPassTextureViewportParameters, PostProcessOutput)
|
|
|
|
|
SHADER_PARAMETER_STRUCT_ARRAY(FScreenPassTextureInput, PostProcessInput, [kPostProcessMaterialInputCountMax])
|
|
|
|
|
SHADER_PARAMETER_SAMPLER(SamplerState, PostProcessInput_BilinearSampler)
|
2020-09-24 00:43:27 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, EyeAdaptationTexture)
|
2022-11-05 22:34:31 -04:00
|
|
|
SHADER_PARAMETER_RDG_BUFFER_SRV(StructuredBuffer<float4>, EyeAdaptationBuffer)
|
2020-02-26 21:42:01 -05:00
|
|
|
SHADER_PARAMETER(uint32, bMetalMSAAHDRDecode)
|
2022-06-27 06:03:01 -04:00
|
|
|
SHADER_PARAMETER(uint32, bSceneDepthWithoutWaterTextureAvailable)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, SceneDepthWithoutSingleLayerWaterTexture)
|
|
|
|
|
SHADER_PARAMETER_SAMPLER(SamplerState, SceneDepthWithoutSingleLayerWaterSampler)
|
|
|
|
|
SHADER_PARAMETER(FVector4f, SceneWithoutSingleLayerWaterMinMaxUV)
|
|
|
|
|
SHADER_PARAMETER(FVector2f, SceneWithoutSingleLayerWaterTextureSize)
|
|
|
|
|
SHADER_PARAMETER(FVector2f, SceneWithoutSingleLayerWaterInvTextureSize)
|
2019-10-01 13:03:04 -04:00
|
|
|
RENDER_TARGET_BINDING_SLOTS()
|
|
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
|
2019-06-18 16:58:24 -04:00
|
|
|
struct FPostProcessMaterialInputs
|
|
|
|
|
{
|
2019-10-01 13:03:04 -04:00
|
|
|
inline void SetInput(EPostProcessMaterialInput Input, FScreenPassTexture Texture)
|
2019-06-18 16:58:24 -04:00
|
|
|
{
|
2019-10-01 13:03:04 -04:00
|
|
|
Textures[(uint32)Input] = Texture;
|
2019-06-18 16:58:24 -04:00
|
|
|
}
|
|
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
inline FScreenPassTexture GetInput(EPostProcessMaterialInput Input) const
|
2019-06-18 16:58:24 -04:00
|
|
|
{
|
2019-10-01 13:03:04 -04:00
|
|
|
return Textures[(uint32)Input];
|
2019-06-18 16:58:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void Validate() const
|
|
|
|
|
{
|
|
|
|
|
ValidateInputExists(EPostProcessMaterialInput::SceneColor);
|
|
|
|
|
ValidateInputExists(EPostProcessMaterialInput::SeparateTranslucency);
|
|
|
|
|
|
|
|
|
|
// Either override output format is valid or the override output texture is; not both.
|
2019-10-01 13:03:04 -04:00
|
|
|
if (OutputFormat != PF_Unknown)
|
2019-06-18 16:58:24 -04:00
|
|
|
{
|
2019-10-01 13:03:04 -04:00
|
|
|
check(OverrideOutput.Texture == nullptr);
|
2019-06-18 16:58:24 -04:00
|
|
|
}
|
2019-10-01 13:03:04 -04:00
|
|
|
if (OverrideOutput.Texture)
|
2019-06-18 16:58:24 -04:00
|
|
|
{
|
2019-10-01 13:03:04 -04:00
|
|
|
check(OutputFormat == PF_Unknown);
|
2019-06-18 16:58:24 -04:00
|
|
|
}
|
2020-09-24 00:43:27 -04:00
|
|
|
|
|
|
|
|
check(SceneTextures.SceneTextures || SceneTextures.MobileSceneTextures);
|
2019-06-18 16:58:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void ValidateInputExists(EPostProcessMaterialInput Input) const
|
|
|
|
|
{
|
2019-10-01 13:03:04 -04:00
|
|
|
const FScreenPassTexture Texture = GetInput(EPostProcessMaterialInput::SceneColor);
|
2020-09-24 00:43:27 -04:00
|
|
|
check(Texture.IsValid());
|
2019-06-18 16:58:24 -04:00
|
|
|
}
|
|
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
// [Optional] Render to the specified output. If invalid, a new texture is created and returned.
|
|
|
|
|
FScreenPassRenderTarget OverrideOutput;
|
|
|
|
|
|
2019-06-18 16:58:24 -04:00
|
|
|
/** Array of input textures bound to the material. The first element represents the output from
|
|
|
|
|
* the previous post process and is required. All other inputs are optional.
|
|
|
|
|
*/
|
2019-10-01 13:03:04 -04:00
|
|
|
TStaticArray<FScreenPassTexture, kPostProcessMaterialInputCountMax> Textures;
|
2019-06-18 16:58:24 -04:00
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
/** The output texture format to use if a new texture is created. Uses the input format if left unknown. */
|
|
|
|
|
EPixelFormat OutputFormat = PF_Unknown;
|
2019-06-18 16:58:24 -04:00
|
|
|
|
|
|
|
|
/** Custom stencil texture used for stencil operations. */
|
|
|
|
|
FRDGTextureRef CustomDepthTexture = nullptr;
|
|
|
|
|
|
2020-09-24 00:43:27 -04:00
|
|
|
/** The uniform buffer containing all scene textures. */
|
|
|
|
|
FSceneTextureShaderParameters SceneTextures;
|
|
|
|
|
|
2022-06-27 06:03:01 -04:00
|
|
|
/** Depth and color textures of the scene without single layer water. May be nullptr if not available. */
|
|
|
|
|
const FSceneWithoutWaterTextures* SceneWithoutWaterTextures = nullptr;
|
|
|
|
|
|
2019-10-23 15:07:28 -04:00
|
|
|
/** Allows (but doesn't guarantee) an optimization where, if possible, the scene color input is reused as
|
|
|
|
|
* the output. This can elide a copy in certain circumstances; for example, when the scene color input isn't
|
|
|
|
|
* actually used by the post process material and no special depth-stencil / blend composition is required.
|
|
|
|
|
* Set this to false when you need to guarantee creation of a dedicated output texture.
|
|
|
|
|
*/
|
|
|
|
|
bool bAllowSceneColorInputAsOutput = true;
|
2020-06-23 18:40:00 -04:00
|
|
|
|
|
|
|
|
bool bMetalMSAAHDRDecode = false;
|
2019-06-18 16:58:24 -04:00
|
|
|
};
|
|
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
FScreenPassTexture AddPostProcessMaterialPass(
|
2019-08-06 18:34:02 -04:00
|
|
|
FRDGBuilder& GraphBuilder,
|
2019-10-01 13:03:04 -04:00
|
|
|
const FViewInfo& View,
|
2019-08-06 18:34:02 -04:00
|
|
|
const FPostProcessMaterialInputs& Inputs,
|
2020-06-23 18:40:00 -04:00
|
|
|
const UMaterialInterface* MaterialInterface);
|
2019-08-06 18:34:02 -04:00
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
FScreenPassTexture AddPostProcessMaterialChain(
|
2019-06-18 16:58:24 -04:00
|
|
|
FRDGBuilder& GraphBuilder,
|
2019-10-01 13:03:04 -04:00
|
|
|
const FViewInfo& View,
|
|
|
|
|
const FPostProcessMaterialInputs& Inputs,
|
|
|
|
|
const FPostProcessMaterialChain& MaterialChain);
|
2019-06-18 16:58:24 -04:00
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
struct FHighResolutionScreenshotMaskInputs
|
|
|
|
|
{
|
|
|
|
|
// [Optional] Render to the specified output. If invalid, a new texture is created and returned.
|
|
|
|
|
FScreenPassRenderTarget OverrideOutput;
|
2019-06-18 16:58:24 -04:00
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
FScreenPassTexture SceneColor;
|
2019-06-18 16:58:24 -04:00
|
|
|
|
2020-09-24 00:43:27 -04:00
|
|
|
FSceneTextureShaderParameters SceneTextures;
|
|
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
UMaterialInterface* Material = nullptr;
|
|
|
|
|
UMaterialInterface* MaskMaterial = nullptr;
|
|
|
|
|
UMaterialInterface* CaptureRegionMaterial = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool IsHighResolutionScreenshotMaskEnabled(const FViewInfo& View);
|
|
|
|
|
|
|
|
|
|
FScreenPassTexture AddHighResolutionScreenshotMaskPass(
|
|
|
|
|
FRDGBuilder& GraphBuilder,
|
|
|
|
|
const FViewInfo& View,
|
2020-09-24 00:43:27 -04:00
|
|
|
const FHighResolutionScreenshotMaskInputs& Inputs);
|