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
/*=============================================================================
PostProcessMotionBlur . cpp : Post process MotionBlur implementation .
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
# include "RendererPrivate.h"
# include "ScenePrivate.h"
# include "SceneFilterRendering.h"
2015-02-23 00:44:20 -05:00
# include "PostProcessAmbientOcclusion.h"
2014-03-14 14:13:41 -04:00
# include "PostProcessMotionBlur.h"
2015-03-04 08:31:40 -05:00
# include "PostProcessAmbientOcclusion.h"
2014-03-14 14:13:41 -04:00
# include "PostProcessing.h"
2014-08-21 06:03:00 -04:00
# include "SceneUtils.h"
2015-04-23 17:35:40 -04:00
# include "GPUSkinVertexFactory.h"
# include "../../Engine/Private/SkeletalRenderGPUSkin.h"
2014-03-14 14:13:41 -04:00
2014-06-25 05:47:33 -04:00
# if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
static TAutoConsoleVariable < int32 > CVarMotionBlurFiltering (
TEXT ( " r.MotionBlurFiltering " ) ,
0 ,
TEXT ( " Useful developer variable \n " )
TEXT ( " 0: off (default, expected by the shader for better quality) \n " )
TEXT ( " 1: on " ) ,
ECVF_Cheat | ECVF_RenderThreadSafe ) ;
# endif
2014-03-14 14:13:41 -04:00
2015-11-18 09:31:10 -05:00
static TAutoConsoleVariable < float > CVarMotionBlur2ndScale (
TEXT ( " r.MotionBlur2ndScale " ) ,
1.0f ,
TEXT ( " " ) ,
2015-02-24 16:28:47 -05:00
ECVF_Cheat | ECVF_RenderThreadSafe ) ;
2014-03-14 14:13:41 -04:00
2014-09-05 17:47:58 -04:00
/** Encapsulates the post processing motion blur vertex shader. */
class FPostProcessMotionBlurSetupVS : public FGlobalShader
{
DECLARE_SHADER_TYPE ( FPostProcessMotionBlurSetupVS , Global ) ;
static bool ShouldCache ( EShaderPlatform Platform )
{
2014-09-08 04:39:14 -04:00
return IsFeatureLevelSupported ( Platform , ERHIFeatureLevel : : SM4 ) ;
2014-09-05 17:47:58 -04:00
}
/** Default constructor. */
FPostProcessMotionBlurSetupVS ( ) { }
// FShader interface.
2015-04-01 07:20:55 -04:00
virtual bool Serialize ( FArchive & Ar ) override
2014-09-05 17:47:58 -04:00
{
bool bShaderHasOutdatedParameters = FGlobalShader : : Serialize ( Ar ) ;
Ar < < PostprocessParameter ;
return bShaderHasOutdatedParameters ;
}
/** to have a similar interface as all other shaders */
void SetParameters ( const FRenderingCompositePassContext & Context )
{
const auto ShaderRHI = GetVertexShader ( ) ;
FGlobalShader : : SetParameters ( Context . RHICmdList , ShaderRHI , Context . View ) ;
PostprocessParameter . SetVS ( ShaderRHI , Context , TStaticSamplerState < SF_Point , AM_Clamp , AM_Clamp , AM_Clamp > : : GetRHI ( ) ) ;
}
public :
FPostProcessPassParameters PostprocessParameter ;
/** Initialization constructor. */
FPostProcessMotionBlurSetupVS ( const ShaderMetaType : : CompiledShaderInitializerType & Initializer )
: FGlobalShader ( Initializer )
{
PostprocessParameter . Bind ( Initializer . ParameterMap ) ;
}
} ;
IMPLEMENT_SHADER_TYPE ( , FPostProcessMotionBlurSetupVS , TEXT ( " PostProcessMotionBlur " ) , TEXT ( " SetupVS " ) , SF_Vertex ) ;
2014-03-14 14:13:41 -04:00
/** Encapsulates the post processing motion blur pixel shader. */
class FPostProcessMotionBlurSetupPS : public FGlobalShader
{
DECLARE_SHADER_TYPE ( FPostProcessMotionBlurSetupPS , Global ) ;
static bool ShouldCache ( EShaderPlatform Platform )
{
2014-08-25 14:41:54 -04:00
return IsFeatureLevelSupported ( Platform , ERHIFeatureLevel : : SM4 ) ;
2014-03-14 14:13:41 -04:00
}
/** Default constructor. */
FPostProcessMotionBlurSetupPS ( ) { }
public :
FPostProcessPassParameters PostprocessParameter ;
FShaderParameter VelocityScale ;
/** Initialization constructor. */
FPostProcessMotionBlurSetupPS ( const ShaderMetaType : : CompiledShaderInitializerType & Initializer )
: FGlobalShader ( Initializer )
{
PostprocessParameter . Bind ( Initializer . ParameterMap ) ;
VelocityScale . Bind ( Initializer . ParameterMap , TEXT ( " VelocityScale " ) ) ;
}
// 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 ) ;
Ar < < PostprocessParameter < < VelocityScale ;
return bShaderHasOutdatedParameters ;
}
2014-06-12 07:13:34 -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 ) ;
2014-03-14 14:13:41 -04:00
2014-06-12 07:13:34 -04:00
PostprocessParameter . SetPS ( ShaderRHI , Context , TStaticSamplerState < SF_Point , AM_Clamp , AM_Clamp , AM_Clamp > : : GetRHI ( ) ) ;
2014-03-14 14:13:41 -04:00
{
const float SizeX = Context . View . ViewRect . Width ( ) ;
const float SizeY = Context . View . ViewRect . Height ( ) ;
const float InvAspectRatio = SizeY / SizeX ;
const FSceneViewState * ViewState = ( FSceneViewState * ) Context . View . State ;
const float MotionBlurTimeScale = ViewState ? ViewState - > MotionBlurTimeScale : 1.0f ;
const float ViewMotionBlurScale = 0.5f * MotionBlurTimeScale * Context . View . FinalPostProcessSettings . MotionBlurAmount ;
// 0:no 1:full screen width
float MaxVelocity = Context . View . FinalPostProcessSettings . MotionBlurMax / 100.0f ;
float InvMaxVelocity = 1.0f / MaxVelocity ;
float ObjectScaleX = ViewMotionBlurScale * InvMaxVelocity ;
float ObjectScaleY = ViewMotionBlurScale * InvMaxVelocity * InvAspectRatio ;
2014-06-12 07:13:34 -04:00
SetShaderValue ( Context . RHICmdList , ShaderRHI , VelocityScale , FVector4 ( ObjectScaleX , - ObjectScaleY , 0 , 0 ) ) ;
2014-03-14 14:13:41 -04:00
}
}
} ;
IMPLEMENT_SHADER_TYPE ( , FPostProcessMotionBlurSetupPS , TEXT ( " PostProcessMotionBlur " ) , TEXT ( " SetupPS " ) , SF_Pixel ) ;
void FRCPassPostProcessMotionBlurSetup : : Process ( FRenderingCompositePassContext & Context )
{
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 ;
// e.g. 4 means the input texture is 4x smaller than the buffer size
2015-05-29 10:47:57 -04:00
uint32 ScaleFactor = FSceneRenderTargets : : Get ( Context . RHICmdList ) . GetBufferSizeXY ( ) . X / SrcSize . X ;
2014-03-14 14:13:41 -04:00
FIntRect SrcRect = View . ViewRect / ScaleFactor ;
// Viewport size not even also causes issue
FIntRect DestRect = FIntRect : : DivideAndRoundUp ( SrcRect , 2 ) ;
2015-09-01 16:52:40 -04:00
SCOPED_DRAW_EVENTF ( Context . RHICmdList , MotionBlurSetup , TEXT ( " MotionBlurSetup %dx%d " ) , DestRect . Width ( ) , DestRect . Height ( ) ) ;
2014-03-14 14:13:41 -04:00
const FSceneRenderTargetItem & DestRenderTarget0 = PassOutputs [ 0 ] . RequestSurface ( Context ) ;
const FSceneRenderTargetItem & DestRenderTarget1 = PassOutputs [ 1 ] . RequestSurface ( Context ) ;
// Set the view family's render target/viewport.
FTextureRHIParamRef RenderTargets [ ] =
{
DestRenderTarget0 . TargetableTexture ,
DestRenderTarget1 . TargetableTexture
} ;
2014-06-12 07:13:34 -04:00
SetRenderTargets ( Context . RHICmdList , ARRAY_COUNT ( RenderTargets ) , RenderTargets , FTextureRHIParamRef ( ) , 0 , NULL ) ;
2014-03-14 14:13:41 -04:00
// is optimized away if possible (RT size=view size, )
FLinearColor ClearColors [ 2 ] = { FLinearColor ( 0 , 0 , 0 , 0 ) , FLinearColor ( 0 , 0 , 0 , 0 ) } ;
2014-06-12 07:13:34 -04:00
Context . RHICmdList . ClearMRT ( true , 2 , ClearColors , 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-06-05 16:38:54 -04:00
2014-09-05 17:47:58 -04:00
TShaderMapRef < FPostProcessMotionBlurSetupVS > VertexShader ( Context . GetShaderMap ( ) ) ;
2014-03-14 14:13:41 -04:00
2014-09-05 17:47:58 -04:00
{
2014-08-28 06:22:54 -04:00
TShaderMapRef < FPostProcessMotionBlurSetupPS > PixelShader ( Context . GetShaderMap ( ) ) ;
2014-03-14 14:13:41 -04:00
static FGlobalBoundShaderState BoundShaderState ;
2014-06-27 11:07:13 -04:00
2014-03-14 14:13:41 -04:00
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-08-04 19:33:26 -04:00
DrawPostProcessPass (
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 ,
2015-08-04 19:33:26 -04:00
View . StereoPass ,
Context . HasHmdMesh ( ) ,
2014-03-14 14:13:41 -04:00
EDRF_UseTriangleOptimization ) ;
2014-06-12 07:13:34 -04:00
Context . RHICmdList . CopyToResolveTarget ( DestRenderTarget0 . TargetableTexture , DestRenderTarget0 . ShaderResourceTexture , false , FResolveParams ( ) ) ;
Context . RHICmdList . CopyToResolveTarget ( DestRenderTarget1 . TargetableTexture , DestRenderTarget1 . ShaderResourceTexture , false , FResolveParams ( ) ) ;
2014-03-14 14:13:41 -04:00
}
FPooledRenderTargetDesc FRCPassPostProcessMotionBlurSetup : : ComputeOutputDesc ( EPassOutputId InPassOutputId ) const
{
if ( InPassOutputId = = ePId_Output0 )
{
// downsampled velocity
2015-07-06 18:04:49 -04:00
FPooledRenderTargetDesc Ret = GetInput ( ePId_Input0 ) - > GetOutput ( ) - > RenderTargetDesc ;
2014-03-14 14:13:41 -04:00
Ret . Reset ( ) ;
Ret . Extent / = 2 ;
Ret . Extent . X = FMath : : Max ( 1 , Ret . Extent . X ) ;
Ret . Extent . Y = FMath : : Max ( 1 , Ret . Extent . Y ) ;
// we need at least a format in the range 0..1 with RGB channels, A is unused
// Ret.Format = PF_A2B10G10R10;
// we need alpha to renormalize
Ret . Format = PF_FloatRGBA ;
Ret . TargetableFlags & = ~ TexCreate_UAV ;
Ret . TargetableFlags | = TexCreate_RenderTargetable ;
Ret . DebugName = TEXT ( " MotionBlurSetup0 " ) ;
return Ret ;
}
else
{
check ( InPassOutputId = = ePId_Output1 ) ;
// scene color with depth in alpha
2015-07-06 18:04:49 -04:00
FPooledRenderTargetDesc Ret = GetInput ( ePId_Input1 ) - > GetOutput ( ) - > RenderTargetDesc ;
2014-03-14 14:13:41 -04:00
Ret . Reset ( ) ;
Ret . Extent / = 2 ;
Ret . Extent . X = FMath : : Max ( 1 , Ret . Extent . X ) ;
Ret . Extent . Y = FMath : : Max ( 1 , Ret . Extent . Y ) ;
Ret . Format = PF_FloatRGBA ;
Ret . TargetableFlags & = ~ TexCreate_UAV ;
Ret . TargetableFlags | = TexCreate_RenderTargetable ;
Ret . DebugName = TEXT ( " MotionBlurSetup1 " ) ;
return Ret ;
}
}
/**
* @ param Quality 0 : visualize , 1 : low , 2 : medium , 3 : high , 4 : very high
* Encapsulates a MotionBlur pixel shader .
*/
template < uint32 Quality >
class FPostProcessMotionBlurPS : public FGlobalShader
{
DECLARE_SHADER_TYPE ( FPostProcessMotionBlurPS , Global ) ;
static bool ShouldCache ( EShaderPlatform Platform )
{
return IsFeatureLevelSupported ( Platform , ERHIFeatureLevel : : SM4 ) ;
}
static void ModifyCompilationEnvironment ( EShaderPlatform Platform , FShaderCompilerEnvironment & OutEnvironment )
{
2014-06-05 16:38:54 -04:00
FGlobalShader : : ModifyCompilationEnvironment ( Platform , OutEnvironment ) ;
2014-03-14 14:13:41 -04:00
OutEnvironment . SetDefine ( TEXT ( " MOTION_BLUR_QUALITY " ) , Quality ) ;
}
/** Default constructor. */
FPostProcessMotionBlurPS ( ) { }
public :
FPostProcessPassParameters PostprocessParameter ;
FDeferredPixelShaderParameters DeferredParameters ;
FShaderParameter PrevViewProjMatrix ;
FShaderParameter TextureViewMad ;
FShaderParameter MotionBlurParameters ;
/** Initialization constructor. */
FPostProcessMotionBlurPS ( const ShaderMetaType : : CompiledShaderInitializerType & Initializer )
: FGlobalShader ( Initializer )
{
PostprocessParameter . Bind ( Initializer . ParameterMap ) ;
DeferredParameters . Bind ( Initializer . ParameterMap ) ;
PrevViewProjMatrix . Bind ( Initializer . ParameterMap , TEXT ( " PrevViewProjMatrix " ) ) ;
TextureViewMad . Bind ( Initializer . ParameterMap , TEXT ( " TextureViewMad " ) ) ;
MotionBlurParameters . Bind ( Initializer . ParameterMap , TEXT ( " MotionBlurParameters " ) ) ;
}
// 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 ) ;
Copying //UE4/Dev-Rendering to Dev-Main (//UE4/Dev-Main)
#lockdown ben.marsh
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2733540 on 2015/10/19 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream
Capsule shadows
* Capsule shadows excel at extremely soft area shadows caused by a large light source angle, but don't support accurate self-shadowing
* Artists can setup a physics asset containing Spheres and Sphyls (capsules) for a skeletal mesh that will be used to represent the mesh's occlusion
* These shapes can then be used for direct shadowing (bCastCapsuleDirectShadow) on a skeletal mesh component, whose softness depends on the light source angle / radius
* The shapes can also be used to create an indirect shadow (bCastCapsuleIndirectShadow), whose direction and softness is derived from the precomputed sky occlusion (stationary sky light) or primary indirect lighting (static sky light)
* Capsule shadowing is computed at half res and uses tiled deferred culling for efficiency - only implemented for PC SM5 + PS4 so far
* Shadowing of movable skylights is not yet supported
Change 2735460 on 2015/10/20 by Uriel.Doyon@uriel.doyon_office_data
Basepass drawlist are now merged within a single drawlist.
Lighting policy parameters are now accessed through a uniform buffer.
Changed the global resource initialization so that InitRHI now comes before InitDynamicRHI
#codereview nick.penwarden
Change 2744741 on 2015/10/28 by Nick.Penwarden@nickp_streams
Remove unused RHI methods:
RHIIsDrawingViewport
RHIGpuTimeBegin
RHIGpuTimeEnd
Made default/empty versions of these calls and removed stubs from RHIs that don't use them:
RHISuspendRendering
RHIResumeRendering
RHIIsRenderingSuspended
Change 2745714 on 2015/10/28 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream
Lighting channels - each component and light can choose from 3 channels
* Primitives output their channel mask to stencil during the base pass, the masks are copied to a texture after the base pass, deferred lighting passes compare the primitive mask against the light's mask
* Dynamic shadow casting also respects the channels
* Only works on opaque materials, direct lighting, dynamic lighting
* Not implemented for tiled deferred atm
* This will replace CastsShadowsFromCinematicObjectsOnly in the future
#rb Martin.Mittring
Change 2746243 on 2015/10/29 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New
First pass at separate Async Compute Context
#codereview Lee.Clark,Daniel.Wright
#rb Gil.Gribb
Change 2746989 on 2015/10/29 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering
Removed a lot of complexity of the skeletal mesh motionblur code (better for multithreading, simpler, faster) but going from one large buffer to per mesh buffers. Upload of bones only needed once.
* GPUSkinCache didn't even work before (in this branch)
* tested BasePass velocity
* tested split screen
* tested editor pause
* matinee camera cut (no need, invalidates velocity)
* tested CPU Skin? (never has motionblur)
* tested CreateSceneProxy (recreation is prevented in CreteSceneProxy unless bone count changes)
* test ES2 -featureleveles2
#rb: Rolando.Caloca
Change 2750734 on 2015/11/02 by Uriel.Doyon@uriel.doyon_office_data
Embree integration into Lightmass
Can be enabled through Lightmass.ini [DevOptions.StaticLighting]bUseEmbree.
Also [DevOptions.StaticLighting]bVerifyEmbree will compare ray casting results.
Only usable on Win64 with this submit.
#review daniel.wright
Change 2752730 on 2015/11/03 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering
added SSAO CS version, can be enabled with
r.AmbientOcclusion.Compute 1
Not optimized yet
#rb:Olaf.Piesche
Change 2752766 on 2015/11/03 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream
Lightmass solver quality improvements
* IndirectLightingScale is no longer applied to photons, avoids splotchy artifacts when using small scales
* New 'Lightmass Portal' actor / component which tells the solver where to look for significant lighting. When lighting with a Static Skylight only, in a mostly indoor environment, setting up these portals is the only way to get high quality.
* Skylight bounce lighting is now much more accurate and leverages adaptive sampling
* Fixed a bug that effectively disabled adaptive sampling on high IndirectLightingQualities
* Shadow penumbras are also improved by IndirectLightingQuality
* Texel debugging is now a cvar 'r.TexelDebugging', instead of requiring a full recompile
Change 2754018 on 2015/11/04 by Uriel.Doyon@uriel.doyon_office_data
Quad Complexity ViewMode (PCD3D_SM5 only).
Shader Complexity with Quad Overhead ViewMode (PCD3D_SM5 only). Require ShaderComplexity ViewMode & Show.Visualize.QuadOverhead
#review brian.karis
Change 2754760 on 2015/11/04 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering
improved SSAO quality (less high frequency noise) to avoid TemporalAA smearing
Change 2756308 on 2015/11/05 by Rolando.Caloca@rolando.caloca_T3903_S
DevRendering - Enable removing unused outputs on PS4 shader pipelines, disable by default removing unused on D3D (toggable with r.D3DRemoveUnusedInterpolators)
#codereview Marcus.Wassmer
Change 2757063 on 2015/11/06 by Simon.Tovey@Simon.Tovey_Dev
Submitting pull request from user Pierdek.
Early out of particle collision module update if there are no active particles.
#github
#1614
Change 2757340 on 2015/11/06 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering
UE4 - Fixed the experimental r.RHICmdBalanceParallelLists 2 mode and renabled it for orion.
Change 2757343 on 2015/11/06 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering
UE4 - Added a path so that texture streaming can avoid flushing the RHI thread.
Change 2757985 on 2015/11/06 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream
Added new PrimitiveComponent setting bSingleSampleShadowFromStationaryLights
* When enabled, shadowing of a movable component from a stationary directional light will come from the Volume Lighting Samples precomputed by Lightmass
* This provides essentially free on/off shadow receiving on dynamic objects, with a fade over time between states
* Lighting has to be rebuilt once for this to work
#rb Rolando.Caloca
Change 2759058 on 2015/11/09 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering
UE4 - Dynamically set stream source to avoid creating a separate drawing policy for each static mesh with vertex colors.
#rb Daniel.Wright
Change 2760523 on 2015/11/10 by Uriel.Doyon@uriel.doyon_office_data
Enabled Embree by default
#review daniel.wright
==========================
ALL CHANGELISTS
==========================
Change 2720123 on 2015/10/07 by Rolando.Caloca@Rolando.Caloca_T4688_5331 'Dev-Rendering - 'integrate' Tem'
Change 2721682 on 2015/10/08 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Eliminated a fatal error '
Change 2721815 on 2015/10/08 by Rolando.Caloca@Rolando.Caloca_T4688_5331 'Dev-Rendering - Fix crash exiti'
Change 2724755 on 2015/10/12 by Rolando.Caloca@Rolando.Caloca_T4688_5331 'Dev-Rendering - D3D12 Fix Tier'
Change 2724781 on 2015/10/12 by Rolando.Caloca@Rolando.Caloca_T4688_5331 'Dev-Rendering - D3D12 Fix offse'
Change 2728317 on 2015/10/14 by Rolando.Caloca@Rolando.Caloca_T4688_5331 'Dev-Rendering - hlslcc - Fix fo'
Change 2729170 on 2015/10/14 by Chris.Bunner@Chris.Bunner_Dev_Stream 'Force Lightmass volume sample g'
Change 2732131 on 2015/10/16 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'fixed resource transition issue'
Change 2732218 on 2015/10/16 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'minor code cleanup '
Change 2733533 on 2015/10/19 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Clear stencil to 0 after decals'
Change 2733540 on 2015/10/19 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Capsule shadows * Capsule shado'
Change 2733546 on 2015/10/19 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Light shaft targets are only al'
Change 2733602 on 2015/10/19 by Uriel.Doyon@uriel.doyon_office_data 'Decals not writing to Normal ca'
Change 2733627 on 2015/10/19 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix for transition ensure. '
Change 2735292 on 2015/10/20 by Brian.Karis@Brian.Karis_T3247_Rendering 'Fix for dark lightmap precision'
Change 2735298 on 2015/10/20 by Brian.Karis@Brian.Karis_T3247_Rendering 'Fix for speedtree LOD transitio'
Change 2735460 on 2015/10/20 by Uriel.Doyon@uriel.doyon_office_data 'Basepass drawlist are now merge'
Change 2737214 on 2015/10/21 by Chris.Bunner@Chris.Bunner_Dev_Stream 'Expanded a warning when importi'
Change 2738581 on 2015/10/22 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Updated comment on stencil usag'
Change 2738583 on 2015/10/22 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Changed bound but not set scene'
Change 2738584 on 2015/10/22 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Fixed skylight occlusion maps b'
Change 2738589 on 2015/10/22 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Lightmap streaming fixes * Chan'
Change 2738593 on 2015/10/22 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Fix from licensee for race cond'
Change 2738982 on 2015/10/22 by Olaf.Piesche@Olaf.Piesche_roaming 'Activating CanTickOnAnyThread f'
Change 2739032 on 2015/10/22 by Olaf.Piesche@Olaf.Piesche_roaming 'Fixing compiler barf with Clang'
Change 2741517 on 2015/10/26 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRindering - D3D12 - Integrat'
Change 2743790 on 2015/10/27 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Fixed texel debugging on static'
Change 2743958 on 2015/10/27 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'added comments '
Change 2744153 on 2015/10/27 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Unity compile fix '
Change 2744741 on 2015/10/28 by Nick.Penwarden@nickp_streams 'Remove unused RHI methods: RHI'
Change 2745714 on 2015/10/28 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Lighting channels - each compon'
Change 2746242 on 2015/10/29 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix crashes on init by swapping'
Change 2746243 on 2015/10/29 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'First pass at separate Async Co'
Change 2746296 on 2015/10/29 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Buffer label frees so we don't '
Change 2746297 on 2015/10/29 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'updated comment '
Change 2746343 on 2015/10/29 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'added comment '
Change 2746347 on 2015/10/29 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'added comment '
Change 2746811 on 2015/10/29 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Draw event for compute commandl'
Change 2746989 on 2015/10/29 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'Removed a lot of complexity of '
Change 2747127 on 2015/10/29 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'Improved game console printout '
Change 2747702 on 2015/10/30 by Chris.Bunner@Chris.Bunner_Dev_Stream 'Bumped Lightmass StaticMesh imp'
Change 2747954 on 2015/10/30 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix SubmitDone not called TRC e'
Change 2747979 on 2015/10/30 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'polish console autocomplete tex'
Change 2750719 on 2015/11/02 by Uriel.Doyon@uriel.doyon_office_data 'Add Embree 2.7.0 for Win64 and '
Change 2750734 on 2015/11/02 by Uriel.Doyon@uriel.doyon_office_data 'Embree integration into Lightma'
Change 2750872 on 2015/11/02 by Nick.Penwarden@nickp_streams 'Merging //UE4/Dev-Main to Dev-R'
Change 2751934 on 2015/11/03 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Disambiguate template function '
Change 2752190 on 2015/11/03 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Fixed assert relating to '
Change 2752333 on 2015/11/03 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - Shader pipeline '
Change 2752655 on 2015/11/03 by Rolando.Caloca@Rolando.Caloca_T3903_S 'DevRendering - Fix Materials pa'
Change 2752710 on 2015/11/03 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'added comment '
Change 2752711 on 2015/11/03 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'added better comment/help text '
Change 2752730 on 2015/11/03 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'added SSAO CS version, can be e'
Change 2752766 on 2015/11/03 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Lightmass solver quality improv'
Change 2752869 on 2015/11/03 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - Add shader pipel'
Change 2752882 on 2015/11/03 by Rolando.Caloca@Rolando.Caloca_T3903_S 'DevRendering - hlslcc - Metal -'
Change 2752899 on 2015/11/03 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'small SSAO GPU optimization mov'
Change 2752934 on 2015/11/03 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'minor GPU optimization for SSAO'
Change 2753109 on 2015/11/03 by Uriel.Doyon@uriel.doyon_office_data 'Fixed final build '
Change 2753669 on 2015/11/04 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'fixed SM4 compiling '
Change 2754002 on 2015/11/04 by Nick.Penwarden@nickp_streams 'test change '
Change 2754018 on 2015/11/04 by Uriel.Doyon@uriel.doyon_office_data 'Quad Complexity ViewMode (PCD3D'
Change 2754115 on 2015/11/04 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Fixed end of frame update'
Change 2754297 on 2015/11/04 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'PS4 compile fixes #codereview U'
Change 2754405 on 2015/11/04 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'minor SSAO ALU optimizations fi'
Change 2754512 on 2015/11/04 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'adjusted clamp for cvar '
Change 2754760 on 2015/11/04 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'improved SSAO quality (less hig'
Change 2755572 on 2015/11/05 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - PS4 warning fix '
Change 2755667 on 2015/11/05 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Fixed UE-22742, leak in t'
Change 2755722 on 2015/11/05 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - Remove unused co'
Change 2755814 on 2015/11/05 by Nick.Penwarden@nickp_streams 'Merging //UE4/Dev-Main to Dev-R'
Change 2755935 on 2015/11/05 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - Rebuild static m'
Change 2756003 on 2015/11/05 by Uriel.Doyon@uriel.doyon_office_data 'Reduce the number of precompute'
Change 2756145 on 2015/11/05 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Temp fix for GPU crash #rb none'
Change 2756308 on 2015/11/05 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - Enable removing '
Change 2756435 on 2015/11/05 by Olaf.Piesche@Olaf.Piesche_roaming 'Disabling a check, to fix OR-85'
Change 2757063 on 2015/11/06 by Simon.Tovey@Simon.Tovey_Dev 'Submitting pull request from us'
Change 2757340 on 2015/11/06 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Fixed the experimental r.'
Change 2757341 on 2015/11/06 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Changed the RHI thread di'
Change 2757342 on 2015/11/06 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Fixed lazy uniform buffer'
Change 2757343 on 2015/11/06 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Added a path so that text'
Change 2757500 on 2015/11/06 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Add FrameSync to externalprofil'
Change 2757650 on 2015/11/06 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'GBuffer should only be consider'
Change 2757665 on 2015/11/06 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'UE-22816 Instruction count is n'
Change 2757834 on 2015/11/06 by Michael.Trepka@Michael.Trepka_a4202_Dev-Rendering 'Embree integration into Lightma'
Change 2757930 on 2015/11/06 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix UT ensure #rb Peter.Knepley'
Change 2757931 on 2015/11/06 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix Ocean ensure #rb josh.ander'
Change 2757946 on 2015/11/06 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Removed invalid Lightmass asser'
Change 2757985 on 2015/11/06 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Added new PrimitiveComponent se'
Change 2758049 on 2015/11/06 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'OR-8600 CRASH: AllocationLeveli'
Change 2758059 on 2015/11/06 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'r.DumpTransitionsForResource #r'
Change 2758082 on 2015/11/06 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - Fix resource tra'
Change 2758879 on 2015/11/09 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - Fix PSSL names f'
Change 2758911 on 2015/11/09 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Fixed accidental force di'
Change 2758968 on 2015/11/09 by Uriel.Doyon@uriel.doyon_office_data 'Disabled single frame buffer us'
Change 2758991 on 2015/11/09 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix togglerhithread crash #rb G'
Change 2759058 on 2015/11/09 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Dynamically set stream so'
Change 2759063 on 2015/11/09 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'fixed UE-22368 CLONE - GitHub 1'
Change 2759073 on 2015/11/09 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'minor code quality improvements'
Change 2759501 on 2015/11/09 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix particle ensure. '
Change 2759522 on 2015/11/09 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix decals using CustomStencil.'
Change 2759610 on 2015/11/09 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Fixed line light source shadows'
Change 2759634 on 2015/11/09 by Uriel.Doyon@uriel.doyon_office_data 'Refined GBufferA resolving when'
Change 2759657 on 2015/11/09 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'Fixed ResourceTransition with r'
Change 2759693 on 2015/11/09 by Rolando.Caloca@Rolando.Caloca_T4688_S 'DevRendering - Fixed global sha'
Change 2759771 on 2015/11/09 by Uriel.Doyon@uriel.doyon_office_data 'Fixed editor hit proxy renderin'
Change 2760188 on 2015/11/09 by Uriel.Doyon@uriel.doyon_office_data 'Disabled some more deferred dec'
Change 2760523 on 2015/11/10 by Uriel.Doyon@uriel.doyon_office_data 'Enabled Embree by default #revi'
[CL 2761339 by Nick Penwarden in Main branch]
2015-11-10 17:11:09 -05:00
Ar < < PostprocessParameter < < DeferredParameters < < PrevViewProjMatrix < < TextureViewMad < < MotionBlurParameters ;
2014-03-14 14:13:41 -04:00
return bShaderHasOutdatedParameters ;
}
2014-06-12 07:13:34 -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 ) ;
2014-03-14 14:13:41 -04:00
2014-06-12 07:13:34 -04:00
DeferredParameters . Set ( Context . RHICmdList , ShaderRHI , Context . View ) ;
2014-03-14 14:13:41 -04:00
{
bool bFiltered = false ;
# if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
2014-06-25 05:47:33 -04:00
bFiltered = CVarMotionBlurFiltering . GetValueOnRenderThread ( ) ! = 0 ;
2014-03-14 14:13:41 -04:00
# endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
if ( bFiltered )
{
2014-06-12 07:13:34 -04:00
PostprocessParameter . SetPS ( ShaderRHI , Context , TStaticSamplerState < SF_Bilinear , AM_Border , AM_Border , AM_Clamp > : : GetRHI ( ) ) ;
2014-03-14 14:13:41 -04:00
}
else
{
2014-06-12 07:13:34 -04:00
PostprocessParameter . SetPS ( ShaderRHI , Context , TStaticSamplerState < SF_Point , AM_Border , AM_Border , AM_Clamp > : : GetRHI ( ) ) ;
2014-03-14 14:13:41 -04:00
}
}
if ( Context . View . Family - > EngineShowFlags . CameraInterpolation )
{
// Instead of finding the world space position of the current pixel, calculate the world space position offset by the camera position,
// then translate by the difference between last frame's camera position and this frame's camera position,
// then apply the rest of the transforms. This effectively avoids precision issues near the extents of large levels whose world space position is very large.
FVector ViewOriginDelta = Context . View . ViewMatrices . ViewOrigin - Context . View . PrevViewMatrices . ViewOrigin ;
2014-06-12 07:13:34 -04:00
SetShaderValue ( Context . RHICmdList , ShaderRHI , PrevViewProjMatrix , FTranslationMatrix ( ViewOriginDelta ) * Context . View . PrevViewRotationProjMatrix ) ;
2014-03-14 14:13:41 -04:00
}
else
{
2014-06-12 07:13:34 -04:00
SetShaderValue ( Context . RHICmdList , ShaderRHI , PrevViewProjMatrix , Context . View . ViewMatrices . GetViewRotationProjMatrix ( ) ) ;
2014-03-14 14:13:41 -04:00
}
TRefCountPtr < IPooledRenderTarget > InputPooledElement = Context . Pass - > GetInput ( ePId_Input0 ) - > GetOutput ( ) - > RequestInput ( ) ;
// to mask out samples from outside of the view
{
2015-05-29 10:47:57 -04:00
FIntPoint BufferSize = FSceneRenderTargets : : Get ( Context . RHICmdList ) . GetBufferSizeXY ( ) ;
2014-03-14 14:13:41 -04:00
FVector2D InvBufferSize ( 1.0f / BufferSize . X , 1.0f / BufferSize . Y ) ;
FIntRect ClipRect = Context . View . ViewRect ;
// to avoid leaking in content from the outside because of bilinear filtering, shrink
ClipRect . InflateRect ( - 1 ) ;
FVector2D MinUV ( ClipRect . Min . X * InvBufferSize . X , ClipRect . Min . Y * InvBufferSize . Y ) ;
FVector2D MaxUV ( ClipRect . Max . X * InvBufferSize . X , ClipRect . Max . Y * InvBufferSize . Y ) ;
FVector2D SizeUV = MaxUV - MinUV ;
FVector2D Mul ( 1.0f / SizeUV . X , 1.0f / SizeUV . Y ) ;
FVector2D Add = - MinUV * Mul ;
FVector4 TextureViewMadValue ( Mul . X , Mul . Y , Add . X , Add . Y ) ;
2014-06-12 07:13:34 -04:00
SetShaderValue ( Context . RHICmdList , ShaderRHI , TextureViewMad , TextureViewMadValue ) ;
2014-03-14 14:13:41 -04:00
}
{
const float SizeX = Context . View . ViewRect . Width ( ) ;
const float SizeY = Context . View . ViewRect . Height ( ) ;
const float AspectRatio = SizeX / SizeY ;
const float InvAspectRatio = SizeY / SizeX ;
const FSceneViewState * ViewState = ( FSceneViewState * ) Context . View . State ;
float MotionBlurTimeScale = ViewState ? ViewState - > MotionBlurTimeScale : 1.0f ;
float ViewMotionBlurScale = 0.5f * MotionBlurTimeScale * Context . View . FinalPostProcessSettings . MotionBlurAmount ;
// MotionBlurInstanceScale was needed to hack some cases where motion blur wasn't working well, this shouldn't be needed any more, can clean this up later
float MotionBlurInstanceScale = 1 ;
float ObjectMotionBlurScale = MotionBlurInstanceScale * ViewMotionBlurScale ;
// 0:no 1:full screen width, percent conversion
float MaxVelocity = Context . View . FinalPostProcessSettings . MotionBlurMax / 100.0f ;
float InvMaxVelocity = 1.0f / MaxVelocity ;
// *2 to convert to -1..1 -1..1 screen space
// / MaxFraction to map screenpos to -1..1 normalized MaxFraction
FVector4 MotionBlurParametersValue (
ObjectMotionBlurScale * InvMaxVelocity ,
- ObjectMotionBlurScale * InvMaxVelocity * InvAspectRatio ,
MaxVelocity * 2 ,
- MaxVelocity * 2 * AspectRatio ) ;
2014-06-12 07:13:34 -04:00
SetShaderValue ( Context . RHICmdList , ShaderRHI , MotionBlurParameters , MotionBlurParametersValue ) ;
2014-03-14 14:13:41 -04:00
}
}
static const TCHAR * GetSourceFilename ( )
{
return TEXT ( " PostProcessMotionBlur " ) ;
}
static const TCHAR * GetFunctionName ( )
{
return TEXT ( " MainPS " ) ;
}
} ;
// #define avoids a lot of code duplication
# define VARIATION1(A) typedef FPostProcessMotionBlurPS<A> FPostProcessMotionBlurPS##A; \
IMPLEMENT_SHADER_TYPE2 ( FPostProcessMotionBlurPS # # A , SF_Pixel ) ;
VARIATION1 ( 0 ) VARIATION1 ( 1 ) VARIATION1 ( 2 ) VARIATION1 ( 3 ) VARIATION1 ( 4 )
# undef VARIATION1
// @param Quality 0: visualize, 1:low, 2:medium, 3:high, 4:very high
template < uint32 Quality >
2014-06-12 07:13:34 -04:00
static void SetMotionBlurShaderTempl ( const FRenderingCompositePassContext & Context )
2014-03-14 14:13:41 -04:00
{
2014-08-28 06:22:54 -04:00
TShaderMapRef < FPostProcessVS > VertexShader ( Context . GetShaderMap ( ) ) ;
TShaderMapRef < FPostProcessMotionBlurPS < Quality > > PixelShader ( Context . GetShaderMap ( ) ) ;
2014-03-14 14:13:41 -04:00
static FGlobalBoundShaderState BoundShaderState ;
2014-06-27 11:07:13 -04:00
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
VertexShader - > SetParameters ( Context ) ;
PixelShader - > SetParameters ( Context ) ;
2014-03-14 14:13:41 -04:00
}
FRCPassPostProcessMotionBlur : : FRCPassPostProcessMotionBlur ( uint32 InQuality )
: Quality ( InQuality )
{
// internal error
check ( Quality > = 1 & & Quality < = 4 ) ;
}
void FRCPassPostProcessMotionBlur : : Process ( FRenderingCompositePassContext & Context )
{
const FPooledRenderTargetDesc * InputDesc = GetInputDesc ( ePId_Input0 ) ;
if ( ! InputDesc )
{
// input is not hooked up correctly
return ;
}
const FSceneView & View = Context . View ;
FIntPoint TexSize = InputDesc - > Extent ;
// we assume the input and output is full resolution
FIntPoint SrcSize = InputDesc - > Extent ;
FIntPoint DestSize = PassOutputs [ 0 ] . RenderTargetDesc . Extent ;
// e.g. 4 means the input texture is 4x smaller than the buffer size
2015-05-29 10:47:57 -04:00
uint32 ScaleFactor = FSceneRenderTargets : : Get ( Context . RHICmdList ) . GetBufferSizeXY ( ) . X / SrcSize . X ;
2014-03-14 14:13:41 -04:00
FIntRect SrcRect = FIntRect : : DivideAndRoundUp ( View . ViewRect , ScaleFactor ) ;
2015-09-03 13:11:59 -04:00
SCOPED_DRAW_EVENTF ( Context . RHICmdList , MotionBlur , TEXT ( " MotionBlur(Old) %dx%d " ) , SrcRect . Width ( ) , SrcRect . Height ( ) ) ;
2014-03-14 14:13:41 -04:00
FIntRect DestRect = SrcRect ;
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 , SrcRect ) ;
2014-03-14 14:13:41 -04:00
Context . SetViewportAndCallRHI ( SrcRect ) ;
// 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
if ( Quality = = 1 )
{
2014-06-12 07:13:34 -04:00
SetMotionBlurShaderTempl < 1 > ( Context ) ;
2014-03-14 14:13:41 -04:00
}
else if ( Quality = = 2 )
{
2014-06-12 07:13:34 -04:00
SetMotionBlurShaderTempl < 2 > ( Context ) ;
2014-03-14 14:13:41 -04:00
}
else if ( Quality = = 3 )
{
2014-06-12 07:13:34 -04:00
SetMotionBlurShaderTempl < 3 > ( Context ) ;
2014-03-14 14:13:41 -04:00
}
else
{
check ( Quality = = 4 ) ;
2014-06-12 07:13:34 -04:00
SetMotionBlurShaderTempl < 4 > ( Context ) ;
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
2015-08-04 19:33:26 -04:00
DrawPostProcessPass (
2014-06-12 07:13:34 -04:00
Context . RHICmdList ,
2014-03-14 14:13:41 -04:00
0 , 0 ,
SrcRect . Width ( ) , SrcRect . Height ( ) ,
2015-08-04 19:33:26 -04:00
SrcRect . Min . X , SrcRect . Min . Y ,
2014-03-14 14:13:41 -04:00
SrcRect . Width ( ) , SrcRect . Height ( ) ,
SrcRect . Size ( ) ,
SrcSize ,
2014-04-23 17:26:59 -04:00
* VertexShader ,
2015-08-04 19:33:26 -04:00
View . StereoPass ,
Context . HasHmdMesh ( ) ,
2014-03-14 14:13:41 -04:00
EDRF_UseTriangleOptimization ) ;
2014-06-12 07:13:34 -04:00
Context . RHICmdList . CopyToResolveTarget ( DestRenderTarget . TargetableTexture , DestRenderTarget . ShaderResourceTexture , false , FResolveParams ( ) ) ;
2014-03-14 14:13:41 -04:00
}
FPooledRenderTargetDesc FRCPassPostProcessMotionBlur : : ComputeOutputDesc ( EPassOutputId InPassOutputId ) const
{
2015-07-06 18:04:49 -04:00
FPooledRenderTargetDesc Ret = GetInput ( ePId_Input0 ) - > GetOutput ( ) - > RenderTargetDesc ;
2014-03-14 14:13:41 -04:00
Ret . Reset ( ) ;
Ret . DebugName = TEXT ( " MotionBlur " ) ;
2015-09-28 14:13:15 -04:00
Ret . AutoWritable = false ;
2014-03-14 14:13:41 -04:00
return Ret ;
}
/** Encapsulates a MotionBlur recombine pixel shader. */
class FPostProcessMotionBlurRecombinePS : public FGlobalShader
{
DECLARE_SHADER_TYPE ( FPostProcessMotionBlurRecombinePS , Global ) ;
static bool ShouldCache ( EShaderPlatform Platform )
{
return IsFeatureLevelSupported ( Platform , ERHIFeatureLevel : : SM4 ) ;
}
static void ModifyCompilationEnvironment ( EShaderPlatform Platform , FShaderCompilerEnvironment & OutEnvironment )
{
FGlobalShader : : ModifyCompilationEnvironment ( Platform , OutEnvironment ) ;
}
/** Default constructor. */
FPostProcessMotionBlurRecombinePS ( ) { }
public :
FPostProcessPassParameters PostprocessParameter ;
/** Initialization constructor. */
FPostProcessMotionBlurRecombinePS ( const ShaderMetaType : : CompiledShaderInitializerType & Initializer )
: FGlobalShader ( Initializer )
{
PostprocessParameter . Bind ( Initializer . ParameterMap ) ;
}
// 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 ) ;
Ar < < PostprocessParameter ;
return bShaderHasOutdatedParameters ;
}
2015-04-23 17:35:40 -04:00
void SetParameters ( const FRenderingCompositePassContext & Context , bool bBilinear )
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 ) ;
2014-03-14 14:13:41 -04:00
2015-04-23 17:35:40 -04:00
if ( bBilinear )
{
PostprocessParameter . SetPS ( ShaderRHI , Context , TStaticSamplerState < SF_Bilinear , AM_Border , AM_Border , AM_Clamp > : : GetRHI ( ) ) ;
}
else
{
PostprocessParameter . SetPS ( ShaderRHI , Context , TStaticSamplerState < SF_Point , AM_Border , AM_Border , AM_Clamp > : : GetRHI ( ) ) ;
}
2014-03-14 14:13:41 -04:00
}
} ;
IMPLEMENT_SHADER_TYPE ( , FPostProcessMotionBlurRecombinePS , TEXT ( " PostProcessMotionBlur " ) , TEXT ( " MainRecombinePS " ) , SF_Pixel ) ;
void FRCPassPostProcessMotionBlurRecombine : : Process ( FRenderingCompositePassContext & Context )
{
const FPooledRenderTargetDesc * InputDesc = GetInputDesc ( ePId_Input0 ) ;
if ( ! InputDesc )
{
// input is not hooked up correctly
return ;
}
const FSceneView & View = Context . View ;
FIntPoint TexSize = InputDesc - > Extent ;
// we assume the input and output is full resolution
FIntPoint SrcSize = InputDesc - > Extent ;
FIntPoint DestSize = PassOutputs [ 0 ] . RenderTargetDesc . Extent ;
// e.g. 4 means the input texture is 4x smaller than the buffer size
2015-05-29 10:47:57 -04:00
uint32 ScaleFactor = FSceneRenderTargets : : Get ( Context . RHICmdList ) . GetBufferSizeXY ( ) . X / SrcSize . X ;
2014-03-14 14:13:41 -04:00
FIntRect SrcRect = View . ViewRect / ScaleFactor ;
FIntRect DestRect = SrcRect ;
2015-09-01 16:52:40 -04:00
SCOPED_DRAW_EVENTF ( Context . RHICmdList , MotionBlurRecombine , TEXT ( " MotionBlurRecombine %dx%d " ) , DestRect . Width ( ) , DestRect . Height ( ) ) ;
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 , SrcRect ) ;
2014-03-14 14:13:41 -04:00
Context . SetViewportAndCallRHI ( SrcRect ) ;
// 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-08-28 06:22:54 -04:00
TShaderMapRef < FPostProcessVS > VertexShader ( Context . GetShaderMap ( ) ) ;
TShaderMapRef < FPostProcessMotionBlurRecombinePS > PixelShader ( Context . GetShaderMap ( ) ) ;
2014-03-14 14:13:41 -04:00
static FGlobalBoundShaderState BoundShaderState ;
2014-06-27 11:07:13 -04:00
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
2015-04-23 17:35:40 -04:00
// with point filtering we can better debug in Visualize MotionBlur
const bool bBilinear = ! View . Family - > EngineShowFlags . VisualizeMotionBlur ;
2014-06-12 07:13:34 -04:00
VertexShader - > SetParameters ( Context ) ;
2015-04-23 17:35:40 -04:00
PixelShader - > SetParameters ( Context , bBilinear ) ;
2014-03-14 14:13:41 -04:00
2015-08-04 19:33:26 -04:00
DrawPostProcessPass (
2014-06-12 07:13:34 -04:00
Context . RHICmdList ,
2014-03-14 14:13:41 -04:00
0 , 0 ,
SrcRect . Width ( ) , SrcRect . Height ( ) ,
2015-08-04 19:33:26 -04:00
SrcRect . Min . X , SrcRect . Min . Y ,
2014-03-14 14:13:41 -04:00
SrcRect . Width ( ) , SrcRect . Height ( ) ,
SrcRect . Size ( ) ,
SrcSize ,
2014-04-23 17:26:59 -04:00
* VertexShader ,
2015-08-04 19:33:26 -04:00
View . StereoPass ,
Context . HasHmdMesh ( ) ,
2014-03-14 14:13:41 -04:00
EDRF_UseTriangleOptimization ) ;
2014-06-12 07:13:34 -04:00
Context . RHICmdList . CopyToResolveTarget ( DestRenderTarget . TargetableTexture , DestRenderTarget . ShaderResourceTexture , false , FResolveParams ( ) ) ;
2014-03-14 14:13:41 -04:00
}
FPooledRenderTargetDesc FRCPassPostProcessMotionBlurRecombine : : ComputeOutputDesc ( EPassOutputId InPassOutputId ) const
{
2015-07-06 18:04:49 -04:00
FPooledRenderTargetDesc Ret = GetInput ( ePId_Input0 ) - > GetOutput ( ) - > RenderTargetDesc ;
2014-03-14 14:13:41 -04:00
Ret . Reset ( ) ;
// we don't need the alpha channel and 32bit is faster and costs less memory
Ret . Format = PF_FloatRGB ;
Copying //UE4/Dev-Rendering to Dev-Main (//UE4/Dev-Main)
#lockdown ben.marsh
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2733540 on 2015/10/19 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream
Capsule shadows
* Capsule shadows excel at extremely soft area shadows caused by a large light source angle, but don't support accurate self-shadowing
* Artists can setup a physics asset containing Spheres and Sphyls (capsules) for a skeletal mesh that will be used to represent the mesh's occlusion
* These shapes can then be used for direct shadowing (bCastCapsuleDirectShadow) on a skeletal mesh component, whose softness depends on the light source angle / radius
* The shapes can also be used to create an indirect shadow (bCastCapsuleIndirectShadow), whose direction and softness is derived from the precomputed sky occlusion (stationary sky light) or primary indirect lighting (static sky light)
* Capsule shadowing is computed at half res and uses tiled deferred culling for efficiency - only implemented for PC SM5 + PS4 so far
* Shadowing of movable skylights is not yet supported
Change 2735460 on 2015/10/20 by Uriel.Doyon@uriel.doyon_office_data
Basepass drawlist are now merged within a single drawlist.
Lighting policy parameters are now accessed through a uniform buffer.
Changed the global resource initialization so that InitRHI now comes before InitDynamicRHI
#codereview nick.penwarden
Change 2744741 on 2015/10/28 by Nick.Penwarden@nickp_streams
Remove unused RHI methods:
RHIIsDrawingViewport
RHIGpuTimeBegin
RHIGpuTimeEnd
Made default/empty versions of these calls and removed stubs from RHIs that don't use them:
RHISuspendRendering
RHIResumeRendering
RHIIsRenderingSuspended
Change 2745714 on 2015/10/28 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream
Lighting channels - each component and light can choose from 3 channels
* Primitives output their channel mask to stencil during the base pass, the masks are copied to a texture after the base pass, deferred lighting passes compare the primitive mask against the light's mask
* Dynamic shadow casting also respects the channels
* Only works on opaque materials, direct lighting, dynamic lighting
* Not implemented for tiled deferred atm
* This will replace CastsShadowsFromCinematicObjectsOnly in the future
#rb Martin.Mittring
Change 2746243 on 2015/10/29 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New
First pass at separate Async Compute Context
#codereview Lee.Clark,Daniel.Wright
#rb Gil.Gribb
Change 2746989 on 2015/10/29 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering
Removed a lot of complexity of the skeletal mesh motionblur code (better for multithreading, simpler, faster) but going from one large buffer to per mesh buffers. Upload of bones only needed once.
* GPUSkinCache didn't even work before (in this branch)
* tested BasePass velocity
* tested split screen
* tested editor pause
* matinee camera cut (no need, invalidates velocity)
* tested CPU Skin? (never has motionblur)
* tested CreateSceneProxy (recreation is prevented in CreteSceneProxy unless bone count changes)
* test ES2 -featureleveles2
#rb: Rolando.Caloca
Change 2750734 on 2015/11/02 by Uriel.Doyon@uriel.doyon_office_data
Embree integration into Lightmass
Can be enabled through Lightmass.ini [DevOptions.StaticLighting]bUseEmbree.
Also [DevOptions.StaticLighting]bVerifyEmbree will compare ray casting results.
Only usable on Win64 with this submit.
#review daniel.wright
Change 2752730 on 2015/11/03 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering
added SSAO CS version, can be enabled with
r.AmbientOcclusion.Compute 1
Not optimized yet
#rb:Olaf.Piesche
Change 2752766 on 2015/11/03 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream
Lightmass solver quality improvements
* IndirectLightingScale is no longer applied to photons, avoids splotchy artifacts when using small scales
* New 'Lightmass Portal' actor / component which tells the solver where to look for significant lighting. When lighting with a Static Skylight only, in a mostly indoor environment, setting up these portals is the only way to get high quality.
* Skylight bounce lighting is now much more accurate and leverages adaptive sampling
* Fixed a bug that effectively disabled adaptive sampling on high IndirectLightingQualities
* Shadow penumbras are also improved by IndirectLightingQuality
* Texel debugging is now a cvar 'r.TexelDebugging', instead of requiring a full recompile
Change 2754018 on 2015/11/04 by Uriel.Doyon@uriel.doyon_office_data
Quad Complexity ViewMode (PCD3D_SM5 only).
Shader Complexity with Quad Overhead ViewMode (PCD3D_SM5 only). Require ShaderComplexity ViewMode & Show.Visualize.QuadOverhead
#review brian.karis
Change 2754760 on 2015/11/04 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering
improved SSAO quality (less high frequency noise) to avoid TemporalAA smearing
Change 2756308 on 2015/11/05 by Rolando.Caloca@rolando.caloca_T3903_S
DevRendering - Enable removing unused outputs on PS4 shader pipelines, disable by default removing unused on D3D (toggable with r.D3DRemoveUnusedInterpolators)
#codereview Marcus.Wassmer
Change 2757063 on 2015/11/06 by Simon.Tovey@Simon.Tovey_Dev
Submitting pull request from user Pierdek.
Early out of particle collision module update if there are no active particles.
#github
#1614
Change 2757340 on 2015/11/06 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering
UE4 - Fixed the experimental r.RHICmdBalanceParallelLists 2 mode and renabled it for orion.
Change 2757343 on 2015/11/06 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering
UE4 - Added a path so that texture streaming can avoid flushing the RHI thread.
Change 2757985 on 2015/11/06 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream
Added new PrimitiveComponent setting bSingleSampleShadowFromStationaryLights
* When enabled, shadowing of a movable component from a stationary directional light will come from the Volume Lighting Samples precomputed by Lightmass
* This provides essentially free on/off shadow receiving on dynamic objects, with a fade over time between states
* Lighting has to be rebuilt once for this to work
#rb Rolando.Caloca
Change 2759058 on 2015/11/09 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering
UE4 - Dynamically set stream source to avoid creating a separate drawing policy for each static mesh with vertex colors.
#rb Daniel.Wright
Change 2760523 on 2015/11/10 by Uriel.Doyon@uriel.doyon_office_data
Enabled Embree by default
#review daniel.wright
==========================
ALL CHANGELISTS
==========================
Change 2720123 on 2015/10/07 by Rolando.Caloca@Rolando.Caloca_T4688_5331 'Dev-Rendering - 'integrate' Tem'
Change 2721682 on 2015/10/08 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Eliminated a fatal error '
Change 2721815 on 2015/10/08 by Rolando.Caloca@Rolando.Caloca_T4688_5331 'Dev-Rendering - Fix crash exiti'
Change 2724755 on 2015/10/12 by Rolando.Caloca@Rolando.Caloca_T4688_5331 'Dev-Rendering - D3D12 Fix Tier'
Change 2724781 on 2015/10/12 by Rolando.Caloca@Rolando.Caloca_T4688_5331 'Dev-Rendering - D3D12 Fix offse'
Change 2728317 on 2015/10/14 by Rolando.Caloca@Rolando.Caloca_T4688_5331 'Dev-Rendering - hlslcc - Fix fo'
Change 2729170 on 2015/10/14 by Chris.Bunner@Chris.Bunner_Dev_Stream 'Force Lightmass volume sample g'
Change 2732131 on 2015/10/16 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'fixed resource transition issue'
Change 2732218 on 2015/10/16 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'minor code cleanup '
Change 2733533 on 2015/10/19 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Clear stencil to 0 after decals'
Change 2733540 on 2015/10/19 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Capsule shadows * Capsule shado'
Change 2733546 on 2015/10/19 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Light shaft targets are only al'
Change 2733602 on 2015/10/19 by Uriel.Doyon@uriel.doyon_office_data 'Decals not writing to Normal ca'
Change 2733627 on 2015/10/19 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix for transition ensure. '
Change 2735292 on 2015/10/20 by Brian.Karis@Brian.Karis_T3247_Rendering 'Fix for dark lightmap precision'
Change 2735298 on 2015/10/20 by Brian.Karis@Brian.Karis_T3247_Rendering 'Fix for speedtree LOD transitio'
Change 2735460 on 2015/10/20 by Uriel.Doyon@uriel.doyon_office_data 'Basepass drawlist are now merge'
Change 2737214 on 2015/10/21 by Chris.Bunner@Chris.Bunner_Dev_Stream 'Expanded a warning when importi'
Change 2738581 on 2015/10/22 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Updated comment on stencil usag'
Change 2738583 on 2015/10/22 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Changed bound but not set scene'
Change 2738584 on 2015/10/22 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Fixed skylight occlusion maps b'
Change 2738589 on 2015/10/22 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Lightmap streaming fixes * Chan'
Change 2738593 on 2015/10/22 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Fix from licensee for race cond'
Change 2738982 on 2015/10/22 by Olaf.Piesche@Olaf.Piesche_roaming 'Activating CanTickOnAnyThread f'
Change 2739032 on 2015/10/22 by Olaf.Piesche@Olaf.Piesche_roaming 'Fixing compiler barf with Clang'
Change 2741517 on 2015/10/26 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRindering - D3D12 - Integrat'
Change 2743790 on 2015/10/27 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Fixed texel debugging on static'
Change 2743958 on 2015/10/27 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'added comments '
Change 2744153 on 2015/10/27 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Unity compile fix '
Change 2744741 on 2015/10/28 by Nick.Penwarden@nickp_streams 'Remove unused RHI methods: RHI'
Change 2745714 on 2015/10/28 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Lighting channels - each compon'
Change 2746242 on 2015/10/29 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix crashes on init by swapping'
Change 2746243 on 2015/10/29 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'First pass at separate Async Co'
Change 2746296 on 2015/10/29 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Buffer label frees so we don't '
Change 2746297 on 2015/10/29 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'updated comment '
Change 2746343 on 2015/10/29 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'added comment '
Change 2746347 on 2015/10/29 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'added comment '
Change 2746811 on 2015/10/29 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Draw event for compute commandl'
Change 2746989 on 2015/10/29 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'Removed a lot of complexity of '
Change 2747127 on 2015/10/29 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'Improved game console printout '
Change 2747702 on 2015/10/30 by Chris.Bunner@Chris.Bunner_Dev_Stream 'Bumped Lightmass StaticMesh imp'
Change 2747954 on 2015/10/30 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix SubmitDone not called TRC e'
Change 2747979 on 2015/10/30 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'polish console autocomplete tex'
Change 2750719 on 2015/11/02 by Uriel.Doyon@uriel.doyon_office_data 'Add Embree 2.7.0 for Win64 and '
Change 2750734 on 2015/11/02 by Uriel.Doyon@uriel.doyon_office_data 'Embree integration into Lightma'
Change 2750872 on 2015/11/02 by Nick.Penwarden@nickp_streams 'Merging //UE4/Dev-Main to Dev-R'
Change 2751934 on 2015/11/03 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Disambiguate template function '
Change 2752190 on 2015/11/03 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Fixed assert relating to '
Change 2752333 on 2015/11/03 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - Shader pipeline '
Change 2752655 on 2015/11/03 by Rolando.Caloca@Rolando.Caloca_T3903_S 'DevRendering - Fix Materials pa'
Change 2752710 on 2015/11/03 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'added comment '
Change 2752711 on 2015/11/03 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'added better comment/help text '
Change 2752730 on 2015/11/03 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'added SSAO CS version, can be e'
Change 2752766 on 2015/11/03 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Lightmass solver quality improv'
Change 2752869 on 2015/11/03 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - Add shader pipel'
Change 2752882 on 2015/11/03 by Rolando.Caloca@Rolando.Caloca_T3903_S 'DevRendering - hlslcc - Metal -'
Change 2752899 on 2015/11/03 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'small SSAO GPU optimization mov'
Change 2752934 on 2015/11/03 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'minor GPU optimization for SSAO'
Change 2753109 on 2015/11/03 by Uriel.Doyon@uriel.doyon_office_data 'Fixed final build '
Change 2753669 on 2015/11/04 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'fixed SM4 compiling '
Change 2754002 on 2015/11/04 by Nick.Penwarden@nickp_streams 'test change '
Change 2754018 on 2015/11/04 by Uriel.Doyon@uriel.doyon_office_data 'Quad Complexity ViewMode (PCD3D'
Change 2754115 on 2015/11/04 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Fixed end of frame update'
Change 2754297 on 2015/11/04 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'PS4 compile fixes #codereview U'
Change 2754405 on 2015/11/04 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'minor SSAO ALU optimizations fi'
Change 2754512 on 2015/11/04 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'adjusted clamp for cvar '
Change 2754760 on 2015/11/04 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'improved SSAO quality (less hig'
Change 2755572 on 2015/11/05 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - PS4 warning fix '
Change 2755667 on 2015/11/05 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Fixed UE-22742, leak in t'
Change 2755722 on 2015/11/05 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - Remove unused co'
Change 2755814 on 2015/11/05 by Nick.Penwarden@nickp_streams 'Merging //UE4/Dev-Main to Dev-R'
Change 2755935 on 2015/11/05 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - Rebuild static m'
Change 2756003 on 2015/11/05 by Uriel.Doyon@uriel.doyon_office_data 'Reduce the number of precompute'
Change 2756145 on 2015/11/05 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Temp fix for GPU crash #rb none'
Change 2756308 on 2015/11/05 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - Enable removing '
Change 2756435 on 2015/11/05 by Olaf.Piesche@Olaf.Piesche_roaming 'Disabling a check, to fix OR-85'
Change 2757063 on 2015/11/06 by Simon.Tovey@Simon.Tovey_Dev 'Submitting pull request from us'
Change 2757340 on 2015/11/06 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Fixed the experimental r.'
Change 2757341 on 2015/11/06 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Changed the RHI thread di'
Change 2757342 on 2015/11/06 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Fixed lazy uniform buffer'
Change 2757343 on 2015/11/06 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Added a path so that text'
Change 2757500 on 2015/11/06 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Add FrameSync to externalprofil'
Change 2757650 on 2015/11/06 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'GBuffer should only be consider'
Change 2757665 on 2015/11/06 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'UE-22816 Instruction count is n'
Change 2757834 on 2015/11/06 by Michael.Trepka@Michael.Trepka_a4202_Dev-Rendering 'Embree integration into Lightma'
Change 2757930 on 2015/11/06 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix UT ensure #rb Peter.Knepley'
Change 2757931 on 2015/11/06 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix Ocean ensure #rb josh.ander'
Change 2757946 on 2015/11/06 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Removed invalid Lightmass asser'
Change 2757985 on 2015/11/06 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Added new PrimitiveComponent se'
Change 2758049 on 2015/11/06 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'OR-8600 CRASH: AllocationLeveli'
Change 2758059 on 2015/11/06 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'r.DumpTransitionsForResource #r'
Change 2758082 on 2015/11/06 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - Fix resource tra'
Change 2758879 on 2015/11/09 by Rolando.Caloca@rolando.caloca_T3903_S 'DevRendering - Fix PSSL names f'
Change 2758911 on 2015/11/09 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Fixed accidental force di'
Change 2758968 on 2015/11/09 by Uriel.Doyon@uriel.doyon_office_data 'Disabled single frame buffer us'
Change 2758991 on 2015/11/09 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix togglerhithread crash #rb G'
Change 2759058 on 2015/11/09 by Gil.Gribb@Gil.Gribb_Z2439_Dev-Rendering 'UE4 - Dynamically set stream so'
Change 2759063 on 2015/11/09 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'fixed UE-22368 CLONE - GitHub 1'
Change 2759073 on 2015/11/09 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'minor code quality improvements'
Change 2759501 on 2015/11/09 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix particle ensure. '
Change 2759522 on 2015/11/09 by Marcus.Wassmer@Marcus.Wassmer_DevRendering_New 'Fix decals using CustomStencil.'
Change 2759610 on 2015/11/09 by Daniel.Wright@Daniel.Wright_G5038_RenderingStream 'Fixed line light source shadows'
Change 2759634 on 2015/11/09 by Uriel.Doyon@uriel.doyon_office_data 'Refined GBufferA resolving when'
Change 2759657 on 2015/11/09 by Martin.Mittring@Martin.Mittring_Z3941_Dev_Rendering 'Fixed ResourceTransition with r'
Change 2759693 on 2015/11/09 by Rolando.Caloca@Rolando.Caloca_T4688_S 'DevRendering - Fixed global sha'
Change 2759771 on 2015/11/09 by Uriel.Doyon@uriel.doyon_office_data 'Fixed editor hit proxy renderin'
Change 2760188 on 2015/11/09 by Uriel.Doyon@uriel.doyon_office_data 'Disabled some more deferred dec'
Change 2760523 on 2015/11/10 by Uriel.Doyon@uriel.doyon_office_data 'Enabled Embree by default #revi'
[CL 2761339 by Nick Penwarden in Main branch]
2015-11-10 17:11:09 -05:00
Ret . AutoWritable = false ;
2014-03-14 14:13:41 -04:00
Ret . DebugName = TEXT ( " MotionBlurRecombine " ) ;
return Ret ;
}
2015-06-22 19:08:33 -04:00
FIntPoint GetNumTiles16x16 ( FIntPoint PixelExtent )
{
uint32 TilesX = ( PixelExtent . X + 15 ) / 16 ;
uint32 TilesY = ( PixelExtent . Y + 15 ) / 16 ;
return FIntPoint ( TilesX , TilesY ) ;
}
2015-02-22 17:53:26 -05:00
2015-11-18 09:31:10 -05:00
FVector4 GetMotionBlurParameters ( const FViewInfo & View , float Scale = 1.0f )
{
const float TileSize = 16.0f ;
const float SizeX = View . ViewRect . Width ( ) ;
const float SizeY = View . ViewRect . Height ( ) ;
const float AspectRatio = SizeY / SizeX ;
const FSceneViewState * ViewState = ( FSceneViewState * ) View . State ;
float MotionBlurTimeScale = ViewState ? ViewState - > MotionBlurTimeScale : 1.0f ;
float MotionBlurScale = 0.5f * MotionBlurTimeScale * View . FinalPostProcessSettings . MotionBlurAmount ;
// 0:no 1:full screen width, percent conversion
float MaxVelocity = View . FinalPostProcessSettings . MotionBlurMax / 100.0f ;
// Scale by 0.5 due to blur samples going both ways
float PixelScale = Scale * SizeX * 0.5f ;
FVector4 MotionBlurParameters (
AspectRatio ,
PixelScale * MotionBlurScale , // Scale for pixels
PixelScale * MotionBlurScale / TileSize , // Scale for tiles
FMath : : Abs ( PixelScale ) * MaxVelocity // Max velocity pixels
) ;
return MotionBlurParameters ;
}
2015-02-22 17:53:26 -05:00
class FPostProcessVelocityFlattenCS : public FGlobalShader
{
DECLARE_SHADER_TYPE ( FPostProcessVelocityFlattenCS , Global ) ;
static bool ShouldCache ( EShaderPlatform Platform )
{
return IsFeatureLevelSupported ( Platform , ERHIFeatureLevel : : SM5 ) ;
}
static void ModifyCompilationEnvironment ( EShaderPlatform Platform , FShaderCompilerEnvironment & OutEnvironment )
{
FGlobalShader : : ModifyCompilationEnvironment ( Platform , OutEnvironment ) ;
}
FPostProcessVelocityFlattenCS ( ) { }
public :
2015-04-29 19:44:56 -04:00
FShaderParameter OutVelocityFlat ; // UAV
FShaderParameter OutMaxTileVelocity ; // UAV
2015-02-22 17:53:26 -05:00
FPostProcessVelocityFlattenCS ( const ShaderMetaType : : CompiledShaderInitializerType & Initializer )
: FGlobalShader ( Initializer )
{
PostprocessParameter . Bind ( Initializer . ParameterMap ) ;
2015-11-18 09:31:10 -05:00
MotionBlurParameters . Bind ( Initializer . ParameterMap , TEXT ( " MotionBlurParameters " ) ) ;
2015-02-22 17:53:26 -05:00
OutVelocityFlat . Bind ( Initializer . ParameterMap , TEXT ( " OutVelocityFlat " ) ) ;
OutMaxTileVelocity . Bind ( Initializer . ParameterMap , TEXT ( " OutMaxTileVelocity " ) ) ;
}
void SetCS ( FRHICommandList & RHICmdList , const FRenderingCompositePassContext & Context , const FSceneView & View )
{
const FComputeShaderRHIParamRef ShaderRHI = GetComputeShader ( ) ;
FGlobalShader : : SetParameters ( RHICmdList , ShaderRHI , Context . View ) ;
Copying //UE4/Dev-Rendering to Dev-Main (//UE4/Dev-Main)
#lockdown ben.marsh
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2774277 on 2015/11/19 by Gil.Gribb
UE4 - Did minor optimizations to the PS4 RHI and drawlists.
Change 2791226 on 2015/12/04 by Uriel.Doyon
Added source code for Embree 2.7.0
Removed duplicate files from the /doc folder.
Change 2800193 on 2015/12/11 by Marcus.Wassmer
SSAO AsyncCompute support.
#rb Martin.Mittring
Change 2801631 on 2015/12/14 by Olaf.Piesche
Making auto deactivate true by default, moving checks to HasCompleted, eliminating some unnecessary logic
#rb martin.mittring
Change 2803240 on 2015/12/15 by Gil.Gribb
UE4 - Added command to collect stats on spammy stats.
Change 2803476 on 2015/12/15 by Rolando.Caloca
DR - Allow toggling compute skin dispatch at runtime
- r.SkinCacheShaders Now enable the shaders and feature
- r.SkinCaching enables toggling at runtime
- r.SkinCache.BufferSize Sets the size in bytes of buffer for outputting
- Now uses 3 UAV buffers instead of one (avoid RenderDoc crashes)
#codereview Marcus.Wassmer, Martin.Mittring
Change 2803940 on 2015/12/15 by Marcus.Wassmer
Add r.PS4.AsyncComputeBudgetMode to switch between CUMasking and WaveLimit modes. So far it looks like WaveLimits behave better in UE4.
Also rearrange AsyncSSAO to run immediately after HZB to overlap with occlusion queries. In my testing this takes SSAO cost from .5ms -> .2ms. However it had to be hacked to run without normals. Hopefully Martin can get some real AsyncSSAO in.
#rb Martin.Mittring
#codereview Martin.Mittring
Change 2803999 on 2015/12/15 by Uriel.Doyon
Refactored the shader complexity material override logic to allow other viewmodes shader overrides.
TexelFactorAccuracy ViewMode : shows the accuracy of the static mesh texel factors, used for streaming.
WantedMipsAccuracy ViewMode : shows the accuracy of the static mesh wanted mips accuracy, used for streaming.
Added an option to stream textures based on the AABB distance instead of using the sphere approximation.
Added an option to only keep a the wanted mips.
Moved optimization related viewmodes into a submenu to avoid polluting the interface.
#jira UE-24502
#jira UE-24503
#jira UERNDR-89
Change 2804150 on 2015/12/15 by Olaf.Piesche
make separate translucency screen percentage a bit more robust; add numsamples to the render target creation functions in preparation for MSAA support for higher quality with low res separate translucency
#rb martin.mittring
Change 2804367 on 2015/12/15 by Daniel.Wright
Capsule shadow primitives are tracked separately on registration - saves 2.6ms of RT time doing the view frustum culling in a medium sized map
Change 2805293 on 2015/12/16 by Olaf.Piesche
logging if potentially immortal emitters are spawned from gameplay; this should catch if we spawn burst only emitters with indefinite life spans (muzzle flashes, hit impacts, etc.)
#rb martin.mittring
Change 2805586 on 2015/12/16 by Zabir.Hoque
Adding support for decals to fade and destroy themselves automatically.
#CodeReview: Martin.Mittring, Daniel.Wright, Olaf.Piesche
Change 2807663 on 2015/12/17 by Rolando.Caloca
DR - Remove expensive logging
#codereview Marcus.Wassmer
Change 2807903 on 2015/12/17 by Zabir.Hoque
Refactored DecalComponent's lifetime management such that it can be set and reset from Blueprints.
#CodeReview Daniel.Wright, Martin.Mittring, Olaf.Piesche
Change 2809261 on 2015/12/18 by Martin.Mittring
Added VisualizeShadingModels to track down issues like that:
FORT-16913 Textures on Hero Mesh is not shown
#rb:David.Hill
#code_review:Bob.Tellez
Change 2810136 on 2015/12/21 by Rolando.Caloca
DR - Added back draw event colors
PR #1602
#jira UE-21526
#codereview Mark.Satterthwaite, Keith.Judge, Marcus.Wassmer, Josh.Adams
Change 2810680 on 2015/12/21 by Martin.Mittring
moved SSAO ComputeShader running without per pixel normal (for AsyncCompute) into DevRendering
#test:editor
Change 2811205 on 2015/12/22 by Brian.Karis
Pulled clear coat out of the reflection compute shader. Added permutation for skylight.
Clear coat base layer now done in base pass. It only picks up the closest capture. This will cause popping when the object moves. Still needs a cross fade.
Change 2811275 on 2015/12/22 by David.Hill
UE-24675
#rb martin.mittring
Corrected buffer-size related problem with fringe.
Change 2811397 on 2015/12/22 by Brian.Karis
2016-01-08 11:12:28 -05:00
PostprocessParameter . SetCS ( ShaderRHI , Context , Context . RHICmdList , TStaticSamplerState < SF_Point , AM_Clamp , AM_Clamp , AM_Clamp > : : GetRHI ( ) ) ;
2015-02-22 17:53:26 -05:00
2015-04-29 19:44:56 -04:00
SetUniformBufferParameter ( RHICmdList , ShaderRHI , GetUniformBufferParameter < FCameraMotionParameters > ( ) , CreateCameraMotionParametersUniformBuffer ( Context . View ) ) ;
2015-11-18 09:31:10 -05:00
SetShaderValue ( Context . RHICmdList , ShaderRHI , MotionBlurParameters , GetMotionBlurParameters ( Context . View ) ) ;
2015-02-22 17:53:26 -05:00
}
2015-04-01 07:20:55 -04:00
virtual bool Serialize ( FArchive & Ar ) override
2015-02-22 17:53:26 -05:00
{
bool bShaderHasOutdatedParameters = FGlobalShader : : Serialize ( Ar ) ;
Ar < < PostprocessParameter ;
2015-11-18 09:31:10 -05:00
Ar < < MotionBlurParameters ;
2015-02-22 17:53:26 -05:00
Ar < < OutVelocityFlat ;
Ar < < OutMaxTileVelocity ;
return bShaderHasOutdatedParameters ;
}
private :
FPostProcessPassParameters PostprocessParameter ;
2015-11-18 09:31:10 -05:00
FShaderParameter MotionBlurParameters ;
2015-02-22 17:53:26 -05:00
} ;
IMPLEMENT_SHADER_TYPE ( , FPostProcessVelocityFlattenCS , TEXT ( " PostProcessVelocityFlatten " ) , TEXT ( " VelocityFlattenMain " ) , SF_Compute ) ;
2015-06-22 19:08:33 -04:00
FRCPassPostProcessVelocityFlatten : : FRCPassPostProcessVelocityFlatten ( )
: AsyncJobFenceID ( - 1 )
{ }
2015-02-22 17:53:26 -05:00
void FRCPassPostProcessVelocityFlatten : : Process ( FRenderingCompositePassContext & Context )
{
2015-06-22 19:08:33 -04:00
SCOPED_DRAW_EVENT ( Context . RHICmdList , VelocityFlatten ) ;
2015-02-22 17:53:26 -05:00
const FPooledRenderTargetDesc * InputDesc = GetInputDesc ( ePId_Input0 ) ;
2015-05-11 15:13:36 -04:00
if ( AsyncJobFenceID ! = - 1 )
{
// If we run with AsyncCompute we use the same node twice, once to start the AsyncCompute and once to wait for the result.
// The later one is happening here.
Context . RHICmdList . GraphicsWaitOnAsyncComputeJob ( AsyncJobFenceID ) ;
AsyncJobFenceID = - 1 ;
return ;
}
2015-02-22 17:53:26 -05:00
if ( ! InputDesc )
{
// input is not hooked up correctly
return ;
}
const FSceneView & View = Context . View ;
const FSceneViewFamily & ViewFamily = * ( View . Family ) ;
const FSceneRenderTargetItem & DestRenderTarget0 = PassOutputs [ 0 ] . RequestSurface ( Context ) ;
const FSceneRenderTargetItem & DestRenderTarget1 = PassOutputs [ 1 ] . RequestSurface ( Context ) ;
TShaderMapRef < FPostProcessVelocityFlattenCS > ComputeShader ( Context . GetShaderMap ( ) ) ;
2015-05-11 15:13:36 -04:00
const bool bAsyncComputeEnabled = IsAsyncComputeEnabled ( ) ;
2015-02-22 17:53:26 -05:00
SetRenderTarget ( Context . RHICmdList , FTextureRHIRef ( ) , FTextureRHIRef ( ) ) ;
2015-05-11 15:13:36 -04:00
if ( bAsyncComputeEnabled )
{
// If AsyncCompute is enabled we start recording the commands for that
Context . RHICmdList . BeginAsyncComputeJob_DrawThread ( AsyncComputePriority_Default ) ;
}
2015-02-22 17:53:26 -05:00
2015-06-22 19:08:33 -04:00
Context . SetViewportAndCallRHI ( View . ViewRect ) ;
2015-05-11 15:13:36 -04:00
Context . RHICmdList . SetComputeShader ( ComputeShader - > GetComputeShader ( ) ) ;
// set destination
Context . RHICmdList . SetUAVParameter ( ComputeShader - > GetComputeShader ( ) , ComputeShader - > OutVelocityFlat . GetBaseIndex ( ) , DestRenderTarget0 . UAV ) ;
Context . RHICmdList . SetUAVParameter ( ComputeShader - > GetComputeShader ( ) , ComputeShader - > OutMaxTileVelocity . GetBaseIndex ( ) , DestRenderTarget1 . UAV ) ;
ComputeShader - > SetCS ( Context . RHICmdList , Context , View ) ;
2015-06-22 19:08:33 -04:00
FIntPoint ThreadGroupCountValue = GetNumTiles16x16 ( View . ViewRect . Size ( ) ) ;
2015-02-22 17:53:26 -05:00
DispatchComputeShader ( Context . RHICmdList , * ComputeShader , ThreadGroupCountValue . X , ThreadGroupCountValue . Y , 1 ) ;
2015-05-11 15:13:36 -04:00
# if USE_ASYNC_COMPUTE_CONTEXT
if ( AsyncJobFenceID ! = - 1 )
{
Context . RHICmdList . GraphicsWaitOnAsyncComputeJob ( AsyncJobFenceID ) ;
AsyncJobFenceID = - 1 ;
}
# endif
// void FD3D11DynamicRHI::RHIGraphicsWaitOnAsyncComputeJob( uint32 FenceIndex )
Context . RHICmdList . FlushComputeShaderCache ( ) ;
2015-02-22 17:53:26 -05:00
// un-set destination
2015-05-11 15:13:36 -04:00
Context . RHICmdList . SetUAVParameter ( ComputeShader - > GetComputeShader ( ) , ComputeShader - > OutVelocityFlat . GetBaseIndex ( ) , NULL ) ;
Context . RHICmdList . SetUAVParameter ( ComputeShader - > GetComputeShader ( ) , ComputeShader - > OutMaxTileVelocity . GetBaseIndex ( ) , NULL ) ;
2015-02-22 17:53:26 -05:00
Context . RHICmdList . CopyToResolveTarget ( DestRenderTarget0 . TargetableTexture , DestRenderTarget0 . ShaderResourceTexture , false , FResolveParams ( ) ) ;
Context . RHICmdList . CopyToResolveTarget ( DestRenderTarget1 . TargetableTexture , DestRenderTarget1 . ShaderResourceTexture , false , FResolveParams ( ) ) ;
2015-05-11 15:13:36 -04:00
// we want this pass to be executed another time
// so we do this: CompositeContext.Process(VelocityFlattenPass, TEXT("VelocityFlattenPass"));
// and this: bProcessWasCalled = false;
if ( bAsyncComputeEnabled )
{
// we end recording the commands for AsyncCompute and get back a number to wait for it with GraphicsWaitOnAsyncComputeJob()
AsyncJobFenceID = Context . RHICmdList . EndAsyncComputeJob_DrawThread ( ) ;
// mark it not processed so it gets executed a second time
bProcessWasCalled = false ;
// we run this Process() two times and want to not get the dependencies processed twice (could be moved into the ComposingGraph iteration, slower but easier coding)
SetInput ( ePId_Input0 , FRenderingCompositeOutputRef ( ) ) ;
SetInput ( ePId_Input1 , FRenderingCompositeOutputRef ( ) ) ;
}
2015-02-22 17:53:26 -05:00
}
FPooledRenderTargetDesc FRCPassPostProcessVelocityFlatten : : ComputeOutputDesc ( EPassOutputId InPassOutputId ) const
{
if ( InPassOutputId = = ePId_Output0 )
{
// Flattened velocity
2015-07-06 18:04:49 -04:00
FPooledRenderTargetDesc Ret = GetInput ( ePId_Input0 ) - > GetOutput ( ) - > RenderTargetDesc ;
2015-02-22 17:53:26 -05:00
Ret . Reset ( ) ;
2015-07-09 15:11:37 -04:00
Ret . ClearValue = FClearValueBinding : : None ;
2015-06-22 19:08:33 -04:00
Ret . Format = PF_FloatR11G11B10 ;
2015-02-22 17:53:26 -05:00
Ret . TargetableFlags | = TexCreate_UAV ;
Ret . TargetableFlags | = TexCreate_RenderTargetable ;
Ret . DebugName = TEXT ( " VelocityFlat " ) ;
return Ret ;
}
else
{
// Max tile velocity
2015-07-06 18:04:49 -04:00
FPooledRenderTargetDesc UnmodifiedRet = GetInput ( ePId_Input0 ) - > GetOutput ( ) - > RenderTargetDesc ;
2015-02-22 17:53:26 -05:00
UnmodifiedRet . Reset ( ) ;
FIntPoint PixelExtent = UnmodifiedRet . Extent ;
2015-06-22 19:08:33 -04:00
FIntPoint TileCount = GetNumTiles16x16 ( PixelExtent ) ;
2015-02-22 17:53:26 -05:00
2015-07-09 15:11:37 -04:00
FPooledRenderTargetDesc Ret ( FPooledRenderTargetDesc : : Create2DDesc ( TileCount , PF_FloatRGBA , FClearValueBinding : : None , TexCreate_None , TexCreate_RenderTargetable | TexCreate_UAV , false ) ) ;
2015-02-22 17:53:26 -05:00
Ret . DebugName = TEXT ( " MaxVelocity " ) ;
return Ret ;
}
}
2015-02-24 16:28:47 -05:00
class FScatterQuadIndexBuffer : public FIndexBuffer
{
public :
virtual void InitRHI ( ) override
{
const uint32 Size = sizeof ( uint16 ) * 6 * 8 ;
const uint32 Stride = sizeof ( uint16 ) ;
FRHIResourceCreateInfo CreateInfo ;
2015-06-30 14:18:55 -04:00
void * Buffer = nullptr ;
IndexBufferRHI = RHICreateAndLockIndexBuffer ( Stride , Size , BUF_Static , CreateInfo , Buffer ) ;
uint16 * Indices = ( uint16 * ) Buffer ;
2015-02-24 16:28:47 -05:00
for ( uint32 SpriteIndex = 0 ; SpriteIndex < 8 ; + + SpriteIndex )
{
Indices [ SpriteIndex * 6 + 0 ] = SpriteIndex * 4 + 0 ;
Indices [ SpriteIndex * 6 + 1 ] = SpriteIndex * 4 + 3 ;
Indices [ SpriteIndex * 6 + 2 ] = SpriteIndex * 4 + 2 ;
Indices [ SpriteIndex * 6 + 3 ] = SpriteIndex * 4 + 0 ;
Indices [ SpriteIndex * 6 + 4 ] = SpriteIndex * 4 + 1 ;
Indices [ SpriteIndex * 6 + 5 ] = SpriteIndex * 4 + 3 ;
}
RHIUnlockIndexBuffer ( IndexBufferRHI ) ;
}
} ;
TGlobalResource < FScatterQuadIndexBuffer > GScatterQuadIndexBuffer ;
class FPostProcessVelocityScatterVS : public FGlobalShader
{
DECLARE_SHADER_TYPE ( FPostProcessVelocityScatterVS , Global ) ;
static bool ShouldCache ( EShaderPlatform Platform )
{
return IsFeatureLevelSupported ( Platform , ERHIFeatureLevel : : SM4 ) ;
}
/** Default constructor. */
FPostProcessVelocityScatterVS ( ) { }
public :
FPostProcessPassParameters PostprocessParameter ;
2015-06-22 19:08:33 -04:00
FShaderParameter DrawMax ;
2015-11-18 09:31:10 -05:00
FShaderParameter MotionBlurParameters ;
2015-02-24 16:28:47 -05:00
/** Initialization constructor. */
FPostProcessVelocityScatterVS ( const ShaderMetaType : : CompiledShaderInitializerType & Initializer )
: FGlobalShader ( Initializer )
{
PostprocessParameter . Bind ( Initializer . ParameterMap ) ;
2015-06-22 19:08:33 -04:00
DrawMax . Bind ( Initializer . ParameterMap , TEXT ( " bDrawMax " ) ) ;
2015-11-18 09:31:10 -05:00
MotionBlurParameters . Bind ( Initializer . ParameterMap , TEXT ( " MotionBlurParameters " ) ) ;
2015-02-24 16:28:47 -05:00
}
// FShader interface.
2015-04-01 07:20:55 -04:00
virtual bool Serialize ( FArchive & Ar ) override
2015-02-24 16:28:47 -05:00
{
bool bShaderHasOutdatedParameters = FGlobalShader : : Serialize ( Ar ) ;
2015-11-18 09:31:10 -05:00
Ar < < PostprocessParameter < < DrawMax < < MotionBlurParameters ;
2015-02-24 16:28:47 -05:00
return bShaderHasOutdatedParameters ;
}
/** to have a similar interface as all other shaders */
2015-06-22 19:08:33 -04:00
void SetParameters ( const FRenderingCompositePassContext & Context , int32 bDrawMax )
2015-02-24 16:28:47 -05:00
{
const FVertexShaderRHIParamRef ShaderRHI = GetVertexShader ( ) ;
FGlobalShader : : SetParameters ( Context . RHICmdList , ShaderRHI , Context . View ) ;
PostprocessParameter . SetVS ( ShaderRHI , Context , TStaticSamplerState < SF_Point , AM_Clamp , AM_Clamp , AM_Clamp > : : GetRHI ( ) ) ;
2015-06-22 19:08:33 -04:00
SetShaderValue ( Context . RHICmdList , ShaderRHI , DrawMax , bDrawMax ) ;
2015-11-18 09:31:10 -05:00
SetShaderValue ( Context . RHICmdList , ShaderRHI , MotionBlurParameters , GetMotionBlurParameters ( Context . View ) ) ;
2015-02-24 16:28:47 -05:00
}
static const TCHAR * GetSourceFilename ( )
{
return TEXT ( " PostProcessMotionBlur " ) ;
}
static const TCHAR * GetFunctionName ( )
{
return TEXT ( " VelocityScatterVS " ) ;
}
} ;
class FPostProcessVelocityScatterPS : public FGlobalShader
{
DECLARE_SHADER_TYPE ( FPostProcessVelocityScatterPS , Global ) ;
static bool ShouldCache ( EShaderPlatform Platform )
{
return IsFeatureLevelSupported ( Platform , ERHIFeatureLevel : : SM4 ) ;
}
/** Default constructor. */
FPostProcessVelocityScatterPS ( ) { }
public :
/** Initialization constructor. */
FPostProcessVelocityScatterPS ( const ShaderMetaType : : CompiledShaderInitializerType & Initializer )
: FGlobalShader ( Initializer )
{ }
void SetParameters ( const FRenderingCompositePassContext & Context )
{
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader ( ) ;
FGlobalShader : : SetParameters ( Context . RHICmdList , ShaderRHI , Context . View ) ;
}
} ;
IMPLEMENT_SHADER_TYPE ( , FPostProcessVelocityScatterVS , TEXT ( " PostProcessMotionBlur " ) , TEXT ( " VelocityScatterVS " ) , SF_Vertex ) ;
IMPLEMENT_SHADER_TYPE ( , FPostProcessVelocityScatterPS , TEXT ( " PostProcessMotionBlur " ) , TEXT ( " VelocityScatterPS " ) , SF_Pixel ) ;
void FRCPassPostProcessVelocityScatter : : Process ( FRenderingCompositePassContext & Context )
{
2015-06-22 19:08:33 -04:00
SCOPED_DRAW_EVENT ( Context . RHICmdList , VelocityScatter ) ;
2015-02-24 16:28:47 -05:00
const FPooledRenderTargetDesc * InputDesc = GetInputDesc ( ePId_Input0 ) ;
if ( ! InputDesc )
{
// input is not hooked up correctly
return ;
}
const FSceneView & View = Context . View ;
FIntPoint SrcSize = InputDesc - > Extent ;
FIntPoint DestSize = PassOutputs [ 0 ] . RenderTargetDesc . Extent ;
2015-06-22 19:08:33 -04:00
FIntPoint TileCount = GetNumTiles16x16 ( View . ViewRect . Size ( ) ) ;
2015-02-24 16:28:47 -05:00
const FSceneRenderTargetItem & DestRenderTarget = PassOutputs [ 0 ] . RequestSurface ( Context ) ;
TRefCountPtr < IPooledRenderTarget > DepthTarget ;
2015-07-09 15:11:37 -04:00
FPooledRenderTargetDesc Desc ( FPooledRenderTargetDesc : : Create2DDesc ( DestSize , PF_ShadowDepth , FClearValueBinding : : DepthOne , TexCreate_None , TexCreate_DepthStencilTargetable , false ) ) ;
2015-09-21 20:07:00 -04:00
GRenderTargetPool . FindFreeElement ( Context . RHICmdList , Desc , DepthTarget , TEXT ( " VelocityScatterDepth " ) ) ;
2015-02-24 16:28:47 -05:00
// Set the view family's render target/viewport.
2015-07-09 15:11:37 -04:00
FRHIRenderTargetView ColorView ( DestRenderTarget . TargetableTexture , 0 , - 1 , ERenderTargetLoadAction : : ELoad , ERenderTargetStoreAction : : EStore ) ;
FRHIDepthRenderTargetView DepthView ( DepthTarget - > GetRenderTargetItem ( ) . TargetableTexture , ERenderTargetLoadAction : : EClear , ERenderTargetStoreAction : : EStore , ERenderTargetLoadAction : : ELoad , ERenderTargetStoreAction : : EStore ) ;
FRHISetRenderTargetsInfo RTInfo ( 1 , & ColorView , DepthView ) ;
// clear depth
// Max >= Min so no need to clear on second pass
Copying //UE4/Orion-Staging to //UE4/Main (originated from //Orion/Dev-General @ 2831630)
#lockdown Nick.Penwarden
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2831624 on 2016/01/17 by Marcus.Wassmer
Merge disable of FCachedReadPlatformData on PS4. Reduces memory spikes. 2830986
#rb none
#test none
#codereview Michael.Noland,James.Golding
Change 2831402 on 2016/01/17 by Marcus.Wassmer
HLOD priority and streamout changes.
Give texture pool an extra 200MB which we can afford thanks to James/Michael
#rb Chris.Gagnon
#test run agora, notice nice textures.
#lockdown Andrew.Grant
Change 2831398 on 2016/01/17 by Marcus.Wassmer
Fix 3 logic bugs with Relocate
#rb chris.gagnon
#test run game, look for corruption.
#lockdown Andrew.Grant
Change 2831372 on 2016/01/16 by Marcus.Wassmer
Update param.sfo's and lockdown version in prep for good PS4 playtest build.
#rb none
#test build from last night...
#lockdown Andrew.Grant
Change 2831274 on 2016/01/16 by Graeme.Thornton
Disable platform file cache wrapper on PS4
#codereview James.Golding
#rb none
#tests ran cooked ps4 build, timed loading (no real change), measured memory used for file handles (small)
Change 2831237 on 2016/01/16 by Sammy.James
Fix PS4 compile error
#codereview Andrew.Grant
#rb none
#tests none
Change 2831219 on 2016/01/16 by Matt.Kuhlenschmidt
Fix possible invalid access to shared movie player resource across threads causing startup crash.
#codereview marcus.wassmer
#rb none, #tests initial load
Change 2831218 on 2016/01/16 by Marcus.Wassmer
Fix bad warning case.
#codereview Martin.Mittring
#rb none
#test none
Change 2831201 on 2016/01/16 by Andrew.Grant
Added extra info about referencer to missing asset reference message
#rb none
#tests cooked, ran editor
Change 2831183 on 2016/01/16 by David.Nikdel
#OSS #PS4 #Purchasing #StoreV2
- Force failure if we have no receipts after a "successful" checkout.
- Report consumed entitlements as well as unconsumed but leave ValidationInfo empty so we can tell the difference at the application level
- Convert productIds to skuIds at checkout time
- Added PS4 Implementation of IOnlineStoreV2
- Bugfix: set bSuccessfullyStartedUp=false when InitNPGameSettings() fails
- Adjusted FOnlineStoreOffer to use FText::AsCurrencyBase
#RB: Paul.Moore
#TESTS: login, purchase redemption, store MTX purchasing on PS4 & PC
Change 2831129 on 2016/01/16 by David.Nikdel
#MCP
- Added a ctor to make converting from FOnlineError to FMcpQueryResult easier (for stuff that was already using FMcpQueryResult).
#RB: none
#TESTS: frontend
Change 2830986 on 2016/01/15 by Michael.Noland
PS4: Disabling FCachedReadPlatformFile on PS4 to significantly reduce high watermark memory consumption during blocking loads
#rb marcus.wassmer
#tests Ran Paragon PS4 down a bad path that currently does a blocking map and hero load
#lockdown andrew.grant
Change 2830943 on 2016/01/15 by Max.Chen
Sequencer: Fix bug introduced with preroll. It was also causing a crash in particle track instance.
#tests Master sequence trailer plays without crashing
#rb none
Change 2830912 on 2016/01/15 by Michael.Noland
Rendering: Exposed GRHIDeviceId (only filled in on D3D11 and D3D12 RHI's under the same circumstances as GRHIAdapterName, etc..., 0 otherwise)
#rb mieszko.zielinski
#tests Tested printing the value out
#codereview martin.mittring
Change 2830910 on 2016/01/15 by Michael.Noland
Rendering: Improved GPU driver detection logic to handle more cases
#codereview martin.mittring
#rb mieszko.zielinski
#tests Tested on my machine which was previous reporting Unknown for the values as some entries contained the key in the Settings subfolder
Change 2830776 on 2016/01/15 by Martin.Mittring
from Dev-Rendering
added ensure to track down multiple issues like
OR-11771 CRASH: User Crashed when pressing the Play button
OR-12430 CRASH: OT2 user crashed with FRHIResource::AddRef()
#rb:Gil.Gribb
#code_review:Gil.Gribb,Mark.Satterthwaite,Marcus.Wassmer
2016-01-20 11:32:08 -05:00
Context . RHICmdList . SetRenderTargetsAndClear ( RTInfo ) ;
2015-07-09 15:11:37 -04:00
Context . SetViewportAndCallRHI ( 0 , 0 , 0.0f , TileCount . X , TileCount . Y , 1.0f ) ;
2015-06-22 19:08:33 -04:00
// Min,Max
for ( int i = 0 ; i < 2 ; i + + )
{
if ( i = = 0 )
{
// min
Context . RHICmdList . SetBlendState ( TStaticBlendStateWriteMask < CW_RGBA > : : GetRHI ( ) ) ;
Context . RHICmdList . SetRasterizerState ( TStaticRasterizerState < > : : GetRHI ( ) ) ;
Context . RHICmdList . SetDepthStencilState ( TStaticDepthStencilState < true , CF_Less > : : GetRHI ( ) ) ;
}
else
{
// max
Context . RHICmdList . SetBlendState ( TStaticBlendStateWriteMask < CW_BA > : : GetRHI ( ) ) ;
Context . RHICmdList . SetRasterizerState ( TStaticRasterizerState < > : : GetRHI ( ) ) ;
Context . RHICmdList . SetDepthStencilState ( TStaticDepthStencilState < true , CF_Greater > : : GetRHI ( ) ) ;
}
2015-02-24 16:28:47 -05:00
2015-06-22 19:08:33 -04:00
TShaderMapRef < FPostProcessVelocityScatterVS > VertexShader ( Context . GetShaderMap ( ) ) ;
TShaderMapRef < FPostProcessVelocityScatterPS > PixelShader ( Context . GetShaderMap ( ) ) ;
2015-02-24 16:28:47 -05:00
2015-06-22 19:08:33 -04:00
static FGlobalBoundShaderState BoundShaderState ;
SetGlobalBoundShaderState ( Context . RHICmdList , Context . GetFeatureLevel ( ) , BoundShaderState , GFilterVertexDeclaration . VertexDeclarationRHI , * VertexShader , * PixelShader ) ;
2015-02-24 16:28:47 -05:00
2015-06-22 19:08:33 -04:00
VertexShader - > SetParameters ( Context , i ) ;
PixelShader - > SetParameters ( Context ) ;
2015-02-24 16:28:47 -05:00
2015-06-22 19:08:33 -04:00
// needs to be the same on shader side (faster on NVIDIA and AMD)
int32 QuadsPerInstance = 8 ;
2015-02-24 16:28:47 -05:00
2015-06-22 19:08:33 -04:00
Context . RHICmdList . SetStreamSource ( 0 , NULL , 0 , 0 ) ;
Context . RHICmdList . DrawIndexedPrimitive ( GScatterQuadIndexBuffer . IndexBufferRHI , PT_TriangleList , 0 , 0 , 32 , 0 , 2 * QuadsPerInstance , FMath : : DivideAndRoundUp ( TileCount . X * TileCount . Y , QuadsPerInstance ) ) ;
}
2015-02-24 16:28:47 -05:00
Context . RHICmdList . CopyToResolveTarget ( DestRenderTarget . TargetableTexture , DestRenderTarget . ShaderResourceTexture , false , FResolveParams ( ) ) ;
}
FPooledRenderTargetDesc FRCPassPostProcessVelocityScatter : : ComputeOutputDesc ( EPassOutputId InPassOutputId ) const
{
2015-07-06 18:04:49 -04:00
FPooledRenderTargetDesc Ret = GetInput ( ePId_Input0 ) - > GetOutput ( ) - > RenderTargetDesc ;
2015-02-24 16:28:47 -05:00
Ret . Reset ( ) ;
Ret . DebugName = TEXT ( " ScatteredMaxVelocity " ) ;
return Ret ;
}
2015-06-22 19:08:33 -04:00
class FPostProcessVelocityGatherCS : public FGlobalShader
2015-02-24 16:28:47 -05:00
{
2015-06-22 19:08:33 -04:00
DECLARE_SHADER_TYPE ( FPostProcessVelocityGatherCS , Global ) ;
2015-02-24 16:28:47 -05:00
static bool ShouldCache ( EShaderPlatform Platform )
{
2015-06-23 03:33:11 -04:00
return IsFeatureLevelSupported ( Platform , ERHIFeatureLevel : : SM5 ) ;
2015-02-24 16:28:47 -05:00
}
static void ModifyCompilationEnvironment ( EShaderPlatform Platform , FShaderCompilerEnvironment & OutEnvironment )
{
FGlobalShader : : ModifyCompilationEnvironment ( Platform , OutEnvironment ) ;
}
/** Default constructor. */
2015-06-22 19:08:33 -04:00
FPostProcessVelocityGatherCS ( ) { }
2015-02-24 16:28:47 -05:00
public :
2015-06-22 19:08:33 -04:00
FShaderParameter OutScatteredMaxVelocity ;
2015-02-24 16:28:47 -05:00
/** Initialization constructor. */
2015-06-22 19:08:33 -04:00
FPostProcessVelocityGatherCS ( const ShaderMetaType : : CompiledShaderInitializerType & Initializer )
2015-02-24 16:28:47 -05:00
: FGlobalShader ( Initializer )
{
PostprocessParameter . Bind ( Initializer . ParameterMap ) ;
2015-11-18 09:31:10 -05:00
MotionBlurParameters . Bind ( Initializer . ParameterMap , TEXT ( " MotionBlurParameters " ) ) ;
2015-06-22 19:08:33 -04:00
OutScatteredMaxVelocity . Bind ( Initializer . ParameterMap , TEXT ( " OutScatteredMaxVelocity " ) ) ;
2015-02-24 16:28:47 -05:00
}
// FShader interface.
2015-04-01 07:20:55 -04:00
virtual bool Serialize ( FArchive & Ar ) override
2015-02-24 16:28:47 -05:00
{
bool bShaderHasOutdatedParameters = FGlobalShader : : Serialize ( Ar ) ;
Ar < < PostprocessParameter ;
2015-11-18 09:31:10 -05:00
Ar < < MotionBlurParameters ;
2015-06-22 19:08:33 -04:00
Ar < < OutScatteredMaxVelocity ;
2015-02-24 16:28:47 -05:00
return bShaderHasOutdatedParameters ;
}
void SetParameters ( const FRenderingCompositePassContext & Context )
{
2015-06-22 19:08:33 -04:00
const FComputeShaderRHIParamRef ShaderRHI = GetComputeShader ( ) ;
2015-02-24 16:28:47 -05:00
FGlobalShader : : SetParameters ( Context . RHICmdList , ShaderRHI , Context . View ) ;
Copying //UE4/Dev-Rendering to Dev-Main (//UE4/Dev-Main)
#lockdown ben.marsh
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2774277 on 2015/11/19 by Gil.Gribb
UE4 - Did minor optimizations to the PS4 RHI and drawlists.
Change 2791226 on 2015/12/04 by Uriel.Doyon
Added source code for Embree 2.7.0
Removed duplicate files from the /doc folder.
Change 2800193 on 2015/12/11 by Marcus.Wassmer
SSAO AsyncCompute support.
#rb Martin.Mittring
Change 2801631 on 2015/12/14 by Olaf.Piesche
Making auto deactivate true by default, moving checks to HasCompleted, eliminating some unnecessary logic
#rb martin.mittring
Change 2803240 on 2015/12/15 by Gil.Gribb
UE4 - Added command to collect stats on spammy stats.
Change 2803476 on 2015/12/15 by Rolando.Caloca
DR - Allow toggling compute skin dispatch at runtime
- r.SkinCacheShaders Now enable the shaders and feature
- r.SkinCaching enables toggling at runtime
- r.SkinCache.BufferSize Sets the size in bytes of buffer for outputting
- Now uses 3 UAV buffers instead of one (avoid RenderDoc crashes)
#codereview Marcus.Wassmer, Martin.Mittring
Change 2803940 on 2015/12/15 by Marcus.Wassmer
Add r.PS4.AsyncComputeBudgetMode to switch between CUMasking and WaveLimit modes. So far it looks like WaveLimits behave better in UE4.
Also rearrange AsyncSSAO to run immediately after HZB to overlap with occlusion queries. In my testing this takes SSAO cost from .5ms -> .2ms. However it had to be hacked to run without normals. Hopefully Martin can get some real AsyncSSAO in.
#rb Martin.Mittring
#codereview Martin.Mittring
Change 2803999 on 2015/12/15 by Uriel.Doyon
Refactored the shader complexity material override logic to allow other viewmodes shader overrides.
TexelFactorAccuracy ViewMode : shows the accuracy of the static mesh texel factors, used for streaming.
WantedMipsAccuracy ViewMode : shows the accuracy of the static mesh wanted mips accuracy, used for streaming.
Added an option to stream textures based on the AABB distance instead of using the sphere approximation.
Added an option to only keep a the wanted mips.
Moved optimization related viewmodes into a submenu to avoid polluting the interface.
#jira UE-24502
#jira UE-24503
#jira UERNDR-89
Change 2804150 on 2015/12/15 by Olaf.Piesche
make separate translucency screen percentage a bit more robust; add numsamples to the render target creation functions in preparation for MSAA support for higher quality with low res separate translucency
#rb martin.mittring
Change 2804367 on 2015/12/15 by Daniel.Wright
Capsule shadow primitives are tracked separately on registration - saves 2.6ms of RT time doing the view frustum culling in a medium sized map
Change 2805293 on 2015/12/16 by Olaf.Piesche
logging if potentially immortal emitters are spawned from gameplay; this should catch if we spawn burst only emitters with indefinite life spans (muzzle flashes, hit impacts, etc.)
#rb martin.mittring
Change 2805586 on 2015/12/16 by Zabir.Hoque
Adding support for decals to fade and destroy themselves automatically.
#CodeReview: Martin.Mittring, Daniel.Wright, Olaf.Piesche
Change 2807663 on 2015/12/17 by Rolando.Caloca
DR - Remove expensive logging
#codereview Marcus.Wassmer
Change 2807903 on 2015/12/17 by Zabir.Hoque
Refactored DecalComponent's lifetime management such that it can be set and reset from Blueprints.
#CodeReview Daniel.Wright, Martin.Mittring, Olaf.Piesche
Change 2809261 on 2015/12/18 by Martin.Mittring
Added VisualizeShadingModels to track down issues like that:
FORT-16913 Textures on Hero Mesh is not shown
#rb:David.Hill
#code_review:Bob.Tellez
Change 2810136 on 2015/12/21 by Rolando.Caloca
DR - Added back draw event colors
PR #1602
#jira UE-21526
#codereview Mark.Satterthwaite, Keith.Judge, Marcus.Wassmer, Josh.Adams
Change 2810680 on 2015/12/21 by Martin.Mittring
moved SSAO ComputeShader running without per pixel normal (for AsyncCompute) into DevRendering
#test:editor
Change 2811205 on 2015/12/22 by Brian.Karis
Pulled clear coat out of the reflection compute shader. Added permutation for skylight.
Clear coat base layer now done in base pass. It only picks up the closest capture. This will cause popping when the object moves. Still needs a cross fade.
Change 2811275 on 2015/12/22 by David.Hill
UE-24675
#rb martin.mittring
Corrected buffer-size related problem with fringe.
Change 2811397 on 2015/12/22 by Brian.Karis
2016-01-08 11:12:28 -05:00
PostprocessParameter . SetCS ( ShaderRHI , Context , Context . RHICmdList , TStaticSamplerState < SF_Point , AM_Clamp , AM_Clamp , AM_Clamp > : : GetRHI ( ) ) ;
2015-11-18 09:31:10 -05:00
SetShaderValue ( Context . RHICmdList , ShaderRHI , MotionBlurParameters , GetMotionBlurParameters ( Context . View ) ) ;
2015-02-24 16:28:47 -05:00
}
2015-06-22 19:08:33 -04:00
private :
2015-11-18 09:31:10 -05:00
FPostProcessPassParameters PostprocessParameter ;
FShaderParameter MotionBlurParameters ;
2015-02-24 16:28:47 -05:00
} ;
2015-06-22 19:08:33 -04:00
IMPLEMENT_SHADER_TYPE ( , FPostProcessVelocityGatherCS , TEXT ( " PostProcessVelocityFlatten " ) , TEXT ( " VelocityGatherCS " ) , SF_Compute ) ;
2015-02-24 16:28:47 -05:00
2015-06-22 19:08:33 -04:00
void FRCPassPostProcessVelocityGather : : Process ( FRenderingCompositePassContext & Context )
2015-02-24 16:28:47 -05:00
{
SCOPED_DRAW_EVENT ( Context . RHICmdList , VelocityDilate ) ;
const FPooledRenderTargetDesc * InputDesc = GetInputDesc ( ePId_Input0 ) ;
if ( ! InputDesc )
{
// input is not hooked up correctly
return ;
}
const FSceneView & View = Context . View ;
2015-06-22 19:08:33 -04:00
FIntPoint TileCount = GetNumTiles16x16 ( View . ViewRect . Size ( ) ) ;
2015-02-24 16:28:47 -05:00
const FSceneRenderTargetItem & DestRenderTarget = PassOutputs [ 0 ] . RequestSurface ( Context ) ;
2015-06-22 19:08:33 -04:00
SetRenderTarget ( Context . RHICmdList , FTextureRHIRef ( ) , FTextureRHIRef ( ) ) ;
Context . SetViewportAndCallRHI ( 0 , 0 , 0.0f , TileCount . X , TileCount . Y , 1.0f ) ;
TShaderMapRef < FPostProcessVelocityGatherCS > ComputeShader ( Context . GetShaderMap ( ) ) ;
Context . RHICmdList . SetComputeShader ( ComputeShader - > GetComputeShader ( ) ) ;
2015-02-24 16:28:47 -05:00
2015-06-22 19:08:33 -04:00
// set destination
Context . RHICmdList . SetUAVParameter ( ComputeShader - > GetComputeShader ( ) , ComputeShader - > OutScatteredMaxVelocity . GetBaseIndex ( ) , DestRenderTarget . UAV ) ;
2015-02-24 16:28:47 -05:00
2015-06-22 19:08:33 -04:00
ComputeShader - > SetParameters ( Context ) ;
2015-02-24 16:28:47 -05:00
2015-11-18 09:31:10 -05:00
FIntPoint GroupCount = GetNumTiles16x16 ( TileCount ) ;
DispatchComputeShader ( Context . RHICmdList , * ComputeShader , GroupCount . X , GroupCount . Y , 1 ) ;
2015-02-24 16:28:47 -05:00
2015-06-22 19:08:33 -04:00
// un-set destination
Context . RHICmdList . SetUAVParameter ( ComputeShader - > GetComputeShader ( ) , ComputeShader - > OutScatteredMaxVelocity . GetBaseIndex ( ) , NULL ) ;
2015-02-24 16:28:47 -05:00
Context . RHICmdList . CopyToResolveTarget ( DestRenderTarget . TargetableTexture , DestRenderTarget . ShaderResourceTexture , false , FResolveParams ( ) ) ;
}
2015-06-22 19:08:33 -04:00
FPooledRenderTargetDesc FRCPassPostProcessVelocityGather : : ComputeOutputDesc ( EPassOutputId InPassOutputId ) const
2015-02-24 16:28:47 -05:00
{
2015-07-06 18:04:49 -04:00
FPooledRenderTargetDesc Ret = GetInput ( ePId_Input0 ) - > GetOutput ( ) - > RenderTargetDesc ;
2015-02-24 16:28:47 -05:00
Ret . Reset ( ) ;
2015-06-22 19:08:33 -04:00
Ret . TargetableFlags | = TexCreate_UAV ;
Ret . TargetableFlags | = TexCreate_RenderTargetable ;
Ret . DebugName = TEXT ( " ScatteredMaxVelocity " ) ;
2015-02-24 16:28:47 -05:00
return Ret ;
}
2015-02-22 17:53:26 -05:00
/**
* @ param Quality 0 : visualize , 1 : low , 2 : medium , 3 : high , 4 : very high
*/
template < uint32 Quality >
class FPostProcessMotionBlurNewPS : public FGlobalShader
{
DECLARE_SHADER_TYPE ( FPostProcessMotionBlurNewPS , Global ) ;
static bool ShouldCache ( EShaderPlatform Platform )
{
return IsFeatureLevelSupported ( Platform , ERHIFeatureLevel : : SM4 ) ;
}
static void ModifyCompilationEnvironment ( EShaderPlatform Platform , FShaderCompilerEnvironment & OutEnvironment )
{
FGlobalShader : : ModifyCompilationEnvironment ( Platform , OutEnvironment ) ;
OutEnvironment . SetDefine ( TEXT ( " MOTION_BLUR_QUALITY " ) , Quality ) ;
}
/** Default constructor. */
FPostProcessMotionBlurNewPS ( ) { }
public :
FPostProcessPassParameters PostprocessParameter ;
FDeferredPixelShaderParameters DeferredParameters ;
FShaderParameter MotionBlurParameters ;
/** Initialization constructor. */
FPostProcessMotionBlurNewPS ( const ShaderMetaType : : CompiledShaderInitializerType & Initializer )
: FGlobalShader ( Initializer )
{
PostprocessParameter . Bind ( Initializer . ParameterMap ) ;
DeferredParameters . Bind ( Initializer . ParameterMap ) ;
MotionBlurParameters . Bind ( Initializer . ParameterMap , TEXT ( " MotionBlurParameters " ) ) ;
}
// FShader interface.
2015-04-01 07:20:55 -04:00
virtual bool Serialize ( FArchive & Ar ) override
2015-02-22 17:53:26 -05:00
{
bool bShaderHasOutdatedParameters = FGlobalShader : : Serialize ( Ar ) ;
Ar < < PostprocessParameter < < DeferredParameters < < MotionBlurParameters ;
return bShaderHasOutdatedParameters ;
}
2015-11-18 09:31:10 -05:00
void SetParameters ( const FRenderingCompositePassContext & Context , float Scale )
2015-02-22 17:53:26 -05:00
{
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader ( ) ;
FGlobalShader : : SetParameters ( Context . RHICmdList , ShaderRHI , Context . View ) ;
DeferredParameters . Set ( Context . RHICmdList , ShaderRHI , Context . View ) ;
{
bool bFiltered = false ;
# if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
bFiltered = CVarMotionBlurFiltering . GetValueOnRenderThread ( ) ! = 0 ;
# endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
if ( bFiltered )
{
//PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear,AM_Border,AM_Border,AM_Clamp>::GetRHI());
FSamplerStateRHIParamRef Filters [ ] =
{
2015-02-23 15:16:20 -05:00
TStaticSamplerState < SF_Bilinear , AM_Clamp , AM_Clamp , AM_Clamp > : : GetRHI ( ) ,
TStaticSamplerState < SF_Point , AM_Clamp , AM_Clamp , AM_Clamp > : : GetRHI ( ) ,
TStaticSamplerState < SF_Point , AM_Clamp , AM_Clamp , AM_Clamp > : : GetRHI ( ) ,
2015-02-24 16:28:47 -05:00
TStaticSamplerState < SF_Point , AM_Clamp , AM_Clamp , AM_Clamp > : : GetRHI ( ) ,
} ;
2015-08-14 11:59:44 -04:00
PostprocessParameter . SetPS ( ShaderRHI , Context , 0 , eFC_0000 , Filters ) ;
2015-02-24 16:28:47 -05:00
}
2015-02-22 17:53:26 -05:00
else
{
2015-02-23 15:16:20 -05:00
PostprocessParameter . SetPS ( ShaderRHI , Context , TStaticSamplerState < SF_Point , AM_Clamp , AM_Clamp , AM_Clamp > : : GetRHI ( ) ) ;
2015-02-22 17:53:26 -05:00
}
}
2015-11-18 09:31:10 -05:00
SetShaderValue ( Context . RHICmdList , ShaderRHI , MotionBlurParameters , GetMotionBlurParameters ( Context . View , Scale ) ) ;
2015-02-22 17:53:26 -05:00
}
static const TCHAR * GetSourceFilename ( )
{
return TEXT ( " PostProcessMotionBlur " ) ;
}
static const TCHAR * GetFunctionName ( )
{
return TEXT ( " MainNewPS " ) ;
}
} ;
// #define avoids a lot of code duplication
# define VARIATION1(A) typedef FPostProcessMotionBlurNewPS<A> FPostProcessMotionBlurNewPS##A; \
IMPLEMENT_SHADER_TYPE2 ( FPostProcessMotionBlurNewPS # # A , SF_Pixel ) ;
2015-11-18 09:31:10 -05:00
VARIATION1 ( 1 ) VARIATION1 ( 2 ) VARIATION1 ( 3 ) VARIATION1 ( 4 )
2015-02-22 17:53:26 -05:00
# undef VARIATION1
// @param Quality 0: visualize, 1:low, 2:medium, 3:high, 4:very high
template < uint32 Quality >
2015-11-18 09:31:10 -05:00
static void SetMotionBlurShaderNewTempl ( const FRenderingCompositePassContext & Context , float Scale )
2015-02-22 17:53:26 -05:00
{
2015-09-01 16:52:40 -04:00
TShaderMapRef < FPostProcessVS > VertexShader ( Context . GetShaderMap ( ) ) ;
2015-02-22 17:53:26 -05:00
TShaderMapRef < FPostProcessMotionBlurNewPS < Quality > > PixelShader ( Context . GetShaderMap ( ) ) ;
static FGlobalBoundShaderState BoundShaderState ;
SetGlobalBoundShaderState ( Context . RHICmdList , Context . GetFeatureLevel ( ) , BoundShaderState , GFilterVertexDeclaration . VertexDeclarationRHI , * VertexShader , * PixelShader ) ;
VertexShader - > SetParameters ( Context ) ;
2015-11-18 09:31:10 -05:00
PixelShader - > SetParameters ( Context , Scale ) ;
2015-02-22 17:53:26 -05:00
}
void FRCPassPostProcessMotionBlurNew : : Process ( FRenderingCompositePassContext & Context )
{
const FPooledRenderTargetDesc * InputDesc = GetInputDesc ( ePId_Input0 ) ;
if ( ! InputDesc )
{
// input is not hooked up correctly
return ;
}
const FSceneView & View = Context . View ;
// we assume the input and output is full resolution
FIntPoint SrcSize = InputDesc - > Extent ;
FIntPoint DestSize = PassOutputs [ 0 ] . RenderTargetDesc . Extent ;
// e.g. 4 means the input texture is 4x smaller than the buffer size
2015-05-29 10:47:57 -04:00
uint32 ScaleFactor = FSceneRenderTargets : : Get ( Context . RHICmdList ) . GetBufferSizeXY ( ) . X / SrcSize . X ;
2015-02-22 17:53:26 -05:00
2015-02-24 16:28:47 -05:00
FIntRect SrcRect = View . ViewRect / ScaleFactor ;
2015-02-22 17:53:26 -05:00
FIntRect DestRect = SrcRect ;
2015-09-03 13:11:59 -04:00
SCOPED_DRAW_EVENTF ( Context . RHICmdList , MotionBlurNew , TEXT ( " MotionBlur(New) %dx%d " ) , SrcRect . Width ( ) , SrcRect . Height ( ) ) ;
2015-09-01 16:52:40 -04:00
2015-02-22 17:53:26 -05:00
const FSceneRenderTargetItem & DestRenderTarget = PassOutputs [ 0 ] . RequestSurface ( Context ) ;
// Set the view family's render target/viewport.
SetRenderTarget ( Context . RHICmdList , DestRenderTarget . TargetableTexture , FTextureRHIRef ( ) ) ;
2015-06-22 19:08:33 -04:00
Context . SetViewportAndCallRHI ( SrcRect ) ;
2015-02-22 17:53:26 -05:00
// is optimized away if possible (RT size=view size, )
//Context.RHICmdList.Clear(true, FLinearColor::Black, false, 1.0f, false, 0, SrcRect);
// set the state
Context . RHICmdList . SetBlendState ( TStaticBlendState < > : : GetRHI ( ) ) ;
Context . RHICmdList . SetRasterizerState ( TStaticRasterizerState < > : : GetRHI ( ) ) ;
Context . RHICmdList . SetDepthStencilState ( TStaticDepthStencilState < false , CF_Always > : : GetRHI ( ) ) ;
2015-11-18 09:31:10 -05:00
float BlurScaleLUT [ ] =
{
1.0f - 0.5f / 4.0f ,
1.0f - 0.5f / 6.0f ,
1.0f - 0.5f / 8.0f ,
1.0f - 0.5f / 16.0f ,
1.0f / 4.0f * CVarMotionBlur2ndScale . GetValueOnRenderThread ( ) ,
1.0f / 6.0f * CVarMotionBlur2ndScale . GetValueOnRenderThread ( ) ,
1.0f / 8.0f * CVarMotionBlur2ndScale . GetValueOnRenderThread ( ) ,
1.0f / 16.0f * CVarMotionBlur2ndScale . GetValueOnRenderThread ( ) ,
} ;
float Scale = Pass > = 0 ? BlurScaleLUT [ ( Pass * 4 ) + ( Quality - 1 ) ] : 1.0f ;
2015-02-22 17:53:26 -05:00
if ( Quality = = 1 )
{
2015-11-18 09:31:10 -05:00
SetMotionBlurShaderNewTempl < 1 > ( Context , Scale ) ;
2015-02-22 17:53:26 -05:00
}
else if ( Quality = = 2 )
{
2015-11-18 09:31:10 -05:00
SetMotionBlurShaderNewTempl < 2 > ( Context , Scale ) ;
2015-02-22 17:53:26 -05:00
}
2015-11-18 09:31:10 -05:00
else if ( Quality = = 3 | | Pass > 0 )
2015-02-22 17:53:26 -05:00
{
2015-11-18 09:31:10 -05:00
SetMotionBlurShaderNewTempl < 3 > ( Context , Scale ) ;
2015-02-22 17:53:26 -05:00
}
else
{
check ( Quality = = 4 ) ;
2015-11-18 09:31:10 -05:00
SetMotionBlurShaderNewTempl < 4 > ( Context , Scale ) ;
2015-02-22 17:53:26 -05:00
}
TShaderMapRef < FPostProcessVS > VertexShader ( Context . GetShaderMap ( ) ) ;
2015-08-04 19:33:26 -04:00
DrawPostProcessPass (
2015-02-22 17:53:26 -05:00
Context . RHICmdList ,
0 , 0 ,
SrcRect . Width ( ) , SrcRect . Height ( ) ,
2015-08-04 19:33:26 -04:00
SrcRect . Min . X , SrcRect . Min . Y ,
2015-02-22 17:53:26 -05:00
SrcRect . Width ( ) , SrcRect . Height ( ) ,
SrcRect . Size ( ) ,
SrcSize ,
* VertexShader ,
2015-08-04 19:33:26 -04:00
View . StereoPass ,
Context . HasHmdMesh ( ) ,
2015-02-22 17:53:26 -05:00
EDRF_UseTriangleOptimization ) ;
Context . RHICmdList . CopyToResolveTarget ( DestRenderTarget . TargetableTexture , DestRenderTarget . ShaderResourceTexture , false , FResolveParams ( ) ) ;
}
FPooledRenderTargetDesc FRCPassPostProcessMotionBlurNew : : ComputeOutputDesc ( EPassOutputId InPassOutputId ) const
{
2015-07-06 18:04:49 -04:00
FPooledRenderTargetDesc Ret = GetInput ( ePId_Input0 ) - > GetOutput ( ) - > RenderTargetDesc ;
2015-02-22 17:53:26 -05:00
Ret . Reset ( ) ;
Ret . Format = PF_FloatRGB ;
Ret . DebugName = TEXT ( " MotionBlur " ) ;
2015-09-28 14:13:15 -04:00
Ret . AutoWritable = false ;
2015-02-22 17:53:26 -05:00
return Ret ;
}
2014-03-14 14:13:41 -04:00
void FRCPassPostProcessVisualizeMotionBlur : : Process ( FRenderingCompositePassContext & Context )
{
2014-10-20 10:43:43 -04:00
SCOPED_DRAW_EVENT ( Context . RHICmdList , VisualizeMotionBlur ) ;
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 ;
2015-04-21 13:44:06 -04:00
const FSceneViewFamily & ViewFamily = * ( View . Family ) ;
2014-03-14 14:13:41 -04:00
FIntPoint TexSize = InputDesc - > Extent ;
// we assume the input and output is full resolution
FIntPoint SrcSize = InputDesc - > Extent ;
FIntPoint DestSize = PassOutputs [ 0 ] . RenderTargetDesc . Extent ;
// e.g. 4 means the input texture is 4x smaller than the buffer size
2015-05-29 10:47:57 -04:00
uint32 ScaleFactor = FSceneRenderTargets : : Get ( Context . RHICmdList ) . GetBufferSizeXY ( ) . X / SrcSize . X ;
2014-03-14 14:13:41 -04:00
FIntRect SrcRect = FIntRect : : DivideAndRoundUp ( View . ViewRect , ScaleFactor ) ;
FIntRect DestRect = SrcRect ;
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 , SrcRect ) ;
2014-03-14 14:13:41 -04:00
Context . SetViewportAndCallRHI ( SrcRect ) ;
// 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
// Quality 0: visualize
2014-06-12 07:13:34 -04:00
SetMotionBlurShaderTempl < 0 > ( 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-04-23 17:26:59 -04:00
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
0 , 0 ,
SrcRect . Width ( ) , SrcRect . Height ( ) ,
SrcRect . Min . X , SrcRect . Min . Y ,
SrcRect . Width ( ) , SrcRect . Height ( ) ,
SrcRect . Size ( ) ,
SrcSize ,
2014-04-23 17:26:59 -04:00
* VertexShader ,
2014-03-14 14:13:41 -04:00
EDRF_UseTriangleOptimization ) ;
2015-04-21 13:44:06 -04:00
// this is a helper class for FCanvas to be able to get screen size
class FRenderTargetTemp : public FRenderTarget
{
public :
const FSceneView & View ;
const FTexture2DRHIRef Texture ;
FRenderTargetTemp ( const FSceneView & InView , const FTexture2DRHIRef InTexture )
: View ( InView ) , Texture ( InTexture )
{
}
virtual FIntPoint GetSizeXY ( ) const
{
return View . ViewRect . Size ( ) ;
} ;
virtual const FTexture2DRHIRef & GetRenderTargetTexture ( ) const
{
return Texture ;
}
} TempRenderTarget ( View , ( const FTexture2DRHIRef & ) DestRenderTarget . TargetableTexture ) ;
FCanvas Canvas ( & TempRenderTarget , NULL , ViewFamily . CurrentRealTime , ViewFamily . CurrentWorldTime , ViewFamily . DeltaWorldTime , Context . GetFeatureLevel ( ) ) ;
2015-04-27 17:12:21 -04:00
float X = 20 ;
2015-04-21 13:44:06 -04:00
float Y = 8 ;
const float YStep = 14 ;
2015-04-27 17:12:21 -04:00
const float ColumnWidth = 200 ;
2015-04-21 13:44:06 -04:00
FString Line ;
Line = FString : : Printf ( TEXT ( " Visualize MotionBlur " ) ) ;
2015-04-23 17:35:40 -04:00
Canvas . DrawShadowedString ( X , Y + = YStep , * Line , GetStatsFont ( ) , FLinearColor ( 1 , 1 , 0 ) ) ;
2015-04-21 13:44:06 -04:00
2015-04-24 17:43:35 -04:00
static const auto MotionBlurDebugVar = IConsoleManager : : Get ( ) . FindTConsoleVariableDataInt ( TEXT ( " r.MotionBlurDebug " ) ) ;
const int32 MotionBlurDebug = MotionBlurDebugVar ? MotionBlurDebugVar - > GetValueOnRenderThread ( ) : 0 ;
Line = FString : : Printf ( TEXT ( " %d, %d " ) , ViewFamily . FrameNumber , MotionBlurDebug ) ;
2015-04-27 17:12:21 -04:00
Canvas . DrawShadowedString ( X , Y + = YStep , TEXT ( " FrameNo, r.MotionBlurDebug: " ) , GetStatsFont ( ) , FLinearColor ( 1 , 1 , 0 ) ) ;
2015-04-23 17:35:40 -04:00
Canvas . DrawShadowedString ( X + ColumnWidth , Y , * Line , GetStatsFont ( ) , FLinearColor ( 1 , 1 , 0 ) ) ;
2015-04-21 13:44:06 -04:00
2015-04-24 17:43:35 -04:00
static const auto VelocityTestVar = IConsoleManager : : Get ( ) . FindTConsoleVariableDataInt ( TEXT ( " r.VelocityTest " ) ) ;
const int32 VelocityTest = VelocityTestVar ? VelocityTestVar - > GetValueOnRenderThread ( ) : 0 ;
extern bool IsParallelVelocity ( ) ;
2015-04-27 17:12:21 -04:00
Line = FString : : Printf ( TEXT ( " %d, %d, %d " ) , ViewFamily . bWorldIsPaused , VelocityTest , IsParallelVelocity ( ) ) ;
Canvas . DrawShadowedString ( X , Y + = YStep , TEXT ( " Paused, r.VelocityTest, Parallel: " ) , GetStatsFont ( ) , FLinearColor ( 1 , 1 , 0 ) ) ;
2015-04-23 17:35:40 -04:00
Canvas . DrawShadowedString ( X + ColumnWidth , Y , * Line , GetStatsFont ( ) , FLinearColor ( 1 , 1 , 0 ) ) ;
2015-04-27 14:32:32 -04:00
const FScene * Scene = ( const FScene * ) View . Family - > Scene ;
Canvas . DrawShadowedString ( X , Y + = YStep , TEXT ( " MotionBlurInfoData (per object): " ) , GetStatsFont ( ) , FLinearColor ( 1 , 1 , 0 ) ) ;
Canvas . DrawShadowedString ( X + ColumnWidth , Y , * Scene - > MotionBlurInfoData . GetDebugString ( ) , GetStatsFont ( ) , FLinearColor ( 1 , 1 , 0 ) ) ;
2015-04-27 17:12:21 -04:00
const FSceneViewState * SceneViewState = ( const FSceneViewState * ) View . State ;
Line = FString : : Printf ( TEXT ( " View=%.4x PrevView=%.4x " ) ,
View . ViewMatrices . ViewMatrix . ComputeHash ( ) & 0xffff ,
SceneViewState - > PrevViewMatrices . ViewMatrix . ComputeHash ( ) & 0xffff ) ;
Canvas . DrawShadowedString ( X , Y + = YStep , TEXT ( " ViewMatrix: " ) , GetStatsFont ( ) , FLinearColor ( 1 , 1 , 0 ) ) ;
Canvas . DrawShadowedString ( X + ColumnWidth , Y , * Line , GetStatsFont ( ) , FLinearColor ( 1 , 1 , 0 ) ) ;
2015-04-21 13:44:06 -04:00
Canvas . Flush_RenderThread ( Context . RHICmdList ) ;
2014-06-12 07:13:34 -04:00
Context . RHICmdList . CopyToResolveTarget ( DestRenderTarget . TargetableTexture , DestRenderTarget . ShaderResourceTexture , false , FResolveParams ( ) ) ;
2014-03-14 14:13:41 -04:00
}
FPooledRenderTargetDesc FRCPassPostProcessVisualizeMotionBlur : : ComputeOutputDesc ( EPassOutputId InPassOutputId ) const
{
2015-07-06 18:04:49 -04:00
FPooledRenderTargetDesc Ret = GetInput ( ePId_Input0 ) - > GetOutput ( ) - > RenderTargetDesc ;
2014-03-14 14:13:41 -04:00
Ret . Reset ( ) ;
Ret . DebugName = TEXT ( " MotionBlur " ) ;
2015-09-28 14:13:15 -04:00
Ret . AutoWritable = false ;
2014-03-14 14:13:41 -04:00
return Ret ;
2015-04-01 07:20:55 -04:00
}