r.ReflectionCaptureResolution

r.ReflectionCaptureResolution

#Overview

name: r.ReflectionCaptureResolution

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

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.ReflectionCaptureResolution is to set the resolution for all reflection capture cubemaps in Unreal Engine 5. This setting variable is primarily used in the rendering system, specifically for reflection capture components.

The Unreal Engine subsystem that relies on this setting variable is the rendering system, particularly the components related to reflection capture and scene visibility. This can be seen from the file locations where the variable is referenced: ReflectionCaptureComponent.cpp and SceneVisibility.cpp.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 128, but can be changed at runtime or set via the project’s Render Settings.

This variable interacts closely with CVarReflectionCaptureSize, which is essentially an alias for r.ReflectionCaptureResolution. They share the same value and purpose.

Developers must be aware of several things when using this variable:

  1. The value must be a power of 2.
  2. Changing this value affects all reflection capture cubemaps in the scene.
  3. It directly impacts rendering performance and quality.
  4. The value is used to calculate minimum source radius for light sources in reflection captures.

Best practices when using this variable include:

  1. Set it through the project’s Render Settings rather than changing it at runtime for consistency.
  2. Choose a value that balances between quality and performance for your specific project needs.
  3. Be cautious about setting very high values, as it can significantly impact performance.
  4. Consider the target platforms and their capabilities when setting this value.

Regarding the associated variable CVarReflectionCaptureSize:

The purpose of CVarReflectionCaptureSize is identical to r.ReflectionCaptureResolution. It’s an engine-wide console variable that sets the resolution for all reflection capture cubemaps.

This variable is used in the UReflectionCaptureComponent class to retrieve the current reflection capture size. It’s accessed through the GetValueOnAnyThread() method, which suggests it can be safely accessed from multiple threads.

The value of CVarReflectionCaptureSize is set in the same way as r.ReflectionCaptureResolution, through the console variable system.

Developers should be aware that changes to CVarReflectionCaptureSize will affect all reflection captures in the scene. Also, the returned value is sanitized through the SanitizeReflectionCaptureSize function before use, which likely ensures the value is a valid power of 2.

Best practices for CVarReflectionCaptureSize are the same as for r.ReflectionCaptureResolution, as they are essentially the same variable. Developers should prefer using the project’s Render Settings to modify this value rather than changing it programmatically, unless there’s a specific need for dynamic adjustment.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:121, section: [/Script/Engine.RendererSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/ReflectionCaptureComponent.cpp:49

Scope: file

Source code excerpt:

 */
ENGINE_API TAutoConsoleVariable<int32> CVarReflectionCaptureSize(
	TEXT("r.ReflectionCaptureResolution"),
	128,
	TEXT("Set the resolution for all reflection capture cubemaps. Should be set via project's Render Settings. Must be power of 2. Defaults to 128.\n")
	);

TAutoConsoleVariable<int32> CVarReflectionCaptureUpdateEveryFrame(
	TEXT("r.ReflectionCaptureUpdateEveryFrame"),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneVisibility.cpp:5303

Scope (from outer to inner):

file
function     void FSceneRenderer::GatherReflectionCaptureLightMeshElements

Source code excerpt:


			// Force to be at least 0.75 pixels
			float CubemapSize = (float)IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.ReflectionCaptureResolution"))->GetValueOnAnyThread();
			float Distance = FMath::Sqrt(DistanceSqr);
			float MinRadius = Distance * 0.75f / CubemapSize;
			LightParameters.SourceRadius = FMath::Max(MinRadius, LightParameters.SourceRadius);

			// Snap to cubemap pixel center to reduce aliasing
			FVector Scale = ToLight.GetAbs();

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/ReflectionCaptureComponent.cpp:48

Scope: file

Source code excerpt:

 * Reflection capture derived data versions must be changed if modifying this
 */
ENGINE_API TAutoConsoleVariable<int32> CVarReflectionCaptureSize(
	TEXT("r.ReflectionCaptureResolution"),
	128,
	TEXT("Set the resolution for all reflection capture cubemaps. Should be set via project's Render Settings. Must be power of 2. Defaults to 128.\n")
	);

TAutoConsoleVariable<int32> CVarReflectionCaptureUpdateEveryFrame(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/ReflectionCaptureComponent.cpp:70

Scope (from outer to inner):

file
function     int32 UReflectionCaptureComponent::GetReflectionCaptureSize

Source code excerpt:

int32 UReflectionCaptureComponent::GetReflectionCaptureSize()
{
	return SanitizeReflectionCaptureSize(CVarReflectionCaptureSize.GetValueOnAnyThread());
}

FReflectionCaptureMapBuildData* UReflectionCaptureComponent::GetMapBuildData() const
{
	AActor* Owner = GetOwner();