r.SSGI.SkyDistance

r.SSGI.SkyDistance

#Overview

name: r.SSGI.SkyDistance

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.SSGI.SkyDistance is to set the distance of the sky in kilometers for the Screen Space Global Illumination (SSGI) system in Unreal Engine 5. This setting is used in the rendering system, specifically for global illumination calculations.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, as evidenced by its location in the ScreenSpaceRayTracing.cpp file within the Runtime/Renderer/Private directory.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 10,000,000 km, which can be changed at runtime.

The associated variable CVarSSGISkyDistance directly interacts with r.SSGI.SkyDistance. They share the same value and purpose.

Developers must be aware that this variable affects the rendering of global illumination in screen space. Changing this value will impact how far the engine considers the sky to be when calculating lighting, which can affect the visual quality and performance of the SSGI system.

Best practices when using this variable include:

  1. Only modify it if you have a specific reason to change the sky distance for your scene.
  2. Be aware that extreme values may lead to unrealistic lighting results or performance issues.
  3. Test thoroughly after making changes to ensure desired visual results and performance.

Regarding the associated variable CVarSSGISkyDistance:

The purpose of CVarSSGISkyDistance is to provide a programmatic way to access and modify the r.SSGI.SkyDistance value within the C++ code of the engine.

It’s used in the Renderer module, specifically in the ScreenSpaceRayTracing namespace.

The value is set initially when the variable is declared, but it can be accessed and potentially modified at runtime using the GetValueOnRenderThread() method.

This variable directly interacts with r.SSGI.SkyDistance, as they represent the same setting.

Developers should be aware that this is the internal representation of the console variable and should be used when needing to access or modify the sky distance value in C++ code.

Best practices include:

  1. Use GetValueOnRenderThread() when accessing the value to ensure thread safety.
  2. Consider using this variable for any runtime modifications to the sky distance in your custom rendering code.
  3. Be cautious about changing this value frequently, as it may impact performance.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarSSGISkyDistance(
	TEXT("r.SSGI.SkyDistance"), 10000000,
	TEXT("Distance of the sky in KM."),
	ECVF_Scalability | ECVF_RenderThreadSafe);


DECLARE_GPU_DRAWCALL_STAT_NAMED(ScreenSpaceReflections, TEXT("ScreenSpace Reflections"));
DECLARE_GPU_STAT_NAMED(ScreenSpaceDiffuseIndirect, TEXT("Screen Space Diffuse Indirect"));

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarSSGISkyDistance(
	TEXT("r.SSGI.SkyDistance"), 10000000,
	TEXT("Distance of the sky in KM."),
	ECVF_Scalability | ECVF_RenderThreadSafe);


DECLARE_GPU_DRAWCALL_STAT_NAMED(ScreenSpaceReflections, TEXT("ScreenSpace Reflections"));

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

Scope (from outer to inner):

file
namespace    ScreenSpaceRayTracing
function     FPrevSceneColorMip ReducePrevSceneColorMip

Source code excerpt:

		PassParameters->PrevSceneColorPreExposureCorrection = View.PreExposure / View.PrevViewInfo.SceneColorPreExposure;
		PassParameters->MinimumLuminance = CVarSSGIMinimumLuminance.GetValueOnRenderThread();
		PassParameters->SkyDistance = CVarSSGISkyDistance.GetValueOnRenderThread();

		PassParameters->PrevScreenPositionScaleBias = FVector4f(
			ViewportExtent.X * 0.5f / BufferSize.X,
			-ViewportExtent.Y * 0.5f / BufferSize.Y,
			(ViewportExtent.X * 0.5f + ViewportOffset.X) / BufferSize.X,
			(ViewportExtent.Y * 0.5f + ViewportOffset.Y) / BufferSize.Y);