r.SeparateTranslucencyScreenPercentage
r.SeparateTranslucencyScreenPercentage
#Overview
name: r.SeparateTranslucencyScreenPercentage
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Render separate translucency at this percentage of the full resolution.\nin percent, >0 and <=100, larger numbers are possible (supersampling).<0 is treated like 100.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.SeparateTranslucencyScreenPercentage is to control the resolution at which separate translucency is rendered in Unreal Engine 5. It allows developers to adjust the quality and performance of translucent object rendering.
This setting variable is primarily used by the rendering system, specifically the translucent rendering subsystem. It’s referenced in the Renderer module and the Engine module, as seen in the callsites.
The value of this variable is set through a console variable (CVarSeparateTranslucencyScreenPercentage) in the TranslucentRendering.cpp file. It’s initialized with a default value of 100.0f, meaning full resolution by default.
This variable interacts with several other parts of the rendering system:
- In SceneView.cpp, it affects the calculation of light probe size ratios.
- In ShaderGenerationUtil.cpp, it’s used in shader code generation for GBuffer decoding.
- In TranslucentRendering.cpp, it’s used to calculate the translucency resolution fraction.
Developers should be aware that:
- The value is a percentage, with 100 being full resolution.
- Values below 100 will render translucency at a lower resolution, potentially improving performance at the cost of quality.
- Values above 100 are possible, enabling supersampling for higher quality at the cost of performance.
- Values less than 0 are treated as 100.
Best practices for using this variable include:
- Use it as a scalability option, allowing users with less powerful hardware to reduce the translucency resolution for better performance.
- Consider dynamically adjusting this value based on the scene complexity or performance metrics.
- Test thoroughly with different values to find the right balance between quality and performance for your specific game or application.
Regarding the associated variable CVarSeparateTranslucencyScreenPercentage:
This is the actual console variable that stores and provides access to the r.SeparateTranslucencyScreenPercentage value. It’s defined in TranslucentRendering.cpp and is used to retrieve the current value of the setting.
The purpose of this variable is to provide a way to access and modify the separate translucency screen percentage at runtime. It’s used directly in the UpdateSeparateTranslucencyDimensions function to calculate the translucency resolution fraction.
Developers should be aware that this variable has the ECVF_Scalability and ECVF_Default flags, meaning it’s intended to be used as a scalability option and can be set to its default value easily.
When working with this variable, developers should:
- Use GetValueOnRenderThread() when accessing its value in render thread code.
- Be aware that changes to this variable will affect rendering performance and quality in real-time.
- Consider exposing this setting in user-facing graphics options if appropriate for your project.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:35
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarSeparateTranslucencyScreenPercentage(
TEXT("r.SeparateTranslucencyScreenPercentage"),
100.0f,
TEXT("Render separate translucency at this percentage of the full resolution.\n")
TEXT("in percent, >0 and <=100, larger numbers are possible (supersampling).")
TEXT("<0 is treated like 100."),
ECVF_Scalability | ECVF_Default);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:2476
Scope (from outer to inner):
file
function void FSceneView::SetupViewRectUniformBufferParameters
Source code excerpt:
ViewUniformShaderParameters.ViewRectMinAndSize = FUintVector4(EffectiveViewRect.Min.X, EffectiveViewRect.Min.Y, EffectiveViewRect.Width(), EffectiveViewRect.Height());
// The light probe ratio is only different during separate forward translucency when r.SeparateTranslucencyScreenPercentage != 100
ViewUniformShaderParameters.LightProbeSizeRatioAndInvSizeRatio = FVector4f(1.0f, 1.0f, 1.0f, 1.0f);
// Calculate the vector used by shaders to convert clip space coordinates to texture space.
const float InvBufferSizeX = 1.0f / BufferSize.X;
const float InvBufferSizeY = 1.0f / BufferSize.Y;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderGenerationUtil.cpp:1426
Scope (from outer to inner):
file
function static FString CreateGBufferDecodeFunctionVariation
Source code excerpt:
// BufferToSceneTextureScale is necessary when translucent materials are rendered in a render target
// that has a different resolution than the scene color textures, e.g. r.SeparateTranslucencyScreenPercentage < 100.
FullStr += FString::Printf(TEXT("\tint2 IntUV = (int2)trunc(%s * View.BufferSizeAndInvSize.xy * View.BufferToSceneTextureScale.xy);\n"), CoordName.GetCharArray().GetData());
FullStr += TEXT("\tuint CustomStencil = SceneTexturesStruct.CustomStencilTexture.Load(int3(IntUV, 0)) STENCIL_COMPONENT_SWIZZLE;\n");
FullStr += FString::Printf(TEXT("\tfloat SceneDepth = CalcSceneDepth(%s);\n"), CoordName.GetCharArray().GetData());
FullStr += TEXT("\tfloat4 AnisotropicData = Texture2DSampleLevel(SceneTexturesStruct.GBufferFTexture, SceneTexturesStruct_GBufferFTextureSampler, UV, 0).xyzw;\n");
}
#Associated Variable and Callsites
This variable is associated with another variable named CVarSeparateTranslucencyScreenPercentage
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:34
Scope: file
Source code excerpt:
bool IsVSMTranslucentHighQualityEnabled();
static TAutoConsoleVariable<float> CVarSeparateTranslucencyScreenPercentage(
TEXT("r.SeparateTranslucencyScreenPercentage"),
100.0f,
TEXT("Render separate translucency at this percentage of the full resolution.\n")
TEXT("in percent, >0 and <=100, larger numbers are possible (supersampling).")
TEXT("<0 is treated like 100."),
ECVF_Scalability | ECVF_Default);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:269
Scope (from outer to inner):
file
function FSeparateTranslucencyDimensions UpdateSeparateTranslucencyDimensions
Source code excerpt:
FSeparateTranslucencyDimensions UpdateSeparateTranslucencyDimensions(const FSceneRenderer& SceneRenderer)
{
float TranslucencyResolutionFraction = FMath::Clamp(CVarSeparateTranslucencyScreenPercentage.GetValueOnRenderThread() / 100.0f, 0.0f, 1.0f);
float MaxTranslucencyResolutionFraction = TranslucencyResolutionFraction;
if (GDynamicTranslucencyResolution.GetSettings().IsEnabled())
{
TranslucencyResolutionFraction = SceneRenderer.DynamicResolutionFractions[GDynamicTranslucencyResolution];
MaxTranslucencyResolutionFraction = SceneRenderer.DynamicResolutionUpperBounds[GDynamicTranslucencyResolution];