@@ -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 {
0 commit comments