You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown nick.penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 2998081 on 2016/06/02 by Rolando.Caloca DR - Update vulkan headers to 1.0.13.0 Change 2998087 on 2016/06/02 by Rolando.Caloca DR - Added r.DumpShaderDebugWorkerCommandLine to dump a batch file containing a command line for SCW's -directcompile mode Change 2998092 on 2016/06/02 by Rolando.Caloca DR - Updated ThirdParty/glslang to 1.0.13.0 Change 2998113 on 2016/06/02 by Martin.Mittring Added -Deterministic and -BuildName=... as command line option for Screenshot verification Change 2998115 on 2016/06/02 by Martin.Mittring optimied Tonemapper sharpen 25->17 instructions fixes: very bright HDR pixel appeared to not be antialiased no blonger blurs very bright pixels (we could bring that back if needed but counters the sharpen) moved one multipy into C++ Added debug visualization (HLSL define) Change 2998132 on 2016/06/02 by Rolando.Caloca DR - Remove auto from VulkanRHI wherever possible Change 2998148 on 2016/06/02 by Rolando.Caloca DR - Move FVulkanPendingState out of device and into cmd list for more RHI thread fixes Change 2998180 on 2016/06/02 by Rolando.Caloca DR - Temp fix for (bogus?) fence validation warning using VULKAN_REUSE_FENCES=0 - Check we are not asking for a VkFormat out of bounds (ie only works with core formats) Change 2998293 on 2016/06/02 by Rolando.Caloca DR - Add support for BC6H & BC7 in desktop Vulkan Change 2998419 on 2016/06/02 by Brian.Karis Optimized CountBits Change2998480on 2016/06/02 by Rolando.Caloca DR - Fix for RHI thread failing in an ensure on es31 (doesn't happen on bypass as the ensure is inside RHI cmd list) Change 2998486 on 2016/06/02 by Martin.Mittring fixed ES2 shader compile Change 2998527 on 2016/06/02 by Daniel.Wright Added cvar r.StencilForLODDither, which is compiled into shaders and forces a full prepass when enabled. This allows r.EarlyZPass to remain changeable at runtime (when not forced to a value by features that are enabled). Change 2998531 on 2016/06/02 by Daniel.Wright Fixed Pixel Normal Offset refraction mode with materials using world space normals Change 2998568 on 2016/06/02 by Rolando.Caloca DR - Fix typo Change 2998630 on 2016/06/02 by Rolando.Caloca DR - Relaxed glslang strictness to get Pos tCombineLUTs working - Reenabled Post CombineLUTs on Vulkan - Removed some extra glsl output from Vulkan backend - Fixed RHI thread uniform buffer assert Change 2998639 on 2016/06/02 by Brian.Karis Fix for crash when removing instances while lighting is building Change 2998640 on 2016/06/02 by Martin.Mittring added r.ResetViewState to allow for more deterministic rendering made SSR FrameRandom resetable by not using FrameNumber (Note: SSR on a view without state was flickering before, not it's stabele and doesn't flicker) Change 2998790 on 2016/06/02 by Martin.Mittring minor optimization to SSR Change 2999849 on 2016/06/03 by Martin.Mittring fixed issue with sort order Change 3000340 on 2016/06/03 by Rolando.Caloca DR - Integrate change from 3000177 Workaround for random crash shutting down D3D11/NV driver jira UE-18906 Change3000422on 2016/06/03 by Rolando.Caloca DR - Mirror change in Odin Change 3000571 on 2016/06/03 by Rolando.Caloca DR - Vulkan SM4 prep Change 3001652 on 2016/06/06 by Gil.Gribb Merging //UE4/Dev-Main@3001532 to Dev-Rendering (//UE4/Dev-Rendering) Change 3001935 on 2016/06/06 by Gil.Gribb UE4 - Fixed botched merge Change 3002390 on 2016/06/06 by Gil.Gribb UE4 - Added code to prevent flooding of rendering thread with heartbeats. Change 3002442 on 2016/06/06 by Martin.Mittring Moved ImageInvalidator out of NotForLicensees - V1.0 works well enough Change 3002460 on 2016/06/06 by Martin.Mittring fixed missing file in ImageValidator added .exe to extras Change 3002514 on 2016/06/06 by Martin.Mittring added OpenSubDiv 3.0.2, not yet used Change 3002536 on 2016/06/06 by Martin.Mittring fixed help text on cvar Change 3002647 on 2016/06/06 by Martin.Mittring adding r.ResetViewState to RenderOutputValidation added r.Streaming.FramesForFullUpdate to r.DisplayInternals #code_review:Benjamin.Hyder Change 3002945 on 2016/06/06 by Rolando.Caloca DR - Fix hlslcc issue with access to matrix elements: This would fail: M._m30 += f; - Fixed IRDump for matrix swizzled - Fix hlslcc_exe not linking Change 3002979 on 2016/06/06 by John.Billon DDS unsupported format error #Jira UE-24529 Change 3002983 on 2016/06/06 by Martin.Mittring split FPixelShaderInOut in in and out Change 3003011 on 2016/06/06 by Martin.Mittring updated OpenSubDiv to 3.0.2 Fixed SubDivisonRendring by using OpenSubDiv Change 3003264 on 2016/06/06 by Daniel.Wright Fixed bUseSingleSampleShadowFromStationaryLights on particles Change 3003296 on 2016/06/06 by Daniel.Wright Renamed files Forward* to Mobile* Change 3003350 on 2016/06/06 by Daniel.Wright Improved "Repaired Painted Vertex Colors" log message. This is now done once on levels at load in the editor, instead of for every component (massive log spam). Total load time caused by the fixup is reported. Change 3003815 on 2016/06/07 by Chris.Bunner Updating to more recent D3DCompiler DLL, seeing up to 2x speed-up in testing. Removed compiler override cvar. #jira UE-28574 Change 3003827 on 2016/06/07 by Gil.Gribb UE4 - Increased stack sizes for thread pools. Change 3003971 on 2016/06/07 by Martin.Mittring fixed compiler warnings Change 3004028 on 2016/06/07 by Rolando.Caloca DR - Update glslang exe Change 3004555 on 2016/06/07 by Rolando.Caloca DR - vk - Fix validation warning Change 3004637 on 2016/06/07 by Martin.Mittring fixed compiler warning Change 3004841 on 2016/06/07 by Daniel.Wright Fix for shadowed variable Change 3005044 on 2016/06/07 by Daniel.Wright SubUV Animations can get opacity information from any channel of the source texture Change 3005057 on 2016/06/07 by Daniel.Wright Renamed ForwardShading* to Mobile* Change 3005135 on 2016/06/07 by Uriel.Doyon Moving wanted mip computation (according to budget) to async task. Update "stat streaming" to show visible mips and also loading progression. Fixed overly wanted mip issue cause be max range clamping. Optimized cost of the texture streamer on the gamethread. Character, Terrain and Forced Load are now loaded with priority in the AsyncIO Reduced streaming temp memory requirements on PS4. Async streaming task now runs in parallel to the incremental update. Fixed bug with bProcessEverything not working as expected in UpdateResourceStreaming. Fixed metrics with HiddenScale being applied in addition to overbudget limitation. Improved budget stability when using split load request (one for visible mips + one for hidden mips) Implemented a more agressive visibility test (used to be a seen in the last 5 sec, now closer to .5) Streaming stats are now within a single class named FTextureStreamingStats and updated in a single function. Cleanup of FStreamingTexture state update into a single function (UpdateDynamicData). Retention logic now drops texture based on the last render time (for non visible textures) to reduce looping effects. Change 3005207 on 2016/06/07 by Uriel.Doyon Fixed warning [CL 3006426 by Gil Gribb in Main branch]
371 lines
14 KiB
C++
371 lines
14 KiB
C++
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
#include "RendererPrivate.h"
|
|
|
|
#if WITH_EDITOR
|
|
|
|
#include "PostProcessCompositeEditorPrimitives.h"
|
|
#include "PostProcessing.h"
|
|
#include "SceneFilterRendering.h"
|
|
#include "SceneUtils.h"
|
|
|
|
|
|
// temporary
|
|
static TAutoConsoleVariable<float> CVarEditorOpaqueGizmo(
|
|
TEXT("r.Editor.OpaqueGizmo"),
|
|
0.0f,
|
|
TEXT("0..1\n0: occluded gizmo is partly transparent (default), 1:gizmo is never occluded"),
|
|
ECVF_RenderThreadSafe);
|
|
|
|
static TAutoConsoleVariable<float> CVarEditorMovingPattern(
|
|
TEXT("r.Editor.MovingPattern"),
|
|
1.0f,
|
|
TEXT("0:animation over time is off (default is 1)"),
|
|
ECVF_RenderThreadSafe);
|
|
|
|
/**
|
|
* Pixel shader for compositing editor primitives rendered
|
|
*/
|
|
template<uint32 MSAASampleCount>
|
|
class FPostProcessCompositeEditorPrimitivesPS : public FGlobalShader
|
|
{
|
|
DECLARE_SHADER_TYPE( FPostProcessCompositeEditorPrimitivesPS, Global )
|
|
|
|
static bool ShouldCache(EShaderPlatform Platform)
|
|
{
|
|
if(!IsFeatureLevelSupported(Platform, ERHIFeatureLevel::SM5))
|
|
{
|
|
if(MSAASampleCount > 1)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return IsPCPlatform(Platform);
|
|
}
|
|
|
|
static void ModifyCompilationEnvironment(EShaderPlatform Platform, FShaderCompilerEnvironment& OutEnvironment)
|
|
{
|
|
FGlobalShader::ModifyCompilationEnvironment(Platform, OutEnvironment);
|
|
OutEnvironment.SetDefine( TEXT("MSAA_SAMPLE_COUNT"), MSAASampleCount);
|
|
}
|
|
|
|
FPostProcessCompositeEditorPrimitivesPS() {}
|
|
|
|
public:
|
|
|
|
|
|
/** FPostProcessPassParameters constructor. */
|
|
FPostProcessCompositeEditorPrimitivesPS(const ShaderMetaType::CompiledShaderInitializerType& Initializer)
|
|
: FGlobalShader(Initializer)
|
|
{
|
|
PostProcessParameters.Bind(Initializer.ParameterMap);
|
|
DeferredParameters.Bind(Initializer.ParameterMap);
|
|
EditorPrimitivesDepth.Bind(Initializer.ParameterMap,TEXT("EditorPrimitivesDepth"));
|
|
EditorPrimitivesColor.Bind(Initializer.ParameterMap,TEXT("EditorPrimitivesColor"));
|
|
EditorPrimitivesColorSampler.Bind(Initializer.ParameterMap,TEXT("EditorPrimitivesColorSampler"));
|
|
EditorRenderParams.Bind(Initializer.ParameterMap,TEXT("EditorRenderParams"));
|
|
FilteredSceneDepthTexture.Bind(Initializer.ParameterMap,TEXT("FilteredSceneDepthTexture"));
|
|
FilteredSceneDepthTextureSampler.Bind(Initializer.ParameterMap,TEXT("FilteredSceneDepthTextureSampler"));
|
|
}
|
|
|
|
void SetParameters(const FRenderingCompositePassContext& Context)
|
|
{
|
|
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(Context.RHICmdList);
|
|
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader();
|
|
|
|
FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View);
|
|
|
|
DeferredParameters.Set(Context.RHICmdList, ShaderRHI, Context.View);
|
|
|
|
FSamplerStateRHIRef SamplerStateRHIRef = TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI();
|
|
PostProcessParameters.SetPS(ShaderRHI, Context, SamplerStateRHIRef);
|
|
if(MSAASampleCount > 1)
|
|
{
|
|
SetTextureParameter(Context.RHICmdList, ShaderRHI, EditorPrimitivesColor, SceneContext.EditorPrimitivesColor->GetRenderTargetItem().TargetableTexture);
|
|
SetTextureParameter(Context.RHICmdList, ShaderRHI, EditorPrimitivesDepth, SceneContext.EditorPrimitivesDepth->GetRenderTargetItem().TargetableTexture);
|
|
}
|
|
else
|
|
{
|
|
SetTextureParameter(Context.RHICmdList, ShaderRHI, EditorPrimitivesColor, EditorPrimitivesColorSampler, SamplerStateRHIRef, SceneContext.EditorPrimitivesColor->GetRenderTargetItem().ShaderResourceTexture);
|
|
SetTextureParameter(Context.RHICmdList, ShaderRHI, EditorPrimitivesDepth, SceneContext.EditorPrimitivesDepth->GetRenderTargetItem().ShaderResourceTexture);
|
|
}
|
|
|
|
{
|
|
FLinearColor Value(CVarEditorOpaqueGizmo.GetValueOnRenderThread(), CVarEditorMovingPattern.GetValueOnRenderThread(), 0, 0);
|
|
|
|
const FSceneViewFamily& ViewFamily = *(Context.View.Family);
|
|
|
|
if(ViewFamily.EngineShowFlags.Wireframe)
|
|
{
|
|
// no occlusion in wire frame rendering
|
|
Value.R = 1;
|
|
}
|
|
|
|
if(!ViewFamily.bRealtimeUpdate)
|
|
{
|
|
// no animation if realtime update is disabled
|
|
Value.G = 0;
|
|
}
|
|
|
|
SetShaderValue(Context.RHICmdList, ShaderRHI, EditorRenderParams, Value);
|
|
}
|
|
|
|
if(FilteredSceneDepthTexture.IsBound())
|
|
{
|
|
const FTexture2DRHIRef* DepthTexture = SceneContext.GetActualDepthTexture();
|
|
SetTextureParameter(
|
|
Context.RHICmdList,
|
|
ShaderRHI,
|
|
FilteredSceneDepthTexture,
|
|
FilteredSceneDepthTextureSampler,
|
|
TStaticSamplerState<SF_Bilinear,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(),
|
|
*DepthTexture
|
|
);
|
|
}
|
|
}
|
|
|
|
// FShader interface.
|
|
virtual bool Serialize(FArchive& Ar) override
|
|
{
|
|
bool bShaderHasOutdatedParameters = FGlobalShader::Serialize(Ar);
|
|
Ar << PostProcessParameters << EditorPrimitivesColor << EditorPrimitivesColorSampler << EditorPrimitivesDepth << DeferredParameters << EditorRenderParams;
|
|
Ar << FilteredSceneDepthTexture;
|
|
Ar << FilteredSceneDepthTextureSampler;
|
|
return bShaderHasOutdatedParameters;
|
|
}
|
|
|
|
private:
|
|
FShaderResourceParameter EditorPrimitivesColor;
|
|
FShaderResourceParameter EditorPrimitivesColorSampler;
|
|
FShaderResourceParameter EditorPrimitivesDepth;
|
|
FPostProcessPassParameters PostProcessParameters;
|
|
FDeferredPixelShaderParameters DeferredParameters;
|
|
FShaderParameter EditorRenderParams;
|
|
/** Parameter for reading filtered depth values */
|
|
FShaderResourceParameter FilteredSceneDepthTexture;
|
|
FShaderResourceParameter FilteredSceneDepthTextureSampler;
|
|
|
|
static const TCHAR* GetSourceFilename()
|
|
{
|
|
return TEXT("PostProcessCompositeEditorPrimitives");
|
|
}
|
|
|
|
static const TCHAR* GetFunctionName()
|
|
{
|
|
return TEXT("MainPS");
|
|
}
|
|
};
|
|
|
|
// #define avoids a lot of code duplication
|
|
#define VARIATION1(A) typedef FPostProcessCompositeEditorPrimitivesPS<A> FPostProcessCompositeEditorPrimitivesPS##A; \
|
|
IMPLEMENT_SHADER_TYPE2(FPostProcessCompositeEditorPrimitivesPS##A, SF_Pixel);
|
|
|
|
VARIATION1(1) VARIATION1(2) VARIATION1(4) VARIATION1(8)
|
|
#undef VARIATION1
|
|
|
|
|
|
template <uint32 MSAASampleCount>
|
|
static void SetCompositePrimitivesShaderTempl(const FRenderingCompositePassContext& Context)
|
|
{
|
|
const auto FeatureLevel = Context.GetFeatureLevel();
|
|
auto ShaderMap = Context.GetShaderMap();
|
|
|
|
TShaderMapRef<FPostProcessVS> VertexShader(ShaderMap);
|
|
TShaderMapRef<FPostProcessCompositeEditorPrimitivesPS<MSAASampleCount> > PixelShader(ShaderMap);
|
|
|
|
static FGlobalBoundShaderState BoundShaderState;
|
|
|
|
|
|
SetGlobalBoundShaderState(Context.RHICmdList, FeatureLevel, BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
|
|
|
|
VertexShader->SetParameters(Context);
|
|
PixelShader->SetParameters(Context);
|
|
}
|
|
|
|
void FRCPassPostProcessCompositeEditorPrimitives::Process(FRenderingCompositePassContext& Context)
|
|
{
|
|
SCOPED_DRAW_EVENT(Context.RHICmdList, CompositeEditorPrimitives);
|
|
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
|
|
|
|
if(!InputDesc)
|
|
{
|
|
// input is not hooked up correctly
|
|
return;
|
|
}
|
|
|
|
const FViewInfo& View = Context.View;
|
|
const FSceneViewFamily& ViewFamily = *(View.Family);
|
|
|
|
FIntRect SrcRect = View.ViewRect;
|
|
FIntRect DestRect = View.ViewRect;
|
|
FIntPoint SrcSize = InputDesc->Extent;
|
|
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(Context.RHICmdList);
|
|
|
|
// If we render wirframe we already started rendering to the EditorPrimitives buffer, so we don't want to clear it.
|
|
bool bClearIsNeeded = !IsValidRef(SceneContext.EditorPrimitivesColor);
|
|
|
|
// Get or create the msaa depth and color buffer
|
|
FTexture2DRHIRef ColorTarget = SceneContext.GetEditorPrimitivesColor(Context.RHICmdList);
|
|
FTexture2DRHIRef DepthTarget = SceneContext.GetEditorPrimitivesDepth(Context.RHICmdList);
|
|
|
|
FTextureRHIParamRef EditorRenderTargets[2];
|
|
EditorRenderTargets[0] = ColorTarget;
|
|
EditorRenderTargets[1] = DepthTarget;
|
|
|
|
const uint32 MSAASampleCount = SceneContext.EditorPrimitivesColor->GetDesc().NumSamples;
|
|
|
|
{
|
|
SetRenderTarget(Context.RHICmdList, ColorTarget, DepthTarget, ESimpleRenderTargetMode::EExistingColorAndDepth);
|
|
Context.SetViewportAndCallRHI(DestRect);
|
|
|
|
if (bClearIsNeeded)
|
|
{
|
|
SCOPED_DRAW_EVENT(Context.RHICmdList, ClearViewEditorPrimitives);
|
|
// Clear color and depth
|
|
Context.RHICmdList.Clear(true, FLinearColor(0, 0, 0, 0), true, (float)ERHIZBuffer::FarPlane, false, 0, FIntRect());
|
|
}
|
|
|
|
SCOPED_DRAW_EVENT(Context.RHICmdList, RenderEditorPrimitives);
|
|
|
|
Context.RHICmdList.SetRasterizerState(View.bReverseCulling ? TStaticRasterizerState<FM_Solid, CM_CW>::GetRHI() : TStaticRasterizerState<FM_Solid, CM_CCW>::GetRHI());
|
|
|
|
if (bDeferredBasePass)
|
|
{
|
|
RenderPrimitivesToComposite<FBasePassOpaqueDrawingPolicyFactory>(Context.RHICmdList, View);
|
|
}
|
|
else
|
|
{
|
|
RenderPrimitivesToComposite<FMobileBasePassOpaqueDrawingPolicyFactory>(Context.RHICmdList, View);
|
|
}
|
|
|
|
GRenderTargetPool.VisualizeTexture.SetCheckPoint(Context.RHICmdList, SceneContext.EditorPrimitivesColor);
|
|
Context.RHICmdList.TransitionResources(EResourceTransitionAccess::EReadable, EditorRenderTargets, 2);
|
|
}
|
|
|
|
// Context.RHICmdList.CopyToResolveTarget(SceneContext.EditorPrimitivesColor->GetRenderTargetItem().TargetableTexture, SceneContext.EditorPrimitivesColor->GetRenderTargetItem().ShaderResourceTexture, false, FResolveParams());
|
|
|
|
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
|
|
const FTexture2DRHIRef& DestRenderTargetSurface = (const FTexture2DRHIRef&)DestRenderTarget.TargetableTexture;
|
|
|
|
// Set the view family's render target/viewport.
|
|
SetRenderTarget(Context.RHICmdList, DestRenderTargetSurface, FTextureRHIRef());
|
|
|
|
Context.SetViewportAndCallRHI(DestRect);
|
|
|
|
// set the state
|
|
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
|
|
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
|
|
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
|
|
|
|
if(MSAASampleCount == 1)
|
|
{
|
|
SetCompositePrimitivesShaderTempl<1>(Context);
|
|
}
|
|
else if(MSAASampleCount == 2)
|
|
{
|
|
SetCompositePrimitivesShaderTempl<2>(Context);
|
|
}
|
|
else if(MSAASampleCount == 4)
|
|
{
|
|
SetCompositePrimitivesShaderTempl<4>(Context);
|
|
}
|
|
else if(MSAASampleCount == 8)
|
|
{
|
|
SetCompositePrimitivesShaderTempl<8>(Context);
|
|
}
|
|
else
|
|
{
|
|
// not supported, internal error
|
|
check(0);
|
|
}
|
|
|
|
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
|
|
|
|
// Draw a quad mapping our render targets to the view's render target
|
|
DrawRectangle(
|
|
Context.RHICmdList,
|
|
0, 0,
|
|
DestRect.Width(), DestRect.Height(),
|
|
SrcRect.Min.X, SrcRect.Min.Y,
|
|
SrcRect.Width(), SrcRect.Height(),
|
|
DestRect.Size(),
|
|
SrcSize,
|
|
*VertexShader,
|
|
EDRF_UseTriangleOptimization);
|
|
|
|
Context.RHICmdList.CopyToResolveTarget(DestRenderTargetSurface, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
|
|
|
|
// Clean up targets
|
|
SceneContext.CleanUpEditorPrimitiveTargets();
|
|
}
|
|
|
|
FPooledRenderTargetDesc FRCPassPostProcessCompositeEditorPrimitives::ComputeOutputDesc(EPassOutputId InPassOutputId) const
|
|
{
|
|
FPooledRenderTargetDesc Ret = GetInput(ePId_Input0)->GetOutput()->RenderTargetDesc;
|
|
|
|
Ret.Reset();
|
|
Ret.DebugName = TEXT("EditorPrimitives");
|
|
|
|
return Ret;
|
|
}
|
|
|
|
template<typename TBasePass>
|
|
void FRCPassPostProcessCompositeEditorPrimitives::RenderPrimitivesToComposite(FRHICommandListImmediate& RHICmdList, const FViewInfo& View)
|
|
{
|
|
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(RHICmdList);
|
|
|
|
// Always depth test against other editor primitives
|
|
RHICmdList.SetDepthStencilState(TStaticDepthStencilState<true, CF_DepthNearOrEqual>::GetRHI());
|
|
RHICmdList.SetBlendState(TStaticBlendStateWriteMask<CW_RGBA>::GetRHI());
|
|
|
|
// most objects should be occluded by the existing scene so we do a manual depth test in the shader
|
|
bool bDepthTest = true;
|
|
|
|
const auto FeatureLevel = View.GetFeatureLevel();
|
|
const auto ShaderPlatform = GShaderPlatformForFeatureLevel[FeatureLevel];
|
|
const bool bNeedToSwitchVerticalAxis = RHINeedsToSwitchVerticalAxis(ShaderPlatform);
|
|
FTexture2DRHIRef SceneDepth = SceneContext.GetSceneDepthTexture();
|
|
|
|
typename TBasePass::ContextType Context(true, ESceneRenderTargetsMode::SetTextures);
|
|
|
|
for (int32 MeshBatchIndex = 0; MeshBatchIndex < View.DynamicEditorMeshElements.Num(); MeshBatchIndex++)
|
|
{
|
|
const FMeshBatchAndRelevance& MeshBatchAndRelevance = View.DynamicEditorMeshElements[MeshBatchIndex];
|
|
|
|
if (MeshBatchAndRelevance.GetHasOpaqueOrMaskedMaterial() || View.Family->EngineShowFlags.Wireframe)
|
|
{
|
|
const FMeshBatch& MeshBatch = *MeshBatchAndRelevance.Mesh;
|
|
TBasePass::DrawDynamicMesh(RHICmdList, View, Context, MeshBatch, false, true, MeshBatchAndRelevance.PrimitiveSceneProxy, MeshBatch.BatchHitProxyId);
|
|
}
|
|
}
|
|
|
|
View.EditorSimpleElementCollector.DrawBatchedElements(RHICmdList, View, SceneContext.GetSceneDepthTexture(), EBlendModeFilter::OpaqueAndMasked);
|
|
|
|
// Draw the base pass for the view's batched mesh elements.
|
|
DrawViewElements<TBasePass>(RHICmdList, View, typename TBasePass::ContextType(bDepthTest, ESceneRenderTargetsMode::SetTextures), SDPG_World, false);
|
|
|
|
// Draw the view's batched simple elements(lines, sprites, etc).
|
|
View.BatchedViewElements.Draw(RHICmdList, FeatureLevel, bNeedToSwitchVerticalAxis, View.ViewProjectionMatrix, View.ViewRect.Width(), View.ViewRect.Height(), false, 1.0f, &View, SceneDepth);
|
|
|
|
// Draw foreground objects. Draw twice, once without depth testing to bring them into the foreground and again to depth test against themselves
|
|
{
|
|
// Do not test against non-composited objects
|
|
bDepthTest = false;
|
|
|
|
RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
|
|
|
|
DrawViewElements<TBasePass>(RHICmdList, View, typename TBasePass::ContextType(bDepthTest, ESceneRenderTargetsMode::SetTextures), SDPG_Foreground, false);
|
|
|
|
View.TopBatchedViewElements.Draw(RHICmdList, FeatureLevel, bNeedToSwitchVerticalAxis, View.ViewProjectionMatrix, View.ViewRect.Width(), View.ViewRect.Height(), false);
|
|
|
|
RHICmdList.SetDepthStencilState(TStaticDepthStencilState<true, CF_DepthNearOrEqual>::GetRHI());
|
|
|
|
DrawViewElements<TBasePass>(RHICmdList, View, typename TBasePass::ContextType(bDepthTest, ESceneRenderTargetsMode::SetTextures), SDPG_Foreground, false);
|
|
|
|
View.TopBatchedViewElements.Draw(RHICmdList, FeatureLevel, bNeedToSwitchVerticalAxis, View.ViewProjectionMatrix, View.ViewRect.Width(), View.ViewRect.Height(), false);
|
|
}
|
|
}
|
|
|
|
#endif |