r.SubsurfaceScattering
r.SubsurfaceScattering
#Overview
name: r.SubsurfaceScattering
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0: disabled\n 1: enabled (default)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.SubsurfaceScattering is to control the subsurface scattering feature in Unreal Engine’s rendering system. Subsurface scattering is a lighting effect that simulates how light penetrates and scatters within translucent materials, such as skin, wax, or marble.
This setting variable is primarily used by the rendering subsystem of Unreal Engine, specifically in the post-processing stage. It is referenced in the PostProcessSubsurface.cpp file, which is part of the Renderer module.
The value of this variable is set through a console variable (CVarSubsurfaceScattering) with two possible states: 0: disabled 1: enabled (default)
The associated variable CVarSubsurfaceScattering interacts directly with r.SubsurfaceScattering. It’s defined as a TAutoConsoleVariable
Developers should be aware that:
- This variable affects rendering performance and visual quality.
- It’s marked with ECVF_RenderThreadSafe and ECVF_Scalability flags, indicating it’s safe to change on the render thread and can be used for scalability settings.
- The actual effect of subsurface scattering also depends on the CVarSSSScale variable, which controls the scale of the effect.
Best practices when using this variable include:
- Consider performance implications when enabling subsurface scattering, especially on lower-end hardware.
- Use it in conjunction with proper material setup for objects that should exhibit subsurface scattering properties.
- Test the visual impact and performance with both enabled and disabled states to determine the best setting for your project.
Regarding the associated variable CVarSubsurfaceScattering:
- It’s the actual console variable that controls the r.SubsurfaceScattering setting.
- It’s used in the IsSubsurfaceEnabled() function to determine if subsurface scattering should be applied.
- When working with subsurface scattering programmatically, developers should use this variable to check or modify the current state of the feature.
- Changes to this variable will immediately affect the rendering pipeline, so it should be used cautiously in performance-critical scenarios.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessSubsurface.cpp:27
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
// Subsurface common parameters
TAutoConsoleVariable<int32> CVarSubsurfaceScattering(
TEXT("r.SubsurfaceScattering"),
1,
TEXT(" 0: disabled\n")
TEXT(" 1: enabled (default)"),
ECVF_RenderThreadSafe | ECVF_Scalability);
TAutoConsoleVariable<float> CVarSSSScale(
#Associated Variable and Callsites
This variable is associated with another variable named CVarSubsurfaceScattering
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessSubsurface.cpp:26
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
{
// Subsurface common parameters
TAutoConsoleVariable<int32> CVarSubsurfaceScattering(
TEXT("r.SubsurfaceScattering"),
1,
TEXT(" 0: disabled\n")
TEXT(" 1: enabled (default)"),
ECVF_RenderThreadSafe | ECVF_Scalability);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessSubsurface.cpp:283
Scope (from outer to inner):
file
function bool IsSubsurfaceEnabled
Source code excerpt:
bool IsSubsurfaceEnabled()
{
const bool bEnabled = CVarSubsurfaceScattering.GetValueOnAnyThread() != 0;
const bool bHasScale = CVarSSSScale.GetValueOnAnyThread() > 0.0f;
return (bEnabled && bHasScale);
}
bool IsSubsurfaceRequiredForView(const FViewInfo& View)
{