r.PathTracing.MaxSSSBounces
r.PathTracing.MaxSSSBounces
#Overview
name: r.PathTracing.MaxSSSBounces
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Sets the maximum number of bounces inside subsurface materials. Lowering this value can make subsurface scattering render too dim, while setting it too high can cause long render times. (default = 256)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.PathTracing.MaxSSSBounces is to control the maximum number of bounces inside subsurface materials in the path tracing rendering system of Unreal Engine 5. This setting variable is crucial for balancing the quality of subsurface scattering effects with render performance.
This setting variable is primarily used by the Renderer module, specifically within the path tracing subsystem. It’s referenced in the PathTracing.cpp file, which is part of the core rendering implementation.
The value of this variable is set through a console variable (CVarPathTracingMaxSSSBounces) with a default value of 256. It can be modified at runtime through the console or through project settings.
The associated variable CVarPathTracingMaxSSSBounces directly interacts with r.PathTracing.MaxSSSBounces. They share the same value and purpose.
Developers must be aware that:
- Setting this value too low can result in subsurface scattering appearing too dim.
- Setting it too high can lead to significantly increased render times.
- This setting only affects the rendering when subsurface scattering is enabled in the show flags.
Best practices when using this variable include:
- Adjust the value based on the specific needs of your scene and the desired balance between quality and performance.
- Start with the default value (256) and adjust incrementally.
- Test thoroughly with different types of subsurface materials in your scene to ensure a good balance.
- Consider exposing this setting to artists or technical artists for fine-tuning in different scenarios.
Regarding the associated variable CVarPathTracingMaxSSSBounces:
- It’s an internal representation of the r.PathTracing.MaxSSSBounces setting.
- It’s implemented as a TAutoConsoleVariable
, allowing for runtime modification. - The value is retrieved in the render thread using GetValueOnRenderThread() method.
- It’s used directly in the PreparePathTracingData function to set the MaxSSSBounces field of the FPathTracingData structure.
- When working with this variable programmatically, ensure thread-safety by accessing it only on the render thread.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:150
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarPathTracingMaxSSSBounces(
TEXT("r.PathTracing.MaxSSSBounces"),
256,
TEXT("Sets the maximum number of bounces inside subsurface materials. Lowering this value can make subsurface scattering render too dim, while setting it too high can cause long render times. (default = 256)"),
ECVF_RenderThreadSafe
);
TAutoConsoleVariable<float> CVarPathTracingSSSGuidingRatio(
#Associated Variable and Callsites
This variable is associated with another variable named CVarPathTracingMaxSSSBounces
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:149
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarPathTracingMaxSSSBounces(
TEXT("r.PathTracing.MaxSSSBounces"),
256,
TEXT("Sets the maximum number of bounces inside subsurface materials. Lowering this value can make subsurface scattering render too dim, while setting it too high can cause long render times. (default = 256)"),
ECVF_RenderThreadSafe
);
#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)