@@ -374,10 +374,14 @@ void MobileBasePass::SetOpaqueRenderState(FMeshPassProcessorRenderState& DrawRen
374
374
}
375
375
}
376
376
377
- void MobileBasePass::SetTranslucentRenderState (FMeshPassProcessorRenderState& DrawRenderState, const FMaterial& Material)
377
+ void MobileBasePass::SetTranslucentRenderState (FMeshPassProcessorRenderState& DrawRenderState, const FMaterial& Material, ETranslucencyPass::Type InTranslucencyPassType )
378
378
{
379
379
const bool bIsUsingMobilePixelProjectedReflection = Material.IsUsingPlanarForwardReflections () && IsUsingMobilePixelProjectedReflection (GetFeatureLevelShaderPlatform (Material.GetFeatureLevel ()));
380
380
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
+
381
385
if (Material.GetShadingModels ().HasShadingModel (MSM_ThinTranslucent))
382
386
{
383
387
// 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
394
398
}
395
399
else
396
400
{
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 ());
398
404
}
399
405
break ;
400
406
case BLEND_Additive:
401
407
// 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 ());
403
411
break ;
404
412
case BLEND_Modulate:
405
413
// 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 ());
407
417
break ;
408
418
case BLEND_AlphaComposite:
409
419
// 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 ());
411
423
break ;
412
424
case BLEND_AlphaHoldout:
413
425
// Blend by holding out the matte shape of the source alpha
@@ -657,8 +669,8 @@ void FMobileBasePassMeshProcessor::AddMeshBatch(const FMeshBatch& RESTRICT MeshB
657
669
// Skipping TPT_TranslucencyAfterDOFModulate. That pass is only needed for Dual Blending, which is not supported on Mobile.
658
670
bool bShouldDraw = (bIsTranslucent || bUsesWaterMaterial || bIsUsingMobilePixelProjectedReflection) &&
659
671
(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);
662
674
663
675
if (bShouldDraw)
664
676
{
@@ -735,7 +747,7 @@ void FMobileBasePassMeshProcessor::Process(
735
747
{
736
748
if (bTranslucentBasePass)
737
749
{
738
- MobileBasePass::SetTranslucentRenderState (DrawRenderState, MaterialResource);
750
+ MobileBasePass::SetTranslucentRenderState (DrawRenderState, MaterialResource, TranslucencyPassType );
739
751
}
740
752
else if (bMaskedInEarlyPass)
741
753
{
0 commit comments