2016-01-07 08:17:16 -05:00
|
|
|
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
/*=============================================================================
|
|
|
|
|
PostProcessSubsurface.cpp: Screenspace subsurface scattering implementation.
|
|
|
|
|
=============================================================================*/
|
|
|
|
|
|
|
|
|
|
#include "RendererPrivate.h"
|
|
|
|
|
#include "ScenePrivate.h"
|
|
|
|
|
#include "SceneFilterRendering.h"
|
|
|
|
|
#include "PostProcessSubsurface.h"
|
|
|
|
|
#include "PostProcessing.h"
|
2014-08-21 06:03:00 -04:00
|
|
|
#include "SceneUtils.h"
|
2015-07-29 17:46:15 -04:00
|
|
|
#include "CompositionLighting/PostProcessPassThrough.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-07-29 18:02:49 -04:00
|
|
|
ENGINE_API const IPooledRenderTarget* GetSubsufaceProfileTexture_RT(FRHICommandListImmediate& RHICmdList);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-09-05 17:48:09 -04:00
|
|
|
|
2016-02-16 05:48:48 -05:00
|
|
|
static TAutoConsoleVariable<int32> CVarSSSQuality(
|
|
|
|
|
TEXT("r.SSS.Quality"),
|
|
|
|
|
0,
|
|
|
|
|
TEXT("Defines the quality of the recombine pass when using the SubsurfaceScatteringProfile shading model\n")
|
|
|
|
|
TEXT(" 0: low (faster, default)\n")
|
|
|
|
|
TEXT(" 1: high (sharper details but slower)\n")
|
|
|
|
|
TEXT("-1: auto, 1 if TemporalAA is disabled (without TemporalAA the quality is more noticable)"),
|
|
|
|
|
ECVF_RenderThreadSafe | ECVF_Scalability);
|
|
|
|
|
|
2014-10-16 13:08:38 -04:00
|
|
|
static TAutoConsoleVariable<int32> CVarSSSFilter(
|
|
|
|
|
TEXT("r.SSS.Filter"),
|
|
|
|
|
1,
|
2015-07-20 12:22:51 -04:00
|
|
|
TEXT("Defines the filter method for Screenspace Subsurface Scattering feature.\n")
|
|
|
|
|
TEXT(" 0: point filter (useful for testing, could be cleaner)\n")
|
|
|
|
|
TEXT(" 1: bilinear filter"),
|
2014-10-16 13:08:38 -04:00
|
|
|
ECVF_RenderThreadSafe | ECVF_Scalability);
|
|
|
|
|
|
2014-09-05 17:48:09 -04:00
|
|
|
static TAutoConsoleVariable<int32> CVarSSSSampleSet(
|
|
|
|
|
TEXT("r.SSS.SampleSet"),
|
2014-10-16 15:44:10 -04:00
|
|
|
2,
|
2015-07-20 12:22:51 -04:00
|
|
|
TEXT("Defines how many samples we use for Screenspace Subsurface Scattering feature.\n")
|
|
|
|
|
TEXT(" 0: lowest quality (6*2+1)\n")
|
|
|
|
|
TEXT(" 1: medium quality (9*2+1)\n")
|
|
|
|
|
TEXT(" 2: high quality (13*2+1) (default)"),
|
2014-09-05 17:48:09 -04:00
|
|
|
ECVF_RenderThreadSafe | ECVF_Scalability);
|
|
|
|
|
|
2014-10-15 16:18:43 -04:00
|
|
|
// -------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
float GetSubsurfaceRadiusScale()
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-10-15 16:18:43 -04:00
|
|
|
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.SSS.Scale"));
|
|
|
|
|
check(CVar);
|
|
|
|
|
float Ret = CVar->GetValueOnRenderThread();
|
|
|
|
|
|
|
|
|
|
return FMath::Max(0.0f, Ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/** Shared shader parameters needed for screen space subsurface scattering. */
|
|
|
|
|
class FSubsurfaceParameters
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
void Bind(const FShaderParameterMap& ParameterMap)
|
|
|
|
|
{
|
|
|
|
|
SSSParams.Bind(ParameterMap, TEXT("SSSParams"));
|
|
|
|
|
SSProfilesTexture.Bind(ParameterMap, TEXT("SSProfilesTexture"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetParameters(FRHICommandList& RHICmdList, const FPixelShaderRHIParamRef& ShaderRHI, const FRenderingCompositePassContext& Context) const
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
// from Separabale.usf: float distanceToProjectionWindow = 1.0 / tan(0.5 * radians(SSSS_FOVY))
|
|
|
|
|
// can be extracted out of projection matrix
|
|
|
|
|
|
2015-05-29 10:47:57 -04:00
|
|
|
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(RHICmdList);
|
2014-10-15 16:18:43 -04:00
|
|
|
|
|
|
|
|
// Calculate the sssWidth scale (1.0 for a unit plane sitting on the projection window):
|
|
|
|
|
float DistanceToProjectionWindow = Context.View.ViewMatrices.ProjMatrix.M[0][0];
|
|
|
|
|
|
|
|
|
|
float SSSScaleZ = DistanceToProjectionWindow * GetSubsurfaceRadiusScale();
|
|
|
|
|
|
|
|
|
|
// * 0.5f: hacked in 0.5 - -1..1 to 0..1 but why this isn't in demo code?
|
2015-07-29 16:42:44 -04:00
|
|
|
float SSSScaleX = SSSScaleZ / SUBSURFACE_KERNEL_SIZE * 0.5f;
|
2014-10-15 16:18:43 -04:00
|
|
|
|
2015-07-29 16:42:44 -04:00
|
|
|
FVector4 ColorScale(SSSScaleX, SSSScaleZ, 0, 0);
|
2014-10-15 16:18:43 -04:00
|
|
|
SetShaderValue(Context.RHICmdList, ShaderRHI, SSSParams, ColorScale);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
const IPooledRenderTarget* PooledRT = GetSubsufaceProfileTexture_RT(Context.RHICmdList);
|
|
|
|
|
|
2014-11-19 17:01:23 -05:00
|
|
|
if(!PooledRT)
|
|
|
|
|
{
|
|
|
|
|
// no subsurface profile was used yet
|
|
|
|
|
PooledRT = GSystemTextures.BlackDummy;
|
|
|
|
|
}
|
2014-10-15 16:18:43 -04:00
|
|
|
|
|
|
|
|
const FSceneRenderTargetItem& Item = PooledRT->GetRenderTargetItem();
|
|
|
|
|
|
2014-12-16 16:01:12 -05:00
|
|
|
SetTextureParameter(Context.RHICmdList, ShaderRHI, SSProfilesTexture, Item.ShaderResourceTexture);
|
2014-10-15 16:18:43 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend FArchive& operator<<(FArchive& Ar,FSubsurfaceParameters& P)
|
|
|
|
|
{
|
2014-12-16 16:01:12 -05:00
|
|
|
Ar << P.SSSParams << P.SSProfilesTexture;
|
2014-10-15 16:18:43 -04:00
|
|
|
return Ar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
FShaderParameter SSSParams;
|
|
|
|
|
FShaderResourceParameter SSProfilesTexture;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Encapsulates the post processing subsurface scattering pixel shader.
|
|
|
|
|
*/
|
|
|
|
|
class FPostProcessSubsurfaceVisualizePS : public FGlobalShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_SHADER_TYPE(FPostProcessSubsurfaceVisualizePS , Global);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
static bool ShouldCache(EShaderPlatform Platform)
|
|
|
|
|
{
|
2014-11-19 17:00:58 -05:00
|
|
|
return IsFeatureLevelSupported(Platform, ERHIFeatureLevel::SM4);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ModifyCompilationEnvironment(EShaderPlatform Platform, FShaderCompilerEnvironment& OutEnvironment)
|
|
|
|
|
{
|
|
|
|
|
FGlobalShader::ModifyCompilationEnvironment(Platform, OutEnvironment);
|
2015-07-29 16:42:44 -04:00
|
|
|
OutEnvironment.SetDefine(TEXT("SUBSURFACE_RADIUS_SCALE"), SUBSURFACE_RADIUS_SCALE);
|
|
|
|
|
OutEnvironment.SetDefine(TEXT("SUBSURFACE_KERNEL_SIZE"), SUBSURFACE_KERNEL_SIZE);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Default constructor. */
|
2014-10-15 16:18:43 -04:00
|
|
|
FPostProcessSubsurfaceVisualizePS () {}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
FPostProcessPassParameters PostprocessParameter;
|
|
|
|
|
FDeferredPixelShaderParameters DeferredParameters;
|
2014-08-22 14:15:05 -04:00
|
|
|
FShaderResourceParameter MiniFontTexture;
|
2014-10-15 16:18:43 -04:00
|
|
|
FSubsurfaceParameters SubsurfaceParameters;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
/** Initialization constructor. */
|
2014-10-15 16:18:43 -04:00
|
|
|
FPostProcessSubsurfaceVisualizePS(const ShaderMetaType::CompiledShaderInitializerType& Initializer)
|
2014-03-14 14:13:41 -04:00
|
|
|
: FGlobalShader(Initializer)
|
|
|
|
|
{
|
|
|
|
|
PostprocessParameter.Bind(Initializer.ParameterMap);
|
|
|
|
|
DeferredParameters.Bind(Initializer.ParameterMap);
|
2014-08-22 14:15:05 -04:00
|
|
|
MiniFontTexture.Bind(Initializer.ParameterMap, TEXT("MiniFontTexture"));
|
2014-10-15 16:18:43 -04:00
|
|
|
SubsurfaceParameters.Bind(Initializer.ParameterMap);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2014-06-12 07:13:34 -04:00
|
|
|
void SetParameters(const FRenderingCompositePassContext& Context)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
const FFinalPostProcessSettings& Settings = Context.View.FinalPostProcessSettings;
|
|
|
|
|
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader();
|
|
|
|
|
|
2014-06-12 07:13:34 -04:00
|
|
|
FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View);
|
|
|
|
|
PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI());
|
|
|
|
|
DeferredParameters.Set(Context.RHICmdList, ShaderRHI, Context.View);
|
2014-08-22 14:15:05 -04:00
|
|
|
SetTextureParameter(Context.RHICmdList, ShaderRHI, MiniFontTexture, GEngine->MiniFontTexture ? GEngine->MiniFontTexture->Resource->TextureRHI : GSystemTextures.WhiteDummy->GetRenderTargetItem().TargetableTexture);
|
2014-10-15 16:18:43 -04:00
|
|
|
SubsurfaceParameters.SetParameters(Context.RHICmdList, ShaderRHI, Context);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FShader interface.
|
2015-04-01 07:20:55 -04:00
|
|
|
virtual bool Serialize(FArchive& Ar) override
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
bool bShaderHasOutdatedParameters = FGlobalShader::Serialize(Ar);
|
2014-10-15 16:18:43 -04:00
|
|
|
Ar << PostprocessParameter << DeferredParameters << MiniFontTexture << SubsurfaceParameters;
|
2014-03-14 14:13:41 -04:00
|
|
|
return bShaderHasOutdatedParameters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const TCHAR* GetSourceFilename()
|
|
|
|
|
{
|
|
|
|
|
return TEXT("PostProcessSubsurface");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const TCHAR* GetFunctionName()
|
|
|
|
|
{
|
2014-10-15 16:18:43 -04:00
|
|
|
return TEXT("VisualizePS");
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-15 16:18:43 -04:00
|
|
|
IMPLEMENT_SHADER_TYPE3(FPostProcessSubsurfaceVisualizePS, SF_Pixel);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-10-15 16:18:43 -04:00
|
|
|
void SetSubsurfaceVisualizeShader(const FRenderingCompositePassContext& Context)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-08-28 06:22:54 -04:00
|
|
|
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
|
2014-10-15 16:18:43 -04:00
|
|
|
TShaderMapRef<FPostProcessSubsurfaceVisualizePS> PixelShader(Context.GetShaderMap());
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
static FGlobalBoundShaderState BoundShaderState;
|
|
|
|
|
|
2014-08-19 10:41:34 -04:00
|
|
|
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-06-12 07:13:34 -04:00
|
|
|
PixelShader->SetParameters(Context);
|
|
|
|
|
VertexShader->SetParameters(Context);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2015-09-21 20:07:00 -04:00
|
|
|
FRCPassPostProcessSubsurfaceVisualize::FRCPassPostProcessSubsurfaceVisualize(FRHICommandList& RHICmdList)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-10-15 16:18:43 -04:00
|
|
|
// we need the GBuffer, we release it Process()
|
2015-09-21 20:07:00 -04:00
|
|
|
FSceneRenderTargets::Get_Todo_PassContext().AdjustGBufferRefCount(RHICmdList, 1);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2014-10-15 16:18:43 -04:00
|
|
|
void FRCPassPostProcessSubsurfaceVisualize::Process(FRenderingCompositePassContext& Context)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2016-02-16 05:48:48 -05:00
|
|
|
SCOPED_DRAW_EVENT(Context.RHICmdList, SubsurfaceVisualize);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
|
|
|
|
|
|
|
|
|
|
if(!InputDesc)
|
|
|
|
|
{
|
|
|
|
|
// input is not hooked up correctly
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FSceneView& View = Context.View;
|
|
|
|
|
const FSceneViewFamily& ViewFamily = *(View.Family);
|
|
|
|
|
|
|
|
|
|
FIntPoint SrcSize = InputDesc->Extent;
|
|
|
|
|
FIntPoint DestSize = PassOutputs[0].RenderTargetDesc.Extent;
|
|
|
|
|
|
2015-05-29 10:47:57 -04:00
|
|
|
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(Context.RHICmdList);
|
2014-03-14 14:13:41 -04:00
|
|
|
// e.g. 4 means the input texture is 4x smaller than the buffer size
|
2015-05-29 10:47:57 -04:00
|
|
|
uint32 ScaleFactor = SceneContext.GetBufferSizeXY().X / SrcSize.X;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
FIntRect SrcRect = View.ViewRect / ScaleFactor;
|
2014-10-15 16:18:43 -04:00
|
|
|
FIntRect DestRect = SrcRect;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
|
|
|
|
|
|
|
|
|
|
// Set the view family's render target/viewport.
|
2014-06-12 07:13:34 -04:00
|
|
|
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
// is optimized away if possible (RT size=view size, )
|
2014-06-12 07:13:34 -04:00
|
|
|
Context.RHICmdList.Clear(true, FLinearColor::Black, false, 1.0f, false, 0, DestRect);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
Context.SetViewportAndCallRHI(0, 0, 0.0f, DestSize.X, DestSize.Y, 1.0f );
|
|
|
|
|
|
|
|
|
|
// set the state
|
2014-06-12 07:13:34 -04:00
|
|
|
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
|
|
|
|
|
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
|
|
|
|
|
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-10-15 16:18:43 -04:00
|
|
|
SetSubsurfaceVisualizeShader(Context);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
// Draw a quad mapping scene color to the view's render target
|
2014-08-28 06:22:54 -04:00
|
|
|
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
|
2014-03-14 14:13:41 -04:00
|
|
|
DrawRectangle(
|
2014-06-12 07:13:34 -04:00
|
|
|
Context.RHICmdList,
|
2014-03-14 14:13:41 -04:00
|
|
|
DestRect.Min.X, DestRect.Min.Y,
|
|
|
|
|
DestRect.Width(), DestRect.Height(),
|
|
|
|
|
SrcRect.Min.X, SrcRect.Min.Y,
|
|
|
|
|
SrcRect.Width(), SrcRect.Height(),
|
|
|
|
|
DestSize,
|
|
|
|
|
SrcSize,
|
2014-04-23 17:26:59 -04:00
|
|
|
*VertexShader,
|
2014-03-14 14:13:41 -04:00
|
|
|
EDRF_UseTriangleOptimization);
|
|
|
|
|
|
2014-08-22 14:15:05 -04:00
|
|
|
{
|
Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 3072736)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3055495 on 2016/07/19 by Marc.Olano
Allow Noise material node on mobile
No reason to exclude mobile, except for Fast Gradient Noise, which uses 3D textures. Allow this node on ES2 for all of the other noise functions.
#jira UE-33345
Change 3055602 on 2016/07/19 by Luke.Thatcher
Fix crash bug in D3D11 RHI when selecting adapters.
- Array of adapter descriptors will get out of sync with the adapter index if any adapter is skipped (e.g. the Microsoft Basic Render Device).
#jira UE-33236
Change 3055890 on 2016/07/19 by Daniel.Wright
Improved the assert in LoadModuleChecked so we won't have to check the log to see which module it was
Change 3055891 on 2016/07/19 by Daniel.Wright
Fixed Global Distance Field not dirtying previous object position on UpdateTransform - left behind a phantom shadow on teleports
* This will effectively double partial distiance field update costs until clipping of the update regions is implemented
Change 3055892 on 2016/07/19 by Daniel.Wright
Higher poly light source shapes drawn into reflection captures
Change 3055893 on 2016/07/19 by Daniel.Wright
More info to 'Incompatible surface format' GNM assert
Change 3055904 on 2016/07/19 by Daniel.Wright
Reflection environment normalization improvements
* Indirect specular from reflection captures is now mixed with indirect diffuse from lightmaps based on roughness, such that a mirror surface will have no mixing. Reflection captures now match other reflection methods like SSR and planar reflections much more closely.
* When a stationary skylight is present, Reflection captures are now normalized as if the initial skylight will always be present, giving consistent results with static skylight reflections. The skylight and reflection captures with sky removed used to be normalized separately, compacting the relative brightness between the sky and scene.
* Added r.ReflectionEnvironmentLightmapMixing for debugging lightmap mixing issues. This toggle was previously not possible due to prenormalizing the capture data.
* The standard deferred reflection path (r.DoTiledReflections 0) can no longer match the results of the compute path or base pass reflections, as it would require MRT to accumulate the average brightness
* Removed unused r.DiffuseFromCaptures
* Cost of reflection environment on PS4 increased from 1.52ms -> 1.75ms with this change, but decreased back to 1.58ms by reducing tile size to 8x8
Change 3055905 on 2016/07/19 by Daniel.Wright
Workaround for RTDF shadows not working on PS4 - manual clear of ObjectIndirectArguments instead of RHICmdList.ClearUAV
Change 3059486 on 2016/07/21 by Nick.Penwarden
Testing #uecritical
Change 3060558 on 2016/07/21 by Daniel.Wright
Fixed skylight with specified cubemap being black
Change 3061999 on 2016/07/22 by Marcus.Wassmer
Disable old AMD driver hacks for DX11. QA has already tested with them off and given thumbs up.
Change 3062241 on 2016/07/22 by Daniel.Wright
Fixed bug in RHISupportsSeparateMSAAAndResolveTextures that was preventing MSAA for any non-Vulkan platforms
Change 3062244 on 2016/07/22 by Daniel.Wright
Discard old prenormalized reflection environment data on load
Change 3062283 on 2016/07/22 by Daniel.Wright
MSAA support for the forward renderer
* AntiAliasing method is chosen in Rendering project settings, DefaultSettings category
* Deferred passes like shadow projection, fogging and decals are only computed per-pixel and can introduce aliasing
* Added Rendering project setting VertexFoggingForOpaque, which makes height fog cheaper and work properly with MSAA
* The AntiAliasing method in PostProcessSettings has been removed, this may affect existing content
* Added r.MSAACount which defaults to 4
* Integrated wide custom resolve filter from Oculus renderer, controlled by r.WideCustomResolve
* GBuffer targets are no longer allocated when using the forward renderer
* Decal blend modes that write to the GBuffer fall back to SceneColor emissive only
Change 3062666 on 2016/07/23 by Uriel.Doyon
Added legend to streaming accuracy viewmodes
Added a new helper class FRenderTargetTemp to be reused in different canvas rendering.
Exposed the pass through pixel shader so that it can be reused.
#review-3058986 @marcus.wassmer
Change 3063023 on 2016/07/25 by Luke.Thatcher
Fix "RecompileShaders Changed" when using Cook On The Fly.
#jira UE-33573
Change 3063078 on 2016/07/25 by Ben.Woodhouse
Add -emitdrawevents command line option to emit draw events by default. This is useful when capturing with Renderdoc
Change 3063315 on 2016/07/25 by Ben.Woodhouse
Fix div 0 in motion blur. This caused artifacts in some fairly common cases
#jira UE-32331
Change 3063897 on 2016/07/25 by Uriel.Doyon
Fixed missing qualifier on interpolants
Change 3064559 on 2016/07/26 by Ben.Woodhouse
Fix for cooker crash with BC6H textures (XB1, but may affect other platforms). Also fixes corruption issue with texture slices not being a multiple of 4 pixels (expanding as necessary), courtesy of Stu McKenna at the Coalition
Tested fix on xbox, PC and PS4, using QAGame
#jira UE-28592
Change 3064896 on 2016/07/26 by Ben.Woodhouse
Fix compile errors on PS4 (the variable "sample" was conflicting with a keyword, causing compile errors). Also making encoding consistent on new shaders (ansi rather than UTF16)
Change 3064913 on 2016/07/26 by Ben.Marsh
Fix spelling of "Editor, Tools, Monolithics & DDC" node in Dev-Rendering build settings.
Change 3065326 on 2016/07/26 by Uriel.Doyon
Fixed UnbuiltInstanceBoundsList not being reset correctly, creating broken rendered primitives.
#jira UE-32585
Change 3065541 on 2016/07/26 by Daniel.Wright
Materials with a GBuffer SceneTexture lookup will fail to compile with forward shading
Change 3065543 on 2016/07/26 by Daniel.Wright
Restored DetailMode changes causing a FGlobalComponentRecreateRenderStateContext - accidental removal from cl 2969413
Change 3065545 on 2016/07/26 by Daniel.Wright
Added material property bNormalCurvatureToRoughness, which can slightly reduce aliasing. Tweakable impact with r.NormalCurvatureToRoughnessScale.
Fixed reflection capture feedback with base pass reflections
Change 3066783 on 2016/07/27 by Daniel.Wright
Moved PreShadowCacheDepthZ out of FSceneRenderTargets and into FScene, which fixes issues with cached preshadows and multiple scenes, including HighResScreenShot
Disabled GMinScreenRadiusForShadowCaster on per-object shadows, which fixes popping when trying to increase shadow resolution from the defaults (r.Shadow.TexelsPerPixel 3)
Change 3066794 on 2016/07/27 by Daniel.Wright
Fixed crash rendering planar reflections due to NULL PostProcessSettings
Change 3067412 on 2016/07/27 by Daniel.Wright
Fix for OpenGL4 with uint interpolator
Change 3068470 on 2016/07/28 by Daniel.Wright
Fixed crash rendering translucency with translucent shadows which were determined to be invisible
Change 3069046 on 2016/07/28 by Daniel.Wright
Handle null Family in SetupAntiAliasingMethod
Change 3069059 on 2016/07/28 by Daniel.Wright
Added r.ReflectionEnvironmentBeginMixingRoughness (.1) and r.ReflectionEnvironmentEndMixingRoughness (.3), which can be used to tweak the lightmap mixing heuristc, or revert to previous behavior (mixing even on a mirror surface)
Change 3069391 on 2016/07/28 by Daniel.Wright
Fixed AverageBrightness being applied to reflections in gamma space in the mobile base pass, causing ES2 reflections to be overbright
Change 3070369 on 2016/07/29 by Daniel.Wright
r.ReflectionEnvironmentBeginMixingRoughness and r.ReflectionEnvironmentEndMixingRoughness set to 0 can be used to achieve old non-roughness based lightmap mixing
Change 3070370 on 2016/07/29 by Daniel.Wright
Bumped reflection capture DDC version to get rid of legacy prenormalized data
Change 3070680 on 2016/07/29 by Marcus.Wassmer
Fix slate ensure that is most likely a timing issue exposed by rendering.
#ue-33902
Change 3070811 on 2016/07/29 by Marcus.Wassmer
Fix ProjectLauncher errors when loading old versions
#ue-33939
Change 3070971 on 2016/07/29 by Uriel.Doyon
Updated ListTextures outputs to fix cooked VS non cooked differences and also to put enphasis on disk VS memory
Change 3071452 on 2016/07/31 by Uriel.Doyon
Updated the legend description for the (texture streaming) primitive distance accuracy view mode
[CL 3072803 by Marcus Wassmer in Main branch]
2016-08-01 18:56:49 -04:00
|
|
|
FRenderTargetTemp TempRenderTarget(View, (const FTexture2DRHIRef&)DestRenderTarget.TargetableTexture);
|
2014-08-22 14:15:05 -04:00
|
|
|
FCanvas Canvas(&TempRenderTarget, NULL, ViewFamily.CurrentRealTime, ViewFamily.CurrentWorldTime, ViewFamily.DeltaWorldTime, Context.GetFeatureLevel());
|
|
|
|
|
|
|
|
|
|
float X = 30;
|
|
|
|
|
float Y = 28;
|
|
|
|
|
const float YStep = 14;
|
|
|
|
|
|
|
|
|
|
FString Line;
|
|
|
|
|
|
|
|
|
|
Line = FString::Printf(TEXT("Visualize Screen Space Subsurface Scattering"));
|
|
|
|
|
Canvas.DrawShadowedString(X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
|
|
|
|
|
|
|
|
|
|
Y += YStep;
|
|
|
|
|
|
|
|
|
|
uint32 Index = 0;
|
2015-06-12 20:26:35 -04:00
|
|
|
while (GSubsurfaceProfileTextureObject.GetEntryString(Index++, Line))
|
2014-08-22 14:15:05 -04:00
|
|
|
{
|
|
|
|
|
Canvas.DrawShadowedString(X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Canvas.Flush_RenderThread(Context.RHICmdList);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 07:13:34 -04:00
|
|
|
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
|
2014-08-22 14:15:05 -04:00
|
|
|
|
2014-10-15 16:18:43 -04:00
|
|
|
// we no longer need the GBuffer
|
2015-09-21 20:07:00 -04:00
|
|
|
SceneContext.AdjustGBufferRefCount(Context.RHICmdList, -1);
|
2014-10-15 16:18:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FPooledRenderTargetDesc FRCPassPostProcessSubsurfaceVisualize::ComputeOutputDesc(EPassOutputId InPassOutputId) const
|
|
|
|
|
{
|
2015-05-29 10:47:57 -04:00
|
|
|
FPooledRenderTargetDesc Ret = FSceneRenderTargets::Get_Todo_PassContext().GetSceneColor()->GetDesc();
|
2014-10-15 16:18:43 -04:00
|
|
|
|
|
|
|
|
Ret.Reset();
|
|
|
|
|
Ret.DebugName = TEXT("SubsurfaceVisualize");
|
|
|
|
|
// alpha is used to store depth and renormalize (alpha==0 means there is no subsurface scattering)
|
|
|
|
|
Ret.Format = PF_FloatRGBA;
|
|
|
|
|
|
|
|
|
|
return Ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Encapsulates the post processing subsurface scattering pixel shader.
|
2015-07-23 18:12:09 -04:00
|
|
|
* @param HalfRes 0:to full res, 1:to half res
|
2014-10-15 16:18:43 -04:00
|
|
|
*/
|
2015-07-31 14:26:40 -04:00
|
|
|
template <uint32 HalfRes>
|
2014-10-15 16:18:43 -04:00
|
|
|
class FPostProcessSubsurfaceSetupPS : public FGlobalShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_SHADER_TYPE(FPostProcessSubsurfaceSetupPS , Global);
|
|
|
|
|
|
|
|
|
|
static bool ShouldCache(EShaderPlatform Platform)
|
2014-08-22 14:15:05 -04:00
|
|
|
{
|
2014-11-19 17:00:58 -05:00
|
|
|
return IsFeatureLevelSupported(Platform, ERHIFeatureLevel::SM4);
|
2014-08-22 14:15:05 -04:00
|
|
|
}
|
2014-10-15 16:18:43 -04:00
|
|
|
|
|
|
|
|
static void ModifyCompilationEnvironment(EShaderPlatform Platform, FShaderCompilerEnvironment& OutEnvironment)
|
|
|
|
|
{
|
|
|
|
|
FGlobalShader::ModifyCompilationEnvironment(Platform, OutEnvironment);
|
2015-07-23 18:12:09 -04:00
|
|
|
OutEnvironment.SetDefine(TEXT("HALF_RES"), HalfRes);
|
2015-07-29 16:42:44 -04:00
|
|
|
OutEnvironment.SetDefine(TEXT("SUBSURFACE_RADIUS_SCALE"), SUBSURFACE_RADIUS_SCALE);
|
|
|
|
|
OutEnvironment.SetDefine(TEXT("SUBSURFACE_KERNEL_SIZE"), SUBSURFACE_KERNEL_SIZE);
|
2014-10-15 16:18:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Default constructor. */
|
|
|
|
|
FPostProcessSubsurfaceSetupPS () {}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
FPostProcessPassParameters PostprocessParameter;
|
|
|
|
|
FDeferredPixelShaderParameters DeferredParameters;
|
|
|
|
|
FShaderResourceParameter MiniFontTexture;
|
|
|
|
|
FSubsurfaceParameters SubsurfaceParameters;
|
|
|
|
|
|
|
|
|
|
/** Initialization constructor. */
|
|
|
|
|
FPostProcessSubsurfaceSetupPS(const ShaderMetaType::CompiledShaderInitializerType& Initializer)
|
|
|
|
|
: FGlobalShader(Initializer)
|
|
|
|
|
{
|
|
|
|
|
PostprocessParameter.Bind(Initializer.ParameterMap);
|
|
|
|
|
DeferredParameters.Bind(Initializer.ParameterMap);
|
|
|
|
|
SubsurfaceParameters.Bind(Initializer.ParameterMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetParameters(const FRenderingCompositePassContext& Context)
|
|
|
|
|
{
|
|
|
|
|
const FFinalPostProcessSettings& Settings = Context.View.FinalPostProcessSettings;
|
|
|
|
|
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader();
|
|
|
|
|
|
|
|
|
|
FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View);
|
|
|
|
|
PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI());
|
|
|
|
|
DeferredParameters.Set(Context.RHICmdList, ShaderRHI, Context.View);
|
|
|
|
|
SubsurfaceParameters.SetParameters(Context.RHICmdList, ShaderRHI, Context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FShader interface.
|
2015-04-01 07:20:55 -04:00
|
|
|
virtual bool Serialize(FArchive& Ar) override
|
2014-10-15 16:18:43 -04:00
|
|
|
{
|
|
|
|
|
bool bShaderHasOutdatedParameters = FGlobalShader::Serialize(Ar);
|
|
|
|
|
Ar << PostprocessParameter << DeferredParameters << SubsurfaceParameters;
|
|
|
|
|
return bShaderHasOutdatedParameters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const TCHAR* GetSourceFilename()
|
|
|
|
|
{
|
|
|
|
|
return TEXT("PostProcessSubsurface");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const TCHAR* GetFunctionName()
|
|
|
|
|
{
|
|
|
|
|
return TEXT("SetupPS");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// #define avoids a lot of code duplication
|
2015-07-31 14:26:40 -04:00
|
|
|
#define VARIATION1(A) typedef FPostProcessSubsurfaceSetupPS<A> FPostProcessSubsurfaceSetupPS##A; \
|
|
|
|
|
IMPLEMENT_SHADER_TYPE2(FPostProcessSubsurfaceSetupPS##A, SF_Pixel);
|
2014-10-15 16:18:43 -04:00
|
|
|
VARIATION1(0) VARIATION1(1)
|
|
|
|
|
#undef VARIATION1
|
|
|
|
|
|
|
|
|
|
|
2015-07-31 14:26:40 -04:00
|
|
|
template <uint32 HalfRes>
|
2014-10-15 16:18:43 -04:00
|
|
|
void SetSubsurfaceSetupShader(const FRenderingCompositePassContext& Context)
|
|
|
|
|
{
|
|
|
|
|
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
|
2015-07-31 14:26:40 -04:00
|
|
|
TShaderMapRef<FPostProcessSubsurfaceSetupPS<HalfRes> > PixelShader(Context.GetShaderMap());
|
2014-10-15 16:18:43 -04:00
|
|
|
|
|
|
|
|
static FGlobalBoundShaderState BoundShaderState;
|
|
|
|
|
|
|
|
|
|
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
|
|
|
|
|
|
|
|
|
|
PixelShader->SetParameters(Context);
|
|
|
|
|
VertexShader->SetParameters(Context);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-23 13:36:07 -04:00
|
|
|
// --------------------------------------
|
|
|
|
|
|
2015-07-23 18:12:09 -04:00
|
|
|
FRCPassPostProcessSubsurfaceSetup::FRCPassPostProcessSubsurfaceSetup(FViewInfo& View, bool bInHalfRes)
|
2014-10-23 13:36:07 -04:00
|
|
|
: ViewRect(View.ViewRect)
|
2015-07-23 18:12:09 -04:00
|
|
|
, bHalfRes(bInHalfRes)
|
2014-10-23 13:36:07 -04:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-15 16:18:43 -04:00
|
|
|
void FRCPassPostProcessSubsurfaceSetup::Process(FRenderingCompositePassContext& Context)
|
|
|
|
|
{
|
2014-10-20 10:43:43 -04:00
|
|
|
SCOPED_DRAW_EVENT(Context.RHICmdList, SubsurfaceSetup);
|
2014-10-15 16:18:43 -04:00
|
|
|
|
|
|
|
|
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
|
|
|
|
|
|
|
|
|
|
if(!InputDesc)
|
|
|
|
|
{
|
|
|
|
|
// input is not hooked up correctly
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FSceneView& View = Context.View;
|
|
|
|
|
const FSceneViewFamily& ViewFamily = *(View.Family);
|
|
|
|
|
|
|
|
|
|
FIntPoint SrcSize = InputDesc->Extent;
|
|
|
|
|
FIntPoint DestSize = PassOutputs[0].RenderTargetDesc.Extent;
|
|
|
|
|
|
2014-10-23 13:36:07 -04:00
|
|
|
FIntRect DestRect = FIntRect(0, 0, DestSize.X, DestSize.Y);
|
2015-07-23 18:12:09 -04:00
|
|
|
FIntRect SrcRect = View.ViewRect;
|
|
|
|
|
|
|
|
|
|
if(bHalfRes)
|
|
|
|
|
{
|
|
|
|
|
// upscale rectangle to not slightly scale (might miss a pixel)
|
|
|
|
|
SrcRect = DestRect * 2 + View.ViewRect.Min;
|
|
|
|
|
}
|
2014-10-15 16:18:43 -04:00
|
|
|
|
|
|
|
|
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
|
|
|
|
|
|
|
|
|
|
// Set the view family's render target/viewport.
|
|
|
|
|
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
|
|
|
|
|
|
|
|
|
|
Context.SetViewportAndCallRHI(0, 0, 0.0f, DestSize.X, DestSize.Y, 1.0f );
|
|
|
|
|
|
|
|
|
|
// set the state
|
|
|
|
|
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
|
|
|
|
|
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
|
|
|
|
|
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
|
|
|
|
|
|
2015-07-31 14:26:40 -04:00
|
|
|
if(bHalfRes)
|
2014-10-15 16:18:43 -04:00
|
|
|
{
|
2015-07-31 14:26:40 -04:00
|
|
|
SetSubsurfaceSetupShader<1>(Context);
|
2014-10-15 16:18:43 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-07-31 14:26:40 -04:00
|
|
|
SetSubsurfaceSetupShader<0>(Context);
|
2014-10-15 16:18:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Draw a quad mapping scene color to the view's render target
|
|
|
|
|
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
|
2015-08-04 19:33:26 -04:00
|
|
|
|
|
|
|
|
DrawPostProcessPass(
|
2014-10-15 16:18:43 -04:00
|
|
|
Context.RHICmdList,
|
|
|
|
|
DestRect.Min.X, DestRect.Min.Y,
|
|
|
|
|
DestRect.Width(), DestRect.Height(),
|
|
|
|
|
SrcRect.Min.X, SrcRect.Min.Y,
|
|
|
|
|
SrcRect.Width(), SrcRect.Height(),
|
|
|
|
|
DestSize,
|
|
|
|
|
SrcSize,
|
|
|
|
|
*VertexShader,
|
2015-08-04 19:33:26 -04:00
|
|
|
View.StereoPass,
|
|
|
|
|
Context.HasHmdMesh(),
|
2014-10-15 16:18:43 -04:00
|
|
|
EDRF_UseTriangleOptimization);
|
|
|
|
|
|
|
|
|
|
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FPooledRenderTargetDesc FRCPassPostProcessSubsurfaceSetup::ComputeOutputDesc(EPassOutputId InPassOutputId) const
|
|
|
|
|
{
|
2015-05-29 10:47:57 -04:00
|
|
|
FPooledRenderTargetDesc Ret = FSceneRenderTargets::Get_Todo_PassContext().GetSceneColor()->GetDesc();
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
Ret.Reset();
|
|
|
|
|
Ret.DebugName = TEXT("SubsurfaceSetup");
|
2014-10-15 16:18:43 -04:00
|
|
|
// alpha is used to store depth and renormalize (alpha==0 means there is no subsurface scattering)
|
|
|
|
|
Ret.Format = PF_FloatRGBA;
|
2014-09-24 18:17:05 -04:00
|
|
|
|
2014-10-23 13:36:07 -04:00
|
|
|
Ret.Extent = ViewRect.Size();
|
|
|
|
|
|
2015-07-23 18:12:09 -04:00
|
|
|
if(bHalfRes)
|
|
|
|
|
{
|
|
|
|
|
Ret.Extent = FIntPoint::DivideAndRoundUp(Ret.Extent, 2);
|
|
|
|
|
Ret.Extent.X = FMath::Max(1, Ret.Extent.X);
|
|
|
|
|
Ret.Extent.Y = FMath::Max(1, Ret.Extent.Y);
|
|
|
|
|
}
|
2014-10-15 16:18:43 -04:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
return Ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-10-02 17:19:02 -04:00
|
|
|
/** Encapsulates the post processing subsurface pixel shader. */
|
|
|
|
|
// @param Direction 0: horizontal, 1:vertical
|
2014-09-05 17:48:09 -04:00
|
|
|
// @param SampleSet 0:low, 1:med, 2:high
|
2014-10-02 17:19:02 -04:00
|
|
|
template <uint32 Direction, uint32 SampleSet>
|
2014-09-05 17:48:09 -04:00
|
|
|
class TPostProcessSubsurfacePS : public FGlobalShader
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-09-05 17:48:09 -04:00
|
|
|
DECLARE_SHADER_TYPE(TPostProcessSubsurfacePS, Global);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
static bool ShouldCache(EShaderPlatform Platform)
|
|
|
|
|
{
|
2014-11-19 17:00:58 -05:00
|
|
|
return IsFeatureLevelSupported(Platform, ERHIFeatureLevel::SM4);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ModifyCompilationEnvironment(EShaderPlatform Platform, FShaderCompilerEnvironment& OutEnvironment)
|
|
|
|
|
{
|
2014-06-05 16:38:54 -04:00
|
|
|
FGlobalShader::ModifyCompilationEnvironment(Platform,OutEnvironment);
|
2014-10-02 17:19:02 -04:00
|
|
|
OutEnvironment.SetDefine(TEXT("SSS_DIRECTION"), Direction);
|
2014-09-05 17:48:09 -04:00
|
|
|
OutEnvironment.SetDefine(TEXT("SSS_SAMPLESET"), SampleSet);
|
2015-07-29 16:42:44 -04:00
|
|
|
OutEnvironment.SetDefine(TEXT("SUBSURFACE_RADIUS_SCALE"), SUBSURFACE_RADIUS_SCALE);
|
|
|
|
|
OutEnvironment.SetDefine(TEXT("SUBSURFACE_KERNEL_SIZE"), SUBSURFACE_KERNEL_SIZE);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Default constructor. */
|
2014-09-05 17:48:09 -04:00
|
|
|
TPostProcessSubsurfacePS() {}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
FPostProcessPassParameters PostprocessParameter;
|
|
|
|
|
FDeferredPixelShaderParameters DeferredParameters;
|
2014-10-15 16:18:43 -04:00
|
|
|
FSubsurfaceParameters SubsurfaceParameters;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
/** Initialization constructor. */
|
2014-09-05 17:48:09 -04:00
|
|
|
TPostProcessSubsurfacePS(const ShaderMetaType::CompiledShaderInitializerType& Initializer)
|
2014-03-14 14:13:41 -04:00
|
|
|
: FGlobalShader(Initializer)
|
|
|
|
|
{
|
|
|
|
|
PostprocessParameter.Bind(Initializer.ParameterMap);
|
|
|
|
|
DeferredParameters.Bind(Initializer.ParameterMap);
|
2014-10-15 16:18:43 -04:00
|
|
|
SubsurfaceParameters.Bind(Initializer.ParameterMap);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FShader interface.
|
2015-04-01 07:20:55 -04:00
|
|
|
virtual bool Serialize(FArchive& Ar) override
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
bool bShaderHasOutdatedParameters = FGlobalShader::Serialize(Ar);
|
2014-10-15 16:18:43 -04:00
|
|
|
Ar << PostprocessParameter << DeferredParameters << SubsurfaceParameters;
|
2014-03-14 14:13:41 -04:00
|
|
|
return bShaderHasOutdatedParameters;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-15 16:18:43 -04:00
|
|
|
void SetParameters(const FRenderingCompositePassContext& Context)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader();
|
|
|
|
|
|
2014-06-12 07:13:34 -04:00
|
|
|
FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View);
|
|
|
|
|
DeferredParameters.Set(Context.RHICmdList, ShaderRHI, Context.View);
|
2014-10-16 13:08:38 -04:00
|
|
|
|
|
|
|
|
if(CVarSSSFilter.GetValueOnRenderThread())
|
|
|
|
|
{
|
|
|
|
|
PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear,AM_Border,AM_Border,AM_Border>::GetRHI());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Point,AM_Border,AM_Border,AM_Border>::GetRHI());
|
|
|
|
|
}
|
2014-10-15 16:18:43 -04:00
|
|
|
SubsurfaceParameters.SetParameters(Context.RHICmdList, ShaderRHI, Context);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const TCHAR* GetSourceFilename()
|
|
|
|
|
{
|
|
|
|
|
return TEXT("PostProcessSubsurface");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const TCHAR* GetFunctionName()
|
|
|
|
|
{
|
|
|
|
|
return TEXT("MainPS");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-16 16:01:12 -05:00
|
|
|
// #define avoids a lot of code duplication
|
2014-09-05 17:48:09 -04:00
|
|
|
#define VARIATION1(A) VARIATION2(A,0) VARIATION2(A,1) VARIATION2(A,2)
|
|
|
|
|
#define VARIATION2(A, B) typedef TPostProcessSubsurfacePS<A, B> TPostProcessSubsurfacePS##A##B; \
|
|
|
|
|
IMPLEMENT_SHADER_TYPE2(TPostProcessSubsurfacePS##A##B, SF_Pixel);
|
|
|
|
|
VARIATION1(0) VARIATION1(1) VARIATION1(2)
|
2014-03-14 14:13:41 -04:00
|
|
|
#undef VARIATION1
|
2014-09-05 17:48:09 -04:00
|
|
|
#undef VARIATION2
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
|
2015-07-23 18:12:09 -04:00
|
|
|
FRCPassPostProcessSubsurface::FRCPassPostProcessSubsurface(uint32 InDirection, bool bInHalfRes)
|
2014-10-15 16:18:43 -04:00
|
|
|
: Direction(InDirection)
|
2015-07-23 18:12:09 -04:00
|
|
|
, bHalfRes(bInHalfRes)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-10-02 17:19:02 -04:00
|
|
|
check(InDirection < 2);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2014-10-02 17:19:02 -04:00
|
|
|
template <uint32 Direction, uint32 SampleSet>
|
2014-10-15 16:18:43 -04:00
|
|
|
void SetSubsurfaceShader(const FRenderingCompositePassContext& Context, TShaderMapRef<FPostProcessVS> &VertexShader)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-10-02 17:19:02 -04:00
|
|
|
TShaderMapRef<TPostProcessSubsurfacePS<Direction, SampleSet> > PixelShader(Context.GetShaderMap());
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
static FGlobalBoundShaderState BoundShaderState;
|
|
|
|
|
|
2014-08-19 10:41:34 -04:00
|
|
|
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-10-15 16:18:43 -04:00
|
|
|
PixelShader->SetParameters(Context);
|
2014-06-12 07:13:34 -04:00
|
|
|
VertexShader->SetParameters(Context);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2014-10-02 17:19:02 -04:00
|
|
|
// 0:horizontal, 1: vertical
|
|
|
|
|
template <uint32 Direction>
|
2014-10-15 16:18:43 -04:00
|
|
|
void SetSubsurfaceShaderSampleSet(const FRenderingCompositePassContext& Context, TShaderMapRef<FPostProcessVS> &VertexShader, uint32 SampleSet)
|
2014-09-05 17:48:09 -04:00
|
|
|
{
|
|
|
|
|
switch(SampleSet)
|
|
|
|
|
{
|
2014-10-15 16:18:43 -04:00
|
|
|
case 0: SetSubsurfaceShader<Direction, 0>(Context, VertexShader); break;
|
|
|
|
|
case 1: SetSubsurfaceShader<Direction, 1>(Context, VertexShader); break;
|
|
|
|
|
case 2: SetSubsurfaceShader<Direction, 2>(Context, VertexShader); break;
|
2014-09-05 17:48:09 -04:00
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
check(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
void FRCPassPostProcessSubsurface::Process(FRenderingCompositePassContext& Context)
|
|
|
|
|
{
|
2014-10-02 17:19:02 -04:00
|
|
|
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-07-29 18:02:49 -04:00
|
|
|
check(InputDesc);
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-07-29 18:02:49 -04:00
|
|
|
const IPooledRenderTarget* PooledRT = GetSubsufaceProfileTexture_RT(Context.RHICmdList);
|
|
|
|
|
|
|
|
|
|
check(PooledRT);
|
|
|
|
|
|
|
|
|
|
// for debugging
|
|
|
|
|
GRenderTargetPool.VisualizeTexture.SetCheckPoint(Context.RHICmdList, PooledRT);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FSceneView& View = Context.View;
|
|
|
|
|
const FSceneViewFamily& ViewFamily = *(View.Family);
|
|
|
|
|
|
|
|
|
|
FIntPoint SrcSize = InputDesc->Extent;
|
2014-10-02 17:19:02 -04:00
|
|
|
FIntPoint DestSize = PassOutputs[0].RenderTargetDesc.Extent;
|
|
|
|
|
|
|
|
|
|
check(DestSize.X);
|
|
|
|
|
check(DestSize.Y);
|
|
|
|
|
check(SrcSize.X);
|
|
|
|
|
check(SrcSize.Y);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-10-23 13:36:07 -04:00
|
|
|
FIntRect SrcRect = FIntRect(0, 0, DestSize.X, DestSize.Y);
|
2014-10-15 16:18:43 -04:00
|
|
|
FIntRect DestRect = SrcRect;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-09-05 17:48:09 -04:00
|
|
|
TRefCountPtr<IPooledRenderTarget> NewSceneColor;
|
|
|
|
|
|
|
|
|
|
const FSceneRenderTargetItem* DestRenderTarget;
|
|
|
|
|
{
|
2014-10-02 17:19:02 -04:00
|
|
|
DestRenderTarget = &PassOutputs[0].RequestSurface(Context);
|
2014-09-05 17:48:09 -04:00
|
|
|
|
|
|
|
|
check(DestRenderTarget);
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
// Set the view family's render target/viewport.
|
2014-09-05 17:48:09 -04:00
|
|
|
SetRenderTarget(Context.RHICmdList, DestRenderTarget->TargetableTexture, FTextureRHIRef());
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
Context.SetViewportAndCallRHI(0, 0, 0.0f, DestSize.X, DestSize.Y, 1.0f );
|
|
|
|
|
|
2014-06-12 07:13:34 -04:00
|
|
|
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
|
|
|
|
|
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
|
|
|
|
|
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-08-28 06:22:54 -04:00
|
|
|
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
|
2014-04-23 17:26:59 -04:00
|
|
|
|
2014-10-20 10:43:43 -04:00
|
|
|
SCOPED_DRAW_EVENTF(Context.RHICmdList, SubsurfacePass, TEXT("SubsurfaceDirection#%d"), Direction);
|
2014-07-29 17:33:28 -04:00
|
|
|
|
2014-09-05 17:48:09 -04:00
|
|
|
uint32 SampleSet = FMath::Clamp(CVarSSSSampleSet.GetValueOnRenderThread(), 0, 2);
|
|
|
|
|
|
2014-10-02 17:19:02 -04:00
|
|
|
if (Direction == 0)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-10-15 16:18:43 -04:00
|
|
|
SetSubsurfaceShaderSampleSet<0>(Context, VertexShader, SampleSet);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
2014-07-29 17:33:28 -04:00
|
|
|
else
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-10-15 16:18:43 -04:00
|
|
|
SetSubsurfaceShaderSampleSet<1>(Context, VertexShader, SampleSet);
|
2014-10-02 17:19:02 -04:00
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2015-08-04 19:33:26 -04:00
|
|
|
DrawPostProcessPass(
|
2014-10-02 17:19:02 -04:00
|
|
|
Context.RHICmdList,
|
|
|
|
|
DestRect.Min.X, DestRect.Min.Y,
|
|
|
|
|
DestRect.Width(), DestRect.Height(),
|
|
|
|
|
SrcRect.Min.X, SrcRect.Min.Y,
|
|
|
|
|
SrcRect.Width(), SrcRect.Height(),
|
|
|
|
|
DestSize,
|
|
|
|
|
SrcSize,
|
|
|
|
|
*VertexShader,
|
2015-08-04 19:33:26 -04:00
|
|
|
View.StereoPass,
|
|
|
|
|
Context.HasHmdMesh(),
|
2014-10-02 17:19:02 -04:00
|
|
|
EDRF_UseTriangleOptimization);
|
|
|
|
|
|
|
|
|
|
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget->TargetableTexture, DestRenderTarget->ShaderResourceTexture, false, FResolveParams());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FPooledRenderTargetDesc FRCPassPostProcessSubsurface::ComputeOutputDesc(EPassOutputId InPassOutputId) const
|
|
|
|
|
{
|
2015-07-06 18:04:49 -04:00
|
|
|
FPooledRenderTargetDesc Ret = GetInput(ePId_Input0)->GetOutput()->RenderTargetDesc;
|
2014-10-02 17:19:02 -04:00
|
|
|
|
|
|
|
|
Ret.Reset();
|
|
|
|
|
Ret.DebugName = (Direction == 0) ? TEXT("SubsurfaceX") : TEXT("SubsurfaceY");
|
|
|
|
|
|
|
|
|
|
return Ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-07-23 18:12:09 -04:00
|
|
|
/** Encapsulates the post processing subsurface recombine pixel shader. */
|
2015-07-31 14:26:40 -04:00
|
|
|
// @param RecombineMode 0:fullres, 1: halfres, 2:no scattering, just reconstruct the lighting (needed for scalability)
|
2016-02-16 05:48:48 -05:00
|
|
|
// @param RecombineQuality 0:low..1:high
|
|
|
|
|
template <uint32 RecombineMode, uint32 RecombineQuality>
|
2014-10-02 17:19:02 -04:00
|
|
|
class TPostProcessSubsurfaceRecombinePS : public FGlobalShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_SHADER_TYPE(TPostProcessSubsurfaceRecombinePS, Global);
|
|
|
|
|
|
|
|
|
|
static bool ShouldCache(EShaderPlatform Platform)
|
|
|
|
|
{
|
2014-11-19 17:00:58 -05:00
|
|
|
return IsFeatureLevelSupported(Platform, ERHIFeatureLevel::SM4);
|
2014-10-02 17:19:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ModifyCompilationEnvironment(EShaderPlatform Platform, FShaderCompilerEnvironment& OutEnvironment)
|
|
|
|
|
{
|
|
|
|
|
FGlobalShader::ModifyCompilationEnvironment(Platform,OutEnvironment);
|
2016-02-16 05:48:48 -05:00
|
|
|
OutEnvironment.SetDefine(TEXT("RECOMBINE_QUALITY"), RecombineQuality);
|
2015-07-31 14:26:40 -04:00
|
|
|
OutEnvironment.SetDefine(TEXT("HALF_RES"), (uint32)(RecombineMode == 1));
|
|
|
|
|
OutEnvironment.SetDefine(TEXT("RECOMBINE_SUBSURFACESCATTER"), (uint32)(RecombineMode != 2));
|
2015-07-29 16:42:44 -04:00
|
|
|
OutEnvironment.SetDefine(TEXT("SUBSURFACE_RADIUS_SCALE"), SUBSURFACE_RADIUS_SCALE);
|
|
|
|
|
OutEnvironment.SetDefine(TEXT("SUBSURFACE_KERNEL_SIZE"), SUBSURFACE_KERNEL_SIZE);
|
2014-10-02 17:19:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Default constructor. */
|
|
|
|
|
TPostProcessSubsurfaceRecombinePS() {}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
FPostProcessPassParameters PostprocessParameter;
|
|
|
|
|
FDeferredPixelShaderParameters DeferredParameters;
|
2014-10-15 16:18:43 -04:00
|
|
|
FSubsurfaceParameters SubsurfaceParameters;
|
2014-10-02 17:19:02 -04:00
|
|
|
|
|
|
|
|
/** Initialization constructor. */
|
|
|
|
|
TPostProcessSubsurfaceRecombinePS(const ShaderMetaType::CompiledShaderInitializerType& Initializer)
|
|
|
|
|
: FGlobalShader(Initializer)
|
|
|
|
|
{
|
|
|
|
|
PostprocessParameter.Bind(Initializer.ParameterMap);
|
|
|
|
|
DeferredParameters.Bind(Initializer.ParameterMap);
|
2014-10-15 16:18:43 -04:00
|
|
|
SubsurfaceParameters.Bind(Initializer.ParameterMap);
|
2014-10-02 17:19:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FShader interface.
|
2015-04-01 07:20:55 -04:00
|
|
|
virtual bool Serialize(FArchive& Ar) override
|
2014-10-02 17:19:02 -04:00
|
|
|
{
|
|
|
|
|
bool bShaderHasOutdatedParameters = FGlobalShader::Serialize(Ar);
|
2014-10-15 16:18:43 -04:00
|
|
|
Ar << PostprocessParameter << DeferredParameters << SubsurfaceParameters;
|
2014-10-02 17:19:02 -04:00
|
|
|
return bShaderHasOutdatedParameters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetParameters(const FRenderingCompositePassContext& Context)
|
|
|
|
|
{
|
|
|
|
|
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader();
|
|
|
|
|
|
|
|
|
|
FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View);
|
|
|
|
|
DeferredParameters.Set(Context.RHICmdList, ShaderRHI, Context.View);
|
|
|
|
|
PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear,AM_Border,AM_Border,AM_Border>::GetRHI());
|
2014-10-15 16:18:43 -04:00
|
|
|
SubsurfaceParameters.SetParameters(Context.RHICmdList, ShaderRHI, Context);
|
2014-10-02 17:19:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const TCHAR* GetSourceFilename()
|
|
|
|
|
{
|
|
|
|
|
return TEXT("PostProcessSubsurface");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const TCHAR* GetFunctionName()
|
|
|
|
|
{
|
|
|
|
|
return TEXT("SubsurfaceRecombinePS");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// #define avoids a lot of code duplication
|
2016-02-16 05:48:48 -05:00
|
|
|
#define VARIATION1(A) VARIATION2(A,0) VARIATION2(A,1)
|
|
|
|
|
#define VARIATION2(A, B) typedef TPostProcessSubsurfaceRecombinePS<A, B> TPostProcessSubsurfaceRecombinePS##A##B; \
|
|
|
|
|
IMPLEMENT_SHADER_TYPE2(TPostProcessSubsurfaceRecombinePS##A##B, SF_Pixel);
|
2015-07-31 14:26:40 -04:00
|
|
|
VARIATION1(0) VARIATION1(1) VARIATION1(2)
|
2014-10-02 17:19:02 -04:00
|
|
|
#undef VARIATION1
|
2016-02-16 05:48:48 -05:00
|
|
|
#undef VARIATION2
|
2014-10-02 17:19:02 -04:00
|
|
|
|
2015-07-31 14:26:40 -04:00
|
|
|
// @param RecombineMode 0:fullres, 1: halfres, 2:no scattering, just reconstruct the lighting (needed for scalability)
|
2016-02-16 05:48:48 -05:00
|
|
|
// @param RecombineQuality 0:low..1:high
|
|
|
|
|
template <uint32 RecombineMode, uint32 RecombineQuality>
|
2014-10-02 17:19:02 -04:00
|
|
|
void SetSubsurfaceRecombineShader(const FRenderingCompositePassContext& Context, TShaderMapRef<FPostProcessVS> &VertexShader)
|
|
|
|
|
{
|
2016-02-16 05:48:48 -05:00
|
|
|
TShaderMapRef<TPostProcessSubsurfaceRecombinePS<RecombineMode, RecombineQuality> > PixelShader(Context.GetShaderMap());
|
2014-10-02 17:19:02 -04:00
|
|
|
|
|
|
|
|
static FGlobalBoundShaderState BoundShaderState;
|
|
|
|
|
|
|
|
|
|
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
|
|
|
|
|
|
|
|
|
|
PixelShader->SetParameters(Context);
|
|
|
|
|
VertexShader->SetParameters(Context);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-29 16:42:44 -04:00
|
|
|
FRCPassPostProcessSubsurfaceRecombine::FRCPassPostProcessSubsurfaceRecombine(bool bInHalfRes, bool bInSingleViewportMode)
|
2015-07-23 18:12:09 -04:00
|
|
|
: bHalfRes(bInHalfRes)
|
2015-07-29 16:42:44 -04:00
|
|
|
, bSingleViewportMode(bInSingleViewportMode)
|
2015-07-23 18:12:09 -04:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-02 17:19:02 -04:00
|
|
|
void FRCPassPostProcessSubsurfaceRecombine::Process(FRenderingCompositePassContext& Context)
|
|
|
|
|
{
|
2015-05-29 10:47:57 -04:00
|
|
|
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(Context.RHICmdList);
|
2014-10-02 17:19:02 -04:00
|
|
|
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
|
|
|
|
|
|
|
|
|
|
check(InputDesc);
|
|
|
|
|
|
|
|
|
|
const FSceneView& View = Context.View;
|
|
|
|
|
const FSceneViewFamily& ViewFamily = *(View.Family);
|
|
|
|
|
|
|
|
|
|
FIntPoint SrcSize = InputDesc->Extent;
|
2015-05-29 10:47:57 -04:00
|
|
|
FIntPoint DestSize = SceneContext.GetBufferSizeXY();
|
2014-10-02 17:19:02 -04:00
|
|
|
|
|
|
|
|
check(DestSize.X);
|
|
|
|
|
check(DestSize.Y);
|
|
|
|
|
check(SrcSize.X);
|
|
|
|
|
check(SrcSize.Y);
|
|
|
|
|
|
2014-10-23 13:36:07 -04:00
|
|
|
FIntRect SrcRect = FIntRect(0, 0, InputDesc->Extent.X, InputDesc->Extent.Y);
|
2014-10-02 17:19:02 -04:00
|
|
|
FIntRect DestRect = View.ViewRect;
|
|
|
|
|
|
2015-05-29 10:47:57 -04:00
|
|
|
TRefCountPtr<IPooledRenderTarget>& SceneColor = SceneContext.GetSceneColor();
|
2014-10-02 17:19:02 -04:00
|
|
|
|
2015-07-29 16:42:44 -04:00
|
|
|
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
|
2014-10-02 17:19:02 -04:00
|
|
|
|
|
|
|
|
// Set the view family's render target/viewport.
|
2014-10-23 13:36:07 -04:00
|
|
|
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
|
2014-10-02 17:19:02 -04:00
|
|
|
|
2015-07-29 16:42:44 -04:00
|
|
|
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
|
2014-10-02 17:19:02 -04:00
|
|
|
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
|
|
|
|
|
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
|
|
|
|
|
|
2015-07-29 16:42:44 -04:00
|
|
|
CopyOverOtherViewportsIfNeeded(Context, View);
|
|
|
|
|
|
|
|
|
|
Context.SetViewportAndCallRHI(0, 0, 0.0f, DestSize.X, DestSize.Y, 1.0f );
|
|
|
|
|
|
2014-10-02 17:19:02 -04:00
|
|
|
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
|
|
|
|
|
|
2016-02-16 05:48:48 -05:00
|
|
|
uint32 QualityCVar = CVarSSSQuality.GetValueOnRenderThread();
|
|
|
|
|
|
|
|
|
|
// 0:low / 1:high
|
|
|
|
|
uint32 RecombineQuality = 0;
|
|
|
|
|
{
|
|
|
|
|
if(QualityCVar == -1)
|
|
|
|
|
{
|
Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 3072736)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3055495 on 2016/07/19 by Marc.Olano
Allow Noise material node on mobile
No reason to exclude mobile, except for Fast Gradient Noise, which uses 3D textures. Allow this node on ES2 for all of the other noise functions.
#jira UE-33345
Change 3055602 on 2016/07/19 by Luke.Thatcher
Fix crash bug in D3D11 RHI when selecting adapters.
- Array of adapter descriptors will get out of sync with the adapter index if any adapter is skipped (e.g. the Microsoft Basic Render Device).
#jira UE-33236
Change 3055890 on 2016/07/19 by Daniel.Wright
Improved the assert in LoadModuleChecked so we won't have to check the log to see which module it was
Change 3055891 on 2016/07/19 by Daniel.Wright
Fixed Global Distance Field not dirtying previous object position on UpdateTransform - left behind a phantom shadow on teleports
* This will effectively double partial distiance field update costs until clipping of the update regions is implemented
Change 3055892 on 2016/07/19 by Daniel.Wright
Higher poly light source shapes drawn into reflection captures
Change 3055893 on 2016/07/19 by Daniel.Wright
More info to 'Incompatible surface format' GNM assert
Change 3055904 on 2016/07/19 by Daniel.Wright
Reflection environment normalization improvements
* Indirect specular from reflection captures is now mixed with indirect diffuse from lightmaps based on roughness, such that a mirror surface will have no mixing. Reflection captures now match other reflection methods like SSR and planar reflections much more closely.
* When a stationary skylight is present, Reflection captures are now normalized as if the initial skylight will always be present, giving consistent results with static skylight reflections. The skylight and reflection captures with sky removed used to be normalized separately, compacting the relative brightness between the sky and scene.
* Added r.ReflectionEnvironmentLightmapMixing for debugging lightmap mixing issues. This toggle was previously not possible due to prenormalizing the capture data.
* The standard deferred reflection path (r.DoTiledReflections 0) can no longer match the results of the compute path or base pass reflections, as it would require MRT to accumulate the average brightness
* Removed unused r.DiffuseFromCaptures
* Cost of reflection environment on PS4 increased from 1.52ms -> 1.75ms with this change, but decreased back to 1.58ms by reducing tile size to 8x8
Change 3055905 on 2016/07/19 by Daniel.Wright
Workaround for RTDF shadows not working on PS4 - manual clear of ObjectIndirectArguments instead of RHICmdList.ClearUAV
Change 3059486 on 2016/07/21 by Nick.Penwarden
Testing #uecritical
Change 3060558 on 2016/07/21 by Daniel.Wright
Fixed skylight with specified cubemap being black
Change 3061999 on 2016/07/22 by Marcus.Wassmer
Disable old AMD driver hacks for DX11. QA has already tested with them off and given thumbs up.
Change 3062241 on 2016/07/22 by Daniel.Wright
Fixed bug in RHISupportsSeparateMSAAAndResolveTextures that was preventing MSAA for any non-Vulkan platforms
Change 3062244 on 2016/07/22 by Daniel.Wright
Discard old prenormalized reflection environment data on load
Change 3062283 on 2016/07/22 by Daniel.Wright
MSAA support for the forward renderer
* AntiAliasing method is chosen in Rendering project settings, DefaultSettings category
* Deferred passes like shadow projection, fogging and decals are only computed per-pixel and can introduce aliasing
* Added Rendering project setting VertexFoggingForOpaque, which makes height fog cheaper and work properly with MSAA
* The AntiAliasing method in PostProcessSettings has been removed, this may affect existing content
* Added r.MSAACount which defaults to 4
* Integrated wide custom resolve filter from Oculus renderer, controlled by r.WideCustomResolve
* GBuffer targets are no longer allocated when using the forward renderer
* Decal blend modes that write to the GBuffer fall back to SceneColor emissive only
Change 3062666 on 2016/07/23 by Uriel.Doyon
Added legend to streaming accuracy viewmodes
Added a new helper class FRenderTargetTemp to be reused in different canvas rendering.
Exposed the pass through pixel shader so that it can be reused.
#review-3058986 @marcus.wassmer
Change 3063023 on 2016/07/25 by Luke.Thatcher
Fix "RecompileShaders Changed" when using Cook On The Fly.
#jira UE-33573
Change 3063078 on 2016/07/25 by Ben.Woodhouse
Add -emitdrawevents command line option to emit draw events by default. This is useful when capturing with Renderdoc
Change 3063315 on 2016/07/25 by Ben.Woodhouse
Fix div 0 in motion blur. This caused artifacts in some fairly common cases
#jira UE-32331
Change 3063897 on 2016/07/25 by Uriel.Doyon
Fixed missing qualifier on interpolants
Change 3064559 on 2016/07/26 by Ben.Woodhouse
Fix for cooker crash with BC6H textures (XB1, but may affect other platforms). Also fixes corruption issue with texture slices not being a multiple of 4 pixels (expanding as necessary), courtesy of Stu McKenna at the Coalition
Tested fix on xbox, PC and PS4, using QAGame
#jira UE-28592
Change 3064896 on 2016/07/26 by Ben.Woodhouse
Fix compile errors on PS4 (the variable "sample" was conflicting with a keyword, causing compile errors). Also making encoding consistent on new shaders (ansi rather than UTF16)
Change 3064913 on 2016/07/26 by Ben.Marsh
Fix spelling of "Editor, Tools, Monolithics & DDC" node in Dev-Rendering build settings.
Change 3065326 on 2016/07/26 by Uriel.Doyon
Fixed UnbuiltInstanceBoundsList not being reset correctly, creating broken rendered primitives.
#jira UE-32585
Change 3065541 on 2016/07/26 by Daniel.Wright
Materials with a GBuffer SceneTexture lookup will fail to compile with forward shading
Change 3065543 on 2016/07/26 by Daniel.Wright
Restored DetailMode changes causing a FGlobalComponentRecreateRenderStateContext - accidental removal from cl 2969413
Change 3065545 on 2016/07/26 by Daniel.Wright
Added material property bNormalCurvatureToRoughness, which can slightly reduce aliasing. Tweakable impact with r.NormalCurvatureToRoughnessScale.
Fixed reflection capture feedback with base pass reflections
Change 3066783 on 2016/07/27 by Daniel.Wright
Moved PreShadowCacheDepthZ out of FSceneRenderTargets and into FScene, which fixes issues with cached preshadows and multiple scenes, including HighResScreenShot
Disabled GMinScreenRadiusForShadowCaster on per-object shadows, which fixes popping when trying to increase shadow resolution from the defaults (r.Shadow.TexelsPerPixel 3)
Change 3066794 on 2016/07/27 by Daniel.Wright
Fixed crash rendering planar reflections due to NULL PostProcessSettings
Change 3067412 on 2016/07/27 by Daniel.Wright
Fix for OpenGL4 with uint interpolator
Change 3068470 on 2016/07/28 by Daniel.Wright
Fixed crash rendering translucency with translucent shadows which were determined to be invisible
Change 3069046 on 2016/07/28 by Daniel.Wright
Handle null Family in SetupAntiAliasingMethod
Change 3069059 on 2016/07/28 by Daniel.Wright
Added r.ReflectionEnvironmentBeginMixingRoughness (.1) and r.ReflectionEnvironmentEndMixingRoughness (.3), which can be used to tweak the lightmap mixing heuristc, or revert to previous behavior (mixing even on a mirror surface)
Change 3069391 on 2016/07/28 by Daniel.Wright
Fixed AverageBrightness being applied to reflections in gamma space in the mobile base pass, causing ES2 reflections to be overbright
Change 3070369 on 2016/07/29 by Daniel.Wright
r.ReflectionEnvironmentBeginMixingRoughness and r.ReflectionEnvironmentEndMixingRoughness set to 0 can be used to achieve old non-roughness based lightmap mixing
Change 3070370 on 2016/07/29 by Daniel.Wright
Bumped reflection capture DDC version to get rid of legacy prenormalized data
Change 3070680 on 2016/07/29 by Marcus.Wassmer
Fix slate ensure that is most likely a timing issue exposed by rendering.
#ue-33902
Change 3070811 on 2016/07/29 by Marcus.Wassmer
Fix ProjectLauncher errors when loading old versions
#ue-33939
Change 3070971 on 2016/07/29 by Uriel.Doyon
Updated ListTextures outputs to fix cooked VS non cooked differences and also to put enphasis on disk VS memory
Change 3071452 on 2016/07/31 by Uriel.Doyon
Updated the legend description for the (texture streaming) primitive distance accuracy view mode
[CL 3072803 by Marcus Wassmer in Main branch]
2016-08-01 18:56:49 -04:00
|
|
|
RecombineQuality = (View.AntiAliasingMethod == AAM_TemporalAA) ? 0 : 1;
|
2016-02-16 05:48:48 -05:00
|
|
|
}
|
|
|
|
|
else if(QualityCVar == 1)
|
|
|
|
|
{
|
|
|
|
|
RecombineQuality = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// needed for Scalability
|
|
|
|
|
// 0:fullres, 1: halfres, 2:no scattering, just reconstruct the lighting (needed for scalability)
|
|
|
|
|
uint32 RecombineMode = 2;
|
|
|
|
|
|
2015-08-19 11:28:54 -04:00
|
|
|
if(GetInput(ePId_Input1)->IsValid())
|
2014-10-02 17:19:02 -04:00
|
|
|
{
|
2016-02-16 05:48:48 -05:00
|
|
|
RecombineMode = bHalfRes ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SCOPED_DRAW_EVENTF(Context.RHICmdList, SubsurfacePassRecombine, TEXT("SubsurfacePassRecombine Mode:%d Quality:%d"), RecombineMode, RecombineQuality);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
if(RecombineQuality == 0)
|
2015-07-31 14:26:40 -04:00
|
|
|
{
|
2016-02-16 05:48:48 -05:00
|
|
|
switch(RecombineMode)
|
|
|
|
|
{
|
|
|
|
|
case 0: SetSubsurfaceRecombineShader<0, 0>(Context, VertexShader); break;
|
|
|
|
|
case 1: SetSubsurfaceRecombineShader<1, 0>(Context, VertexShader); break;
|
|
|
|
|
case 2: SetSubsurfaceRecombineShader<2, 0>(Context, VertexShader); break;
|
|
|
|
|
default: check(0);
|
|
|
|
|
}
|
2015-07-31 14:26:40 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-02-16 05:48:48 -05:00
|
|
|
switch(RecombineMode)
|
|
|
|
|
{
|
|
|
|
|
case 0: SetSubsurfaceRecombineShader<0, 1>(Context, VertexShader); break;
|
|
|
|
|
case 1: SetSubsurfaceRecombineShader<1, 1>(Context, VertexShader); break;
|
|
|
|
|
case 2: SetSubsurfaceRecombineShader<2, 1>(Context, VertexShader); break;
|
|
|
|
|
default: check(0);
|
|
|
|
|
}
|
2015-07-31 14:26:40 -04:00
|
|
|
}
|
2014-10-02 17:19:02 -04:00
|
|
|
}
|
2014-07-29 17:33:28 -04:00
|
|
|
|
2015-08-04 19:33:26 -04:00
|
|
|
DrawPostProcessPass(
|
2014-07-29 17:33:28 -04:00
|
|
|
Context.RHICmdList,
|
|
|
|
|
DestRect.Min.X, DestRect.Min.Y,
|
|
|
|
|
DestRect.Width(), DestRect.Height(),
|
|
|
|
|
SrcRect.Min.X, SrcRect.Min.Y,
|
|
|
|
|
SrcRect.Width(), SrcRect.Height(),
|
|
|
|
|
DestSize,
|
|
|
|
|
SrcSize,
|
|
|
|
|
*VertexShader,
|
2015-08-04 19:33:26 -04:00
|
|
|
View.StereoPass,
|
|
|
|
|
Context.HasHmdMesh(),
|
2014-07-29 17:33:28 -04:00
|
|
|
EDRF_UseTriangleOptimization);
|
|
|
|
|
|
2014-10-23 13:36:07 -04:00
|
|
|
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
|
2015-07-29 16:42:44 -04:00
|
|
|
|
|
|
|
|
// replace the current SceneColor with this one
|
|
|
|
|
SceneContext.SetSceneColor(PassOutputs[0].PooledRenderTarget);
|
|
|
|
|
PassOutputs[0].PooledRenderTarget.SafeRelease();
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-10-02 17:19:02 -04:00
|
|
|
FPooledRenderTargetDesc FRCPassPostProcessSubsurfaceRecombine::ComputeOutputDesc(EPassOutputId InPassOutputId) const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-07-29 16:42:44 -04:00
|
|
|
FPooledRenderTargetDesc Ret = GetInput(ePId_Input0)->GetOutput()->RenderTargetDesc;
|
2014-07-29 17:33:28 -04:00
|
|
|
|
2015-07-29 16:42:44 -04:00
|
|
|
Ret.Reset();
|
|
|
|
|
Ret.DebugName = TEXT("SceneColorSubsurface");
|
|
|
|
|
|
|
|
|
|
// we replace the HDR SceneColor with this one
|
2014-03-14 14:13:41 -04:00
|
|
|
return Ret;
|
2014-10-02 17:19:02 -04:00
|
|
|
}
|