r.Translucency.ScreenPercentage.Basis
r.Translucency.ScreenPercentage.Basis
#Overview
name: r.Translucency.ScreenPercentage.Basis
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Basis of the translucency\'s screen percentage (Experimental).\n 0: Uses the primary view\'s resolution (notably scaling with r.ScreenPercentage and r.DynamicRes.*)\n 1: Uses the secondary view\'s resolution (temporal upscale\'s output resolution)
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Translucency.ScreenPercentage.Basis is to determine the basis for calculating the screen percentage of translucent objects in Unreal Engine’s rendering system. It is used to control how the resolution of translucent objects scales in relation to the overall screen resolution.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically in the translucent rendering subsystem. It also affects the ImgMedia plugin and the MediaPlate plugin.
The value of this variable is set through a console variable (CVar) system. It can be set to either 0 or 1:
- 0: Uses the primary view’s resolution (scaling with r.ScreenPercentage and r.DynamicRes.*)
- 1: Uses the secondary view’s resolution (temporal upscale’s output resolution)
The associated variable CVarTranslucencyScreenPercentageBasis interacts directly with r.Translucency.ScreenPercentage.Basis. They share the same value and are used interchangeably in the code.
Developers should be aware that changing this variable can affect the resolution and performance of translucent objects in the scene. When set to 1, it can impact how dynamic resolution scaling is applied to translucent objects.
Best practices when using this variable include:
- Consider the performance implications when changing this value, especially in projects with many translucent objects.
- Be aware that setting this to 1 may require additional configuration for certain features, such as media plates with overlay materials.
- Test thoroughly after changing this value to ensure desired visual quality and performance.
Regarding the associated variable CVarTranslucencyScreenPercentageBasis:
The purpose of CVarTranslucencyScreenPercentageBasis is to provide a programmatic way to access and modify the r.Translucency.ScreenPercentage.Basis setting within C++ code.
This variable is used in the same subsystems as r.Translucency.ScreenPercentage.Basis, primarily in the Renderer module for translucent rendering calculations.
The value of CVarTranslucencyScreenPercentageBasis is set and accessed through the Unreal Engine’s console variable system, allowing for runtime modifications.
It interacts directly with r.Translucency.ScreenPercentage.Basis, effectively serving as its C++ representation.
Developers should be aware that modifying CVarTranslucencyScreenPercentageBasis will have the same effects as changing r.Translucency.ScreenPercentage.Basis. It’s important to consider the performance and visual implications of these changes.
Best practices for using CVarTranslucencyScreenPercentageBasis include:
- Use it for programmatic access to the translucency screen percentage basis setting.
- Be cautious when modifying its value at runtime, as it can affect rendering performance.
- Consider using it in conjunction with other dynamic resolution and translucency settings for fine-tuned control over rendering quality and performance.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:43
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarTranslucencyScreenPercentageBasis(
TEXT("r.Translucency.ScreenPercentage.Basis"), 0,
TEXT("Basis of the translucency's screen percentage (Experimental).\n")
TEXT(" 0: Uses the primary view's resolution (notably scaling with r.ScreenPercentage and r.DynamicRes.*)\n")
TEXT(" 1: Uses the secondary view's resolution (temporal upscale's output resolution)"),
ECVF_Scalability | ECVF_Default);
static TAutoConsoleVariable<float> CVarTranslucencyMinScreenPercentage(
#Loc: <Workspace>/Engine/Plugins/Media/ImgMedia/Source/ImgMedia/Private/ImgMediaSceneViewExtension.cpp:154
Scope (from outer to inner):
file
function void FImgMediaSceneViewExtension::CacheViewInfo
Source code excerpt:
* This ensures that mip estimation covers both regular and upscaled resolutions. It may not be the most efficient solve, but by far the safest and simplest.
*/
static const auto CVarTranslucencySPBasis = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Translucency.ScreenPercentage.Basis"));
if (CVarTranslucencySPBasis && CVarTranslucencySPBasis->GetInt() == 1)
{
FImgMediaViewInfo PostUpscaleVirtualInfo = Info;
// Note: This is equivalent to FViewInfo::GetSecondaryViewRectSize
PostUpscaleVirtualInfo.ViewportRect = FIntRect(0, 0,
#Loc: <Workspace>/Engine/Plugins/Media/MediaPlate/Source/MediaPlate/Private/MediaPlate.cpp:29
Scope (from outer to inner):
file
namespace UE::MediaPlate::Private
function void ApplyTranslucencyScreenPercentageCVar
Source code excerpt:
void ApplyTranslucencyScreenPercentageCVar(int32 InBasis)
{
static IConsoleVariable* TranslucencySPBasisCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Translucency.ScreenPercentage.Basis"));
if (TranslucencySPBasisCVar->GetInt() != InBasis)
{
if (InBasis)
{
UE_LOG(LogMediaPlate, Warning, TEXT("Setting 'r.Translucency.ScreenPercentage.Basis' to 1. For media plates with overlay materials, please apply this console variable permanently to your project."));
}
#Loc: <Workspace>/Engine/Plugins/Media/MediaPlate/Source/MediaPlateEditor/Private/MediaPlateEditorModule.cpp:392
Scope (from outer to inner):
file
function TSharedRef<FExtender> FMediaPlateEditorModule::ExtendLevelViewportContextMenuForMediaPlate
lambda-function
Source code excerpt:
MenuBuilder.AddMenuEntry(
LOCTEXT("ResetDefaultMats", "Reset Default Materials"),
LOCTEXT("ResetDefaultMats_Tooltip", "Reverts the media plate to its default materials. Note that we also globally disable r.Translucency.ScreenPercentage.Basis if previously enabled."),
FSlateIcon(Style->GetStyleSetName(), "ClassIcon.MediaPlate"),
Action_ResetDefault
);
MenuBuilder.EndSection();
},
MediaPlateActor
#Associated Variable and Callsites
This variable is associated with another variable named CVarTranslucencyScreenPercentageBasis
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:42
Scope: file
Source code excerpt:
ECVF_Scalability | ECVF_Default);
static TAutoConsoleVariable<int32> CVarTranslucencyScreenPercentageBasis(
TEXT("r.Translucency.ScreenPercentage.Basis"), 0,
TEXT("Basis of the translucency's screen percentage (Experimental).\n")
TEXT(" 0: Uses the primary view's resolution (notably scaling with r.ScreenPercentage and r.DynamicRes.*)\n")
TEXT(" 1: Uses the secondary view's resolution (temporal upscale's output resolution)"),
ECVF_Scalability | ECVF_Default);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:115
Scope (from outer to inner):
file
function DynamicRenderScaling::FHeuristicSettings GetDynamicTranslucencyResolutionSettings
Source code excerpt:
DynamicRenderScaling::FHeuristicSettings BucketSetting;
BucketSetting.Model = DynamicRenderScaling::EHeuristicModel::Quadratic;
BucketSetting.bModelScalesWithPrimaryScreenPercentage = CVarTranslucencyScreenPercentageBasis.GetValueOnAnyThread() != 1;
BucketSetting.MinResolutionFraction = DynamicRenderScaling::GetPercentageCVarToFraction(CVarTranslucencyMinScreenPercentage);
BucketSetting.MaxResolutionFraction = DynamicRenderScaling::GetPercentageCVarToFraction(CVarTranslucencyMaxScreenPercentage);
BucketSetting.BudgetMs = CVarTranslucencyTimeBudget.GetValueOnAnyThread();
BucketSetting.ChangeThreshold = DynamicRenderScaling::GetPercentageCVarToFraction(CVarTranslucencyChangeThreshold);
BucketSetting.TargetedHeadRoom = DynamicRenderScaling::GetPercentageCVarToFraction(CVarTranslucencyTargetedHeadRoomPercentage);
BucketSetting.UpperBoundQuantization = CVarTranslucencyUpperBoundQuantization.GetValueOnAnyThread();
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:278
Scope (from outer to inner):
file
function FSeparateTranslucencyDimensions UpdateSeparateTranslucencyDimensions
Source code excerpt:
}
if (CVarTranslucencyScreenPercentageBasis.GetValueOnRenderThread() == 1)
{
TranslucencyResolutionFraction /= SceneRenderer.DynamicResolutionFractions[GDynamicPrimaryResolutionFraction];
MaxTranslucencyResolutionFraction /= SceneRenderer.DynamicResolutionUpperBounds[GDynamicPrimaryResolutionFraction];
}
FSeparateTranslucencyDimensions Dimensions;