r.SkyLight.CubemapMaxResolution

r.SkyLight.CubemapMaxResolution

#Overview

name: r.SkyLight.CubemapMaxResolution

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.SkyLight.CubemapMaxResolution is to control the maximum resolution of the skylight cubemap in Unreal Engine 5’s rendering system. It allows developers to override the default resolution of the skylight cubemap, which is an important component in lighting and reflections within a scene.

This setting variable is primarily used by the Engine module, specifically within the SkyLightComponent. It’s part of the rendering subsystem, affecting how skylight is processed and rendered in the game.

The value of this variable is set through the console variable system. It’s initialized with a default value of -1, which means it will use the default property value of USkyLightComponent::CubeMapResolution. Developers can change this value at runtime using console commands or through configuration files.

The associated variable GSkylightCubemapMaxResolution directly interacts with r.SkyLight.CubemapMaxResolution. They share the same value, with GSkylightCubemapMaxResolution being the actual integer variable used in the C++ code.

Developers must be aware that setting this variable affects the quality and performance of skylight rendering. A higher resolution will result in better quality but may impact performance, especially on lower-end hardware.

Best practices when using this variable include:

  1. Only override the default value if necessary, as the engine’s default settings are usually optimized for a balance of quality and performance.
  2. Consider the target hardware when adjusting this value, as higher resolutions may not be suitable for all platforms.
  3. Test thoroughly after changing this value to ensure it doesn’t negatively impact performance or visual quality.
  4. Use in conjunction with other skylight-related settings for optimal results.

Regarding the associated variable GSkylightCubemapMaxResolution:

The purpose of GSkylightCubemapMaxResolution is to store the actual integer value of the maximum skylight cubemap resolution within the C++ code.

It’s used directly in the Engine module, specifically in the SkyLightComponent implementation. The SanitizeCubemapSize function uses this variable to determine the final cubemap resolution.

The value of GSkylightCubemapMaxResolution is set through the console variable system, mirroring the value of r.SkyLight.CubemapMaxResolution.

This variable interacts directly with the CubemapResolution property of the SkyLightComponent. If GSkylightCubemapMaxResolution is greater than 0, it overrides the CubemapResolution value.

Developers should be aware that changes to GSkylightCubemapMaxResolution will directly affect the skylight rendering quality and performance. It’s important to consider the implications of changing this value, especially in terms of memory usage and rendering time.

Best practices for using GSkylightCubemapMaxResolution include:

  1. Avoid directly modifying this variable in code; instead, use the console variable system to ensure consistency.
  2. When debugging or profiling skylight performance, monitor this variable to understand its impact on rendering.
  3. Consider platform-specific optimizations by adjusting this value based on the target hardware capabilities.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/SkyLightComponent.cpp:110

Scope: file

Source code excerpt:

int32 GSkylightCubemapMaxResolution = -1;
FAutoConsoleVariableRef CVarSkylightCubemapMaxResolution(
	TEXT("r.SkyLight.CubemapMaxResolution"),
	GSkylightCubemapMaxResolution,
	TEXT("Force max resolution of skylight cubemap (default to -1: takes default property value of USkyLightComponent::CubeMapResolution)")
);

constexpr EPixelFormat SKYLIGHT_CUBEMAP_FORMAT = PF_FloatRGBA;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/SkyLightComponent.cpp:108

Scope: file

Source code excerpt:

	);

int32 GSkylightCubemapMaxResolution = -1;
FAutoConsoleVariableRef CVarSkylightCubemapMaxResolution(
	TEXT("r.SkyLight.CubemapMaxResolution"),
	GSkylightCubemapMaxResolution,
	TEXT("Force max resolution of skylight cubemap (default to -1: takes default property value of USkyLightComponent::CubeMapResolution)")
);

constexpr EPixelFormat SKYLIGHT_CUBEMAP_FORMAT = PF_FloatRGBA;

void FSkyTextureCubeResource::InitRHI(FRHICommandListBase&)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/SkyLightComponent.cpp:352

Scope (from outer to inner):

file
function     void USkyLightComponent::SanitizeCubemapSize

Source code excerpt:

	const int32 MinCubemapResolution = 8;

	if (GSkylightCubemapMaxResolution > 0)
	{
		CubemapResolution = GSkylightCubemapMaxResolution;
	}

	CubemapResolution = FMath::Clamp(int32(FMath::RoundUpToPowerOfTwo(CubemapResolution)), MinCubemapResolution, MaxCubemapResolution);

#if WITH_EDITOR
	if (FApp::CanEverRender() && !FApp::IsUnattended())