Skip to content

Commit ea695b6

Browse files
author
YOung
committed
Support SeparateTranslucencyScreenPercentage on mobile platforms.
1 parent 1a24cb3 commit ea695b6

32 files changed

+406
-192
lines changed

Engine/Shaders/Private/DownsampleDepthPixelShader.usf

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define DOWNSAMPLE_DEPTH_FILTER_CBMINMAX 2
1414

1515
Texture2D<float> DepthTexture;
16+
SamplerState DepthTexturePointClampedSampler;
1617
float4 SourceTexelOffsets01;
1718
float4 SourceTexelOffsets23;
1819
float2 SourceMaxUV;
@@ -21,7 +22,7 @@ uint DownsampleDepthFilter;
2122

2223
float GetDeviceZ(float2 UV)
2324
{
24-
return DepthTexture.Sample(GlobalPointClampedSampler, min(UV, SourceMaxUV));
25+
return DepthTexture.Sample(DepthTexturePointClampedSampler, min(UV, SourceMaxUV));
2526
}
2627

2728
void Main(

Engine/Shaders/Private/SeparateTranslucency.ush

+8-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
Texture2D<float> LowResDepthTexture;
1010
Texture2D<float> FullResDepthTexture;
1111

12+
SamplerState PointClampedSampler;
13+
SamplerState BilinearClampedSampler;
14+
1215
void UpdateNearestSample(float Z, float2 UV, float FullResZ, inout float MinDist, inout float2 NearestUV)
1316
{
1417
float DepthDelta = abs(Z - FullResZ);
@@ -23,7 +26,7 @@ void UpdateNearestSample(float Z, float2 UV, float FullResZ, inout float MinDist
2326

2427
float4 BilinearUpsampling(float2 UV, Texture2D LowResTex)
2528
{
26-
return Texture2DSample(LowResTex, GlobalBilinearClampedSampler, UV);
29+
return Texture2DSample(LowResTex, BilinearClampedSampler, UV);
2730
}
2831

2932
float4 NearestDepthNeighborUpsampling(float2 Position, float2 UV, Texture2D LowResTex, float2 LowResTexelSize)
@@ -35,7 +38,7 @@ float4 NearestDepthNeighborUpsampling(float2 Position, float2 UV, Texture2D LowR
3538
float MaxOperationDepth = 2000000.0f;
3639

3740
// Note: this upsample is specialized for half res to full res
38-
float4 LowResDepthBuffer = LowResDepthTexture.GatherRed(GlobalBilinearClampedSampler, UV);
41+
float4 LowResDepthBuffer = LowResDepthTexture.GatherRed(BilinearClampedSampler, UV);
3942
float4 LowResDepth = min(float4(ConvertFromDeviceZ(LowResDepthBuffer.x), ConvertFromDeviceZ(LowResDepthBuffer.y), ConvertFromDeviceZ(LowResDepthBuffer.z), ConvertFromDeviceZ(LowResDepthBuffer.w)), MaxOperationDepth.xxxx);
4043
float FullResDepth = min(ConvertFromDeviceZ(FullResDepthTexture[uint2(Position.xy)].x), MaxOperationDepth);
4144

@@ -66,18 +69,18 @@ float4 NearestDepthNeighborUpsampling(float2 Position, float2 UV, Texture2D LowR
6669
&& abs(LowResDepth.x - FullResDepth) * InvFullResDepth < RelativeDepthThreshold
6770
&& abs(LowResDepth.y - FullResDepth) * InvFullResDepth < RelativeDepthThreshold)
6871
{
69-
Output = Texture2DSampleLevel(LowResTex, GlobalBilinearClampedSampler, UV, 0);
72+
Output = Texture2DSampleLevel(LowResTex, BilinearClampedSampler, UV, 0);
7073
}
7174
else
7275
{
73-
Output = Texture2DSampleLevel(LowResTex, GlobalPointClampedSampler, NearestUV, 0);
76+
Output = Texture2DSampleLevel(LowResTex, PointClampedSampler, NearestUV, 0);
7477
}
7578

7679
return Output;
7780

7881
#else
7982

80-
return Texture2DSample(LowResTex, GlobalBilinearClampedSampler, UV);
83+
return Texture2DSample(LowResTex, BilinearClampedSampler, UV);
8184

8285
#endif
8386
}

Engine/Source/Runtime/Engine/Private/Materials/MaterialInterface.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ FMaterialRelevance UMaterialInterface::GetRelevance_Internal(const UMaterial* Ma
211211
{
212212
// Check whether the material can be drawn in the separate translucency pass as per FMaterialResource::IsTranslucencyAfterDOFEnabled and IsMobileSeparateTranslucencyEnabled
213213
bool bSupportsSeparateTranslucency = Material->MaterialDomain != MD_UI && Material->MaterialDomain != MD_DeferredDecal;
214-
bool bMaterialSeparateTranslucency = bSupportsSeparateTranslucency && (bIsMobile ? Material->bEnableMobileSeparateTranslucency : Material->bEnableSeparateTranslucency);
214+
bool bMaterialSeparateTranslucency = bSupportsSeparateTranslucency && Material->bEnableSeparateTranslucency;
215215

216216
// If dual blending is supported, and we are rendering separate translucency, then we also need to render a second pass to the modulation buffer.
217217
// The modulation buffer can also be used for regular modulation shaders after DoF.

Engine/Source/Runtime/Renderer/Private/DepthRendering.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "ClearQuad.h"
2929
#include "GPUSkinCache.h"
3030
#include "MeshPassProcessor.inl"
31+
#include "MobileShadingRenderer.h"
3132

3233
static TAutoConsoleVariable<int32> CVarParallelPrePass(
3334
TEXT("r.ParallelPrePass"),

Engine/Source/Runtime/Renderer/Private/EditorPrimitivesRendering.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void FEditorPrimitivesBasePassMeshProcessor::ProcessMobileShadingPath(const FMes
134134

135135
if (bTranslucentBasePass)
136136
{
137-
MobileBasePass::SetTranslucentRenderState(DrawRenderState, Material);
137+
MobileBasePass::SetTranslucentRenderState(DrawRenderState, Material, ETranslucencyPass::TPT_AllTranslucency);
138138
}
139139

140140
const FMeshDrawingPolicyOverrideSettings OverrideSettings = ComputeMeshOverrideSettings(MeshBatch);

Engine/Source/Runtime/Renderer/Private/MobileBasePass.cpp

+20-8
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,14 @@ void MobileBasePass::SetOpaqueRenderState(FMeshPassProcessorRenderState& DrawRen
374374
}
375375
}
376376

377-
void MobileBasePass::SetTranslucentRenderState(FMeshPassProcessorRenderState& DrawRenderState, const FMaterial& Material)
377+
void MobileBasePass::SetTranslucentRenderState(FMeshPassProcessorRenderState& DrawRenderState, const FMaterial& Material, ETranslucencyPass::Type InTranslucencyPassType)
378378
{
379379
const bool bIsUsingMobilePixelProjectedReflection = Material.IsUsingPlanarForwardReflections() && IsUsingMobilePixelProjectedReflection(GetFeatureLevelShaderPlatform(Material.GetFeatureLevel()));
380380

381+
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.SeparateTranslucencyScreenPercentage"));
382+
const float DownsampleScale = CVar ? FMath::Clamp(CVar->GetValueOnRenderThread() / 100.0f, 0.0f, 1.0f) : 1.0f;
383+
const bool bSeparateTranslucencyActive = IsMobileSeparateTranslucencyColorTextureEnabled(InTranslucencyPassType, DownsampleScale);
384+
381385
if (Material.GetShadingModels().HasShadingModel(MSM_ThinTranslucent))
382386
{
383387
// the mobile thin translucent fallback uses a similar mode as BLEND_Translucent, but multiplies color by 1 insead of SrcAlpha.
@@ -394,20 +398,28 @@ void MobileBasePass::SetTranslucentRenderState(FMeshPassProcessorRenderState& Dr
394398
}
395399
else
396400
{
397-
DrawRenderState.SetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_SourceAlpha, BF_InverseSourceAlpha, BO_Add, BF_Zero, BF_InverseSourceAlpha>::GetRHI());
401+
bSeparateTranslucencyActive
402+
? DrawRenderState.SetBlendState(TStaticBlendState<CW_RGBA, BO_Add, BF_SourceAlpha, BF_InverseSourceAlpha, BO_Add, BF_Zero, BF_InverseSourceAlpha>::GetRHI())
403+
: DrawRenderState.SetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_SourceAlpha, BF_InverseSourceAlpha, BO_Add, BF_Zero, BF_InverseSourceAlpha>::GetRHI());
398404
}
399405
break;
400406
case BLEND_Additive:
401407
// Add to the existing scene color
402-
DrawRenderState.SetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_One, BF_One, BO_Add, BF_Zero, BF_InverseSourceAlpha>::GetRHI());
408+
bSeparateTranslucencyActive
409+
? DrawRenderState.SetBlendState(TStaticBlendState<CW_RGBA, BO_Add, BF_One, BF_One, BO_Add, BF_Zero, BF_InverseSourceAlpha>::GetRHI())
410+
: DrawRenderState.SetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_One, BF_One, BO_Add, BF_Zero, BF_InverseSourceAlpha>::GetRHI());
403411
break;
404412
case BLEND_Modulate:
405413
// Modulate with the existing scene color
406-
DrawRenderState.SetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_DestColor, BF_Zero>::GetRHI());
414+
bSeparateTranslucencyActive
415+
? DrawRenderState.SetBlendState(TStaticBlendState<CW_RGBA, BO_Add, BF_DestColor, BF_Zero>::GetRHI())
416+
: DrawRenderState.SetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_DestColor, BF_Zero>::GetRHI());
407417
break;
408418
case BLEND_AlphaComposite:
409419
// Blend with existing scene color. New color is already pre-multiplied by alpha.
410-
DrawRenderState.SetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_One, BF_InverseSourceAlpha, BO_Add, BF_Zero, BF_InverseSourceAlpha>::GetRHI());
420+
bSeparateTranslucencyActive
421+
? DrawRenderState.SetBlendState(TStaticBlendState<CW_RGBA, BO_Add, BF_One, BF_InverseSourceAlpha, BO_Add, BF_Zero, BF_InverseSourceAlpha>::GetRHI())
422+
: DrawRenderState.SetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_One, BF_InverseSourceAlpha, BO_Add, BF_Zero, BF_InverseSourceAlpha>::GetRHI());
411423
break;
412424
case BLEND_AlphaHoldout:
413425
// Blend by holding out the matte shape of the source alpha
@@ -657,8 +669,8 @@ void FMobileBasePassMeshProcessor::AddMeshBatch(const FMeshBatch& RESTRICT MeshB
657669
// Skipping TPT_TranslucencyAfterDOFModulate. That pass is only needed for Dual Blending, which is not supported on Mobile.
658670
bool bShouldDraw = (bIsTranslucent || bUsesWaterMaterial || bIsUsingMobilePixelProjectedReflection) &&
659671
(TranslucencyPassType == ETranslucencyPass::TPT_AllTranslucency
660-
|| (TranslucencyPassType == ETranslucencyPass::TPT_StandardTranslucency && !Material.IsMobileSeparateTranslucencyEnabled())
661-
|| (TranslucencyPassType == ETranslucencyPass::TPT_TranslucencyAfterDOF && Material.IsMobileSeparateTranslucencyEnabled()));
672+
|| TranslucencyPassType == ETranslucencyPass::TPT_StandardTranslucency
673+
|| TranslucencyPassType == ETranslucencyPass::TPT_TranslucencyAfterDOF);
662674

