r.PathTracing.SSSGuidingRatio
r.PathTracing.SSSGuidingRatio
#Overview
name: r.PathTracing.SSSGuidingRatio
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Sets the ratio between classical random walks and walks guided towards the surface. A value of 0.0 corresponds to a purely classical random walk, while a value of 1.0 is fully guided towards the surface (at the expense of fireflies in non-flat regions of the model. (default = 0.5)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.PathTracing.SSSGuidingRatio is to control the balance between classical random walks and guided walks in subsurface scattering (SSS) calculations for path tracing rendering.
This setting variable is primarily used in the rendering system, specifically in the path tracing module of Unreal Engine 5. It’s part of the advanced rendering features that deal with realistic light scattering in materials.
Based on the callsites, this variable is utilized in the Renderer module, specifically in the PathTracing.cpp file. This indicates that it’s an integral part of the path tracing rendering subsystem.
The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 0.5f, but can be changed at runtime through console commands or programmatically.
The associated variable CVarPathTracingSSSGuidingRatio directly interacts with r.PathTracing.SSSGuidingRatio. They share the same value and purpose.
Developers must be aware that this variable affects the visual quality and performance of subsurface scattering in path-traced renders. A value of 0.0 results in a purely classical random walk, while 1.0 leads to fully guided walks towards the surface. The latter can cause visual artifacts (“fireflies”) in non-flat regions of the model.
Best practices when using this variable include:
- Start with the default value of 0.5 and adjust based on specific scene requirements.
- Be cautious when setting values close to 1.0, as it may introduce visual artifacts.
- Balance between render quality and performance, as higher values may impact rendering speed.
- Test different values in various lighting conditions and with different materials to find the optimal setting for your specific use case.
Regarding the associated variable CVarPathTracingSSSGuidingRatio:
- Its purpose is the same as r.PathTracing.SSSGuidingRatio, serving as the C++ representation of the console variable.
- It’s used in the PreparePathTracingData function to set the SSSGuidingRatio in the PathTracingData structure.
- The value is clamped between 0.0f and 1.0f to ensure it stays within the valid range.
- Developers should note that changes to this variable will take effect on the render thread, as indicated by the GetValueOnRenderThread() call.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:157
Scope: file
Source code excerpt:
TAutoConsoleVariable<float> CVarPathTracingSSSGuidingRatio(
TEXT("r.PathTracing.SSSGuidingRatio"),
0.5f,
TEXT("Sets the ratio between classical random walks and walks guided towards the surface. A value of 0.0 corresponds to a purely classical random walk, while a value of 1.0 is fully guided towards the surface (at the expense of fireflies in non-flat regions of the model. (default = 0.5)"),
ECVF_RenderThreadSafe
);
#Associated Variable and Callsites
This variable is associated with another variable named CVarPathTracingSSSGuidingRatio
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:156
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<float> CVarPathTracingSSSGuidingRatio(
TEXT("r.PathTracing.SSSGuidingRatio"),
0.5f,
TEXT("Sets the ratio between classical random walks and walks guided towards the surface. A value of 0.0 corresponds to a purely classical random walk, while a value of 1.0 is fully guided towards the surface (at the expense of fireflies in non-flat regions of the model. (default = 0.5)"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:624
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)
{