ShowFlag.SubsurfaceScattering
ShowFlag.SubsurfaceScattering
#Overview
name: ShowFlag.SubsurfaceScattering
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allows to override a specific showflag (works in editor and game, \
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ShowFlag.SubsurfaceScattering is to control the visibility and rendering of subsurface scattering effects in Unreal Engine 5. Subsurface scattering is a lighting feature 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 system, specifically in the following subsystems and modules:
- Path Tracing: It affects the maximum number of subsurface scattering bounces in path tracing calculations.
- Post-Processing: It determines whether subsurface scattering effects should be applied during post-processing.
- Shadow Rendering: It influences how shadows are rendered for materials with subsurface scattering properties.
The value of this variable is typically set through the engine’s show flags system, which allows toggling various rendering features on and off. It can be accessed and modified through the View.Family->EngineShowFlags.SubsurfaceScattering
property.
The associated variable SubsurfaceScattering
shares the same value and purpose as ShowFlag.SubsurfaceScattering
. They are used interchangeably in different parts of the engine code.
Developers should be aware of the following when using this variable:
- Performance impact: Enabling subsurface scattering can have a significant performance cost, especially in path tracing scenarios.
- Visual quality: It greatly affects the realism of certain materials, particularly those simulating skin or other translucent substances.
- Interaction with other rendering features: It may influence shadow rendering and other lighting calculations.
Best practices for using this variable include:
- Only enable it when necessary for materials that benefit from subsurface scattering effects.
- Consider using the half-resolution option (controlled by
CVarSSSHalfRes
) for performance optimization. - Adjust related parameters like
SubsurfaceRadiusScale
to fine-tune the effect. - Be mindful of its impact on path tracing and adjust
MaxSSSBounces
accordingly for balance between quality and performance.
In summary, ShowFlag.SubsurfaceScattering
is a crucial setting for controlling the subsurface scattering effect in Unreal Engine 5, affecting both visual quality and performance across various rendering scenarios.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:155
Scope: file
Source code excerpt:
SHOWFLAG_ALWAYS_ACCESSIBLE(CapsuleShadows, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "CapsuleShadows", "Capsule Shadows"))
/** If Screen Space Subsurface Scattering enabled */
SHOWFLAG_FIXED_IN_SHIPPING(1, SubsurfaceScattering, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "SubsurfaceScatteringSF", "Subsurface Scattering (Screen Space)"))
/** If Screen Space Subsurface Scattering visualization is enabled */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeSSS, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeSSSSF", "Subsurface Scattering (Screen Space)"))
/** Whether to apply volumetric lightmap lighting, when present. */
SHOWFLAG_ALWAYS_ACCESSIBLE(VolumetricLightmap, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "VolumetricLightmapSF", "Volumetric Lightmap"))
/** If the indirect lighting cache is enabled, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(IndirectLightingCache, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "IndirectLightingCacheSF", "Indirect Lighting Cache"))
#Associated Variable and Callsites
This variable is associated with another variable named SubsurfaceScattering
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:155
Scope: file
Source code excerpt:
SHOWFLAG_ALWAYS_ACCESSIBLE(CapsuleShadows, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "CapsuleShadows", "Capsule Shadows"))
/** If Screen Space Subsurface Scattering enabled */
SHOWFLAG_FIXED_IN_SHIPPING(1, SubsurfaceScattering, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "SubsurfaceScatteringSF", "Subsurface Scattering (Screen Space)"))
/** If Screen Space Subsurface Scattering visualization is enabled */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeSSS, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeSSSSF", "Subsurface Scattering (Screen Space)"))
/** Whether to apply volumetric lightmap lighting, when present. */
SHOWFLAG_ALWAYS_ACCESSIBLE(VolumetricLightmap, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "VolumetricLightmapSF", "Volumetric Lightmap"))
/** If the indirect lighting cache is enabled, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(IndirectLightingCache, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "IndirectLightingCacheSF", "Indirect Lighting Cache"))
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:623
Scope (from outer to inner):
file
function static void PreparePathTracingData
Source code excerpt:
PathTracingData.MaxBounces = MaxBounces;
PathTracingData.MaxSSSBounces = ShowFlags.SubsurfaceScattering ? CVarPathTracingMaxSSSBounces.GetValueOnRenderThread() : 0;
PathTracingData.SSSGuidingRatio = FMath::Clamp(CVarPathTracingSSSGuidingRatio.GetValueOnRenderThread(), 0.0f, 1.0f);
PathTracingData.MaxNormalBias = GetRaytracingMaxNormalBias();
PathTracingData.MISMode = CVarPathTracingMISMode.GetValueOnRenderThread();
PathTracingData.VolumeMISMode = CVarPathTracingVolumeMISMode.GetValueOnRenderThread();
PathTracingData.MaxPathIntensity = CVarPathTracingMaxPathIntensity.GetValueOnRenderThread();
if (PathTracingData.MaxPathIntensity <= 0)
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:2499
Scope: file
Source code excerpt:
Config.LightShowFlags |= View.Family->EngineShowFlags.LightingOnlyOverride ? 1 << 11 : 0;
Config.LightShowFlags |= View.Family->EngineShowFlags.ReflectionOverride ? 1 << 12 : 0;
Config.LightShowFlags |= View.Family->EngineShowFlags.SubsurfaceScattering ? 1 << 13 : 0;
// the following affects which material shaders get used and therefore change the image
if (Substrate::IsSubstrateEnabled() && CVarPathTracingSubstrateCompileSimplifiedMaterial.GetValueOnRenderThread() != 0)
{
Config.LightShowFlags |= CVarPathTracingSubstrateUseSimplifiedMaterial.GetValueOnRenderThread() != 0 ? 1 << 14 : 0;
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessSubsurface.cpp:211
Scope (from outer to inner):
file
function ESubsurfaceMode GetSubsurfaceModeForView
Source code excerpt:
{
const float Radius = GetSubsurfaceRadiusScale();
const bool bShowSubsurfaceScattering = Radius > 0 && View.Family->EngineShowFlags.SubsurfaceScattering;
if (bShowSubsurfaceScattering)
{
const bool bHalfRes = CVarSSSHalfRes.GetValueOnRenderThread() != 0;
if (bHalfRes)
{
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessSubsurface.cpp:1036
Scope (from outer to inner):
file
function void AddSubsurfaceViewPass
Source code excerpt:
FRDGTextureRef NewQualityHistoryTexture = nullptr;
RDG_GPU_STAT_SCOPE(GraphBuilder, SubsurfaceScattering);
FSubsurfaceTiles Tiles;
/**
* When in bypass mode, the setup and convolution passes are skipped, but lighting
* reconstruction is still performed in the recombine pass.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:724
Scope (from outer to inner):
file
function FRHIBlendState* FProjectedShadowInfo::GetBlendStateForProjection
Source code excerpt:
// A: non WholeSceneShadows, SSS
//
// SSS: SubsurfaceScattering materials
// non SSS: shadow for opaque materials
// WholeSceneShadows: directional light CSM
// non WholeSceneShadows: spotlight, per object shadows, translucency lighting, omni-directional lights
if (bIsWholeSceneDirectionalShadow)
{