r.SSGI.Quality

r.SSGI.Quality

#Overview

name: r.SSGI.Quality

The value of this variable can be defined or overridden in .ini config files. 5 .ini config files referencing this setting variable.

This variable is created as a Console Variable (cvar).

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.SSGI.Quality is to control the quality settings for Screen Space Global Illumination (SSGI) in Unreal Engine’s rendering system. Specifically, it determines the number of rays shot with SSGI, ranging from 1 to 4, with a default value of 4.

This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the Screen Space Ray Tracing subsystem. It directly impacts the performance and visual quality of global illumination calculations in screen space.

The value of this variable is set through a console variable (CVarSSGIQuality) in the ScreenSpaceRayTracing.cpp file. It can be modified at runtime using console commands or through engine configuration files.

The r.SSGI.Quality variable interacts closely with other SSGI-related variables and functions. For example, it’s used in conjunction with GetSSRTGIShaderOptionsForQuality to determine the number of rays per pixel for SSGI calculations.

Developers should be aware that:

  1. Higher quality settings (closer to 4) will provide better visual results but at the cost of performance.
  2. The value is clamped between 1 and 4 in actual usage to prevent invalid settings.
  3. This setting affects both the quality and performance of global illumination, so it should be balanced carefully based on the target hardware and desired visual fidelity.

Best practices when using this variable include:

  1. Adjusting it based on the performance requirements of the target platform.
  2. Using it in conjunction with other SSGI settings for optimal results.
  3. Testing different values to find the best balance between visual quality and performance for your specific scene.

The associated variable CVarSSGIQuality is the actual console variable that stores and manages the r.SSGI.Quality setting. It’s defined as a TAutoConsoleVariable, which means it’s an integer value that can be changed at runtime through console commands.

CVarSSGIQuality is used directly in the code to retrieve the current SSGI quality setting. It’s accessed using the GetValueOnRenderThread() method, ensuring thread-safe access in the render thread.

When working with CVarSSGIQuality, developers should:

  1. Use GetValueOnRenderThread() when accessing it from render thread code.
  2. Be aware that changes to this variable will immediately affect SSGI calculations.
  3. Consider exposing this setting in user-facing graphics options if allowing players to adjust SSGI quality is desired.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseScalability.ini:623, section: [EffectsQuality@0]

Location: <Workspace>/Engine/Config/BaseScalability.ini:650, section: [EffectsQuality@1]

Location: <Workspace>/Engine/Config/BaseScalability.ini:677, section: [EffectsQuality@2]

Location: <Workspace>/Engine/Config/BaseScalability.ini:704, section: [EffectsQuality@3]

Location: <Workspace>/Engine/Config/BaseScalability.ini:732, section: [EffectsQuality@Cine]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceRayTracing.cpp:52

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarSSGIQuality(
	TEXT("r.SSGI.Quality"), 4,
	TEXT("Quality setting to control number of ray shot with SSGI, between 1 and 4 (defaults to 4).\n"),
	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarSSGIMinimumLuminance(
	TEXT("r.SSGI.MinimumLuminance"), 0.5f,
	TEXT(""),

#Associated Variable and Callsites

This variable is associated with another variable named CVarSSGIQuality. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceRayTracing.cpp:51

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarSSGIQuality(
	TEXT("r.SSGI.Quality"), 4,
	TEXT("Quality setting to control number of ray shot with SSGI, between 1 and 4 (defaults to 4).\n"),
	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarSSGIMinimumLuminance(
	TEXT("r.SSGI.MinimumLuminance"), 0.5f,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceRayTracing.cpp:97

Scope (from outer to inner):

file
function     static bool SupportScreenSpaceDiffuseIndirect

Source code excerpt:

	}

	int Quality = CVarSSGIQuality.GetValueOnRenderThread();

	if (Quality <= 0)
	{
		return false;
	}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceRayTracing.cpp:1313

Scope (from outer to inner):

file
namespace    ScreenSpaceRayTracing
function     int32 GetSSGIRayCountPerTracingPixel

Source code excerpt:

int32 GetSSGIRayCountPerTracingPixel()
{
	const int32 Quality = FMath::Clamp(CVarSSGIQuality.GetValueOnRenderThread(), 1, 4);

	int32 RayCountPerPixel;
	GetSSRTGIShaderOptionsForQuality(Quality, /* out */ &RayCountPerPixel);

	return RayCountPerPixel;
}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceRayTracing.cpp:1328

Scope (from outer to inner):

file
namespace    ScreenSpaceRayTracing
function     IScreenSpaceDenoiser::FDiffuseIndirectInputs CastStandaloneDiffuseIndirectRays

Source code excerpt:

	const FViewInfo& View)
{
	const int32 Quality = FMath::Clamp(CVarSSGIQuality.GetValueOnRenderThread(), 1, 4);

	int32 RayCountPerPixel;
	GetSSRTGIShaderOptionsForQuality(Quality, &RayCountPerPixel);
	check(RayCountPerPixel == CommonParameters.RayCountPerPixel);

	FIntPoint GroupSize = GetSSRTGroupSizeForSampleCount(CommonParameters.RayCountPerPixel);