663675
if (bShouldDraw)
664676
{
@@ -735,7 +747,7 @@ void FMobileBasePassMeshProcessor::Process(
735747
{
736748
if (bTranslucentBasePass)
737749
{
738-
MobileBasePass::SetTranslucentRenderState(DrawRenderState, MaterialResource);
750+
MobileBasePass::SetTranslucentRenderState(DrawRenderState, MaterialResource, TranslucencyPassType);
739751
}
740752
else if (bMaskedInEarlyPass)
741753
{

Engine/Source/Runtime/Renderer/Private/MobileBasePassRendering.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "FramePro/FrameProProfiler.h"
1919
#include "PostProcess/PostProcessPixelProjectedReflectionMobile.h"
20+
#include "MobileShadingRenderer.h"
2021

2122
// Changing this causes a full shader recompile
2223
static TAutoConsoleVariable<int32> CVarMobileDisableVertexFog(

Engine/Source/Runtime/Renderer/Private/MobileBasePassRendering.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ namespace MobileBasePass
353353
bool StaticCanReceiveCSM(const FLightSceneInfo* LightSceneInfo, const FPrimitiveSceneProxy* PrimitiveSceneProxy);
354354

355355
void SetOpaqueRenderState(FMeshPassProcessorRenderState& DrawRenderState, const FPrimitiveSceneProxy* PrimitiveSceneProxy, const FMaterial& Material, bool bEnableReceiveDecalOutput, bool bUsesDeferredShading);
356-
void SetTranslucentRenderState(FMeshPassProcessorRenderState& DrawRenderState, const FMaterial& Material);
356+
void SetTranslucentRenderState(FMeshPassProcessorRenderState& DrawRenderState, const FMaterial& Material, ETranslucencyPass::Type InTranslucencyPassType);
357357

358358
bool StationarySkyLightHasBeenApplied(const FScene* Scene, ELightMapPolicyType LightMapPolicyType);
359359
};

Engine/Source/Runtime/Renderer/Private/MobileDecalRendering.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "SceneRendering.h"
1515
#include "ScenePrivate.h"
1616
#include "DecalRenderingShared.h"
17+
#include "MobileShadingRenderer.h"
1718

1819
extern FRHIRasterizerState* GetDecalRasterizerState(EDecalRasterizerState DecalRasterizerState);
1920
extern void RenderMeshDecalsMobile(FRHICommandList& RHICmdList, const FViewInfo& View);

Engine/Source/Runtime/Renderer/Private/MobileSceneCaptureRendering.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ MobileSceneCaptureRendering.cpp - Mobile specific scene capture code.
2828
#include "PipelineStateCache.h"
2929
#include "CommonRenderResources.h"
3030
#include "GenerateMips.h"
31+
#include "MobileShadingRenderer.h"
3132

3233
/**
3334
* Shader set for the copy of scene color to capture target, alpha channel will contain opacity information. (Determined from depth buffer content)

Engine/Source/Runtime/Renderer/Private/MobileSeparateTranslucencyPass.cpp

+46-17
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,67 @@ MobileSeparateTranslucencyPass.cpp - Mobile specific separate translucency pass
77
#include "MobileSeparateTranslucencyPass.h"
88
#include "TranslucentRendering.h"
99
#include "DynamicPrimitiveDrawing.h"
10+
#include "MobileShadingRenderer.h"
1011

11-
bool IsMobileSeparateTranslucencyActive(const FViewInfo* Views, int32 NumViews)
12+
bool IsMobileTranslucencyAfterDOFActive(const FViewInfo* Views, int32 NumViews)
1213
{
1314
for (int32 ViewIdx = 0; ViewIdx < NumViews; ++ViewIdx)
1415
{
15-
if (IsMobileSeparateTranslucencyActive(Views[ViewIdx]))
16+
if (IsMobileTranslucencyAfterDOFActive(Views[ViewIdx]))
1617
{
1718
return true;
1819
}
1920
}
2021
return false;
2122
}
2223

23-
bool IsMobileSeparateTranslucencyActive(const FViewInfo& View)
24+
bool IsMobileTranslucencyAfterDOFActive(const FViewInfo& View)
2425
{
2526
return View.ParallelMeshDrawCommandPasses[EMeshPass::TranslucencyAfterDOF].HasAnyDraw();
2627
}
2728

28-
void AddMobileSeparateTranslucencyPass(FRDGBuilder& GraphBuilder, const FViewInfo& View, const FMobileSeparateTranslucencyInputs& Inputs)
29+
bool IsMobileTranslucencyStandardActive(const FViewInfo* Views, int32 NumViews)
2930
{
30-
FRenderTargetParameters* PassParameters = GraphBuilder.AllocParameters<FRenderTargetParameters>();
31-
PassParameters->RenderTargets[0] = FRenderTargetBinding(Inputs.SceneColor.Texture, ERenderTargetLoadAction::ELoad);
32-
PassParameters->RenderTargets.DepthStencil = FDepthStencilBinding(Inputs.SceneDepth.Texture, ERenderTargetLoadAction::ELoad, ERenderTargetLoadAction::ELoad, FExclusiveDepthStencil::DepthRead_StencilRead);
33-
34-
GraphBuilder.AddPass(
35-
RDG_EVENT_NAME("SeparateTranslucency %dx%d", View.ViewRect.Width(), View.ViewRect.Height()),
36-
PassParameters,
37-
ERDGPassFlags::Raster,
38-
[&View](FRHICommandList& RHICmdList)
31+
for (int32 ViewIdx = 0; ViewIdx < NumViews; ++ViewIdx)
32+
{
33+
if (IsMobileTranslucencyStandardActive(Views[ViewIdx]))
34+
{
35+
return true;
36+
}
37+
}
38+
return false;
39+
}
40+
41+
bool IsMobileTranslucencyStandardActive(const FViewInfo& View)
42+
{
43+
return View.ParallelMeshDrawCommandPasses[EMeshPass::TranslucencyStandard].HasAnyDraw();
44+
}
45+
46+
void FMobileSceneRenderer::AddMobileSeparateTranslucencyPass(FRDGBuilder& GraphBuilder, const FViewInfo& View, const FMobileSeparateTranslucencyInputs& Inputs)
47+
{
48+
FSeparateTranslucencyDimensions SeparateTranslucencyDimensions = SeparateTranslucencyTextures.GetDimensions();
49+
50+
if (IsMobileSeparateTranslucencyColorTextureEnabled(ETranslucencyPass::TPT_TranslucencyAfterDOF, SeparateTranslucencyDimensions.Scale))
3951
{
40-
// Set the view family's render target/viewport.
41-
RHICmdList.SetViewport(View.ViewRect.Min.X, View.ViewRect.Min.Y, 0.0f, View.ViewRect.Max.X, View.ViewRect.Max.Y, 1.0f);
42-
View.ParallelMeshDrawCommandPasses[EMeshPass::TranslucencyAfterDOF].DispatchDraw(nullptr, RHICmdList);
43-
});
52+
FRDGTextureRef SceneColorTexture = Inputs.SceneColor.Texture;
53+
FRDGTextureRef SceneDepthTexture = Inputs.SceneDepth.Texture;
54+
RenderSeparateTranslucency(GraphBuilder, SceneColorTexture, SceneDepthTexture, SeparateTranslucencyTextures, ETranslucencyPass::TPT_TranslucencyAfterDOF, View);
55+
}
56+
else
57+
{
58+
FRenderTargetParameters* PassParameters = GraphBuilder.AllocParameters<FRenderTargetParameters>();
59+
PassParameters->RenderTargets[0] = FRenderTargetBinding(Inputs.SceneColor.Texture, ERenderTargetLoadAction::ELoad);
60+
PassParameters->RenderTargets.DepthStencil = FDepthStencilBinding(Inputs.SceneDepth.Texture, ERenderTargetLoadAction::ELoad, ERenderTargetLoadAction::ELoad, FExclusiveDepthStencil::DepthRead_StencilRead);
61+
62+
GraphBuilder.AddPass(
63+
RDG_EVENT_NAME("SeparateTranslucency %dx%d", View.ViewRect.Width(), View.ViewRect.Height()),
64+
PassParameters,
65+
ERDGPassFlags::Raster,
66+
[&View](FRHICommandList& RHICmdList)
67+
{
68+
// Set the view family's render target/viewport.
69+
RHICmdList.SetViewport(View.ViewRect.Min.X, View.ViewRect.Min.Y, 0.0f, View.ViewRect.Max.X, View.ViewRect.Max.Y, 1.0f);
70+
View.ParallelMeshDrawCommandPasses[EMeshPass::TranslucencyAfterDOF].DispatchDraw(nullptr, RHICmdList);
71+
});
72+
}
4473
}

Engine/Source/Runtime/Renderer/Private/MobileSeparateTranslucencyPass.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ struct FMobileSeparateTranslucencyInputs
1111
FScreenPassTexture SceneDepth;
1212
};
1313

14-
void AddMobileSeparateTranslucencyPass(FRDGBuilder& GraphBuilder, const FViewInfo& View, const FMobileSeparateTranslucencyInputs& Inputs);
15-
1614
// Returns whether separate translucency is enabled and there primitives to draw in the view
17-
bool IsMobileSeparateTranslucencyActive(const FViewInfo& View);
18-
bool IsMobileSeparateTranslucencyActive(const FViewInfo* Views, int32 NumViews);
15+
bool IsMobileTranslucencyAfterDOFActive(const FViewInfo& View);
16+
bool IsMobileTranslucencyAfterDOFActive(const FViewInfo* Views, int32 NumViews);
17+
bool IsMobileTranslucencyStandardActive(const FViewInfo& View);
18+
bool IsMobileTranslucencyStandardActive(const FViewInfo* Views, int32 NumViews);

Engine/Source/Runtime/Renderer/Private/MobileShadingRenderer.cpp

+21-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
MobileShadingRenderer.cpp: Scene rendering code for ES3/3.1 feature level.
55
=============================================================================*/
66

7+
#include "MobileShadingRenderer.h"
78
#include "CoreMinimal.h"
89
#include "Stats/Stats.h"
910
#include "Misc/MemStack.h"
@@ -385,7 +386,9 @@ void FMobileSceneRenderer::InitViews(FRHICommandListImmediate& RHICmdList)
385386
// On PowerVR we see flickering of shadows and depths not updating correctly if targets are discarded.
386387
// See CVarMobileForceDepthResolve use in ConditionalResolveSceneDepth.
387388
const bool bForceDepthResolve = (CVarMobileForceDepthResolve.GetValueOnRenderThread() == 1);
388-
const bool bSeparateTranslucencyActive = IsMobileSeparateTranslucencyActive(Views.GetData(), Views.Num());
389+
const bool bSeparateTranslucencyActive = ViewFamily.AllowTranslucencyAfterDOF() && SeparateTranslucencyTextures.GetDimensions().Scale < 1.0f
390+
&& IsMobileTranslucencyStandardActive(Views.GetData(), Views.Num())
391+
|| IsMobileTranslucencyAfterDOFActive(Views.GetData(), Views.Num());
389392
const bool bShouldRenderVelocities = ShouldRenderVelocities();
390393
bRequiresMultiPass = RequiresMultiPass(RHICmdList, Views[0]);
391394
bKeepDepthContent =
@@ -565,6 +568,8 @@ void FMobileSceneRenderer::InitViews(FRHICommandListImmediate& RHICmdList)
565568
}
566569
}
567570

571+
SeparateTranslucencyTextures = UpdateTranslucencyTimers(RHICmdList, Views);
572+
568573
if (bDeferredShading)
569574
{
570575
SetupSceneReflectionCaptureBuffer(RHICmdList);
@@ -1105,8 +1110,9 @@ FRHITexture* FMobileSceneRenderer::RenderForward(FRHICommandListImmediate& RHICm
11051110
}
11061111
}
11071112

1113+
bool bSeparateTranslucency = SeparateTranslucencyTextures.GetDimensions().Scale < 1.0f;
11081114
// Draw translucency.
1109-
if (ViewFamily.EngineShowFlags.Translucency)
1115+
if (ViewFamily.EngineShowFlags.Translucency && !bSeparateTranslucency)
11101116
{
11111117
CSV_SCOPED_TIMING_STAT_EXCLUSIVE(RenderTranslucency);
11121118
SCOPE_CYCLE_COUNTER(STAT_TranslucencyDrawTime);
@@ -1135,6 +1141,19 @@ FRHITexture* FMobileSceneRenderer::RenderForward(FRHICommandListImmediate& RHICm
11351141
// End of scene color rendering
11361142
RHICmdList.EndRenderPass();
11371143

1144+
// Draw separate translucency.
1145+
if (ViewFamily.EngineShowFlags.Translucency && bSeparateTranslucency)
1146+
{
1147+
CSV_SCOPED_TIMING_STAT_EXCLUSIVE(RenderTranslucency);
1148+
SCOPE_CYCLE_COUNTER(STAT_TranslucencyDrawTime);
1149+
1150+
FRDGBuilder GraphBuilder(RHICmdList);
1151+
FRDGTextureRef SceneColorTexture = GraphBuilder.RegisterExternalTexture(SceneContext.GetSceneColor());
1152+
FRDGTextureRef SceneDepthTexture = GraphBuilder.RegisterExternalTexture(SceneContext.SceneDepthZ);
1153+
RenderSeparateTranslucency(GraphBuilder, SceneColorTexture, SceneDepthTexture, SeparateTranslucencyTextures, ETranslucencyPass::TPT_StandardTranslucency, View);
1154+
GraphBuilder.Execute();
1155+
}
1156+
11381157
return SceneColorResolve ? SceneColorResolve : SceneColor;
11391158
}
11401159

0 commit comments

Comments
 (0)