r.HighQualityLightMaps

r.HighQualityLightMaps

#Overview

name: r.HighQualityLightMaps

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.HighQualityLightMaps is to control the usage of high-quality lightmaps in the rendering system. It determines whether to allow high-quality lightmaps that don’t bake in direct lighting of stationary lights.

This setting variable is primarily used by Unreal Engine’s rendering system, specifically in the lighting and lightmap generation subsystems. It’s defined in the Engine module, as evident from its location in the UnrealEngine.cpp file.

The value of this variable is set through a console variable (CVarAllowHighQualityLightMaps) with a default value of 1, meaning high-quality lightmaps are allowed by default. It can be changed at runtime through console commands.

The associated variable CVarAllowHighQualityLightMaps directly interacts with r.HighQualityLightMaps. They share the same value and purpose.

Developers must be aware that:

  1. This setting is render thread safe and read-only, meaning it can’t be modified during gameplay.
  2. It only affects platforms that support high-quality lightmaps and feature levels above ES3_1.
  3. It doesn’t apply to mobile platforms.

Best practices when using this variable include:

  1. Consider performance implications when enabling high-quality lightmaps, especially on lower-end hardware.
  2. Use in conjunction with other lighting and performance settings for optimal results.
  3. Test thoroughly on target platforms to ensure desired visual quality and performance.

Regarding the associated variable CVarAllowHighQualityLightMaps:

The purpose of CVarAllowHighQualityLightMaps is to provide a console-accessible way to control the r.HighQualityLightMaps setting.

It’s used by the Engine module to determine whether high-quality lightmaps should be allowed. The AllowHighQualityLightmaps function directly uses this variable to make its decision.

The value is set when the console variable is initialized, with a default of 1. It can be changed through console commands at runtime.

This variable directly controls the behavior of r.HighQualityLightMaps.

Developers should be aware that:

  1. This is a render thread safe and read-only variable.
  2. Changes to this variable will immediately affect the lighting system’s behavior.

Best practices include:

  1. Use console commands to adjust this setting during development for quick iterations on lighting.
  2. Consider exposing this setting in a user-friendly way for end-users if dynamic adjustment of lightmap quality is desired.
  3. Be cautious about changing this value in shipping builds, as it can significantly impact performance and visual quality.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:17566

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarAllowHighQualityLightMaps(
	TEXT("r.HighQualityLightMaps"),
	1,
	TEXT("If set to 1, allow high quality lightmaps which don't bake in direct lighting of stationary lights"),
	ECVF_RenderThreadSafe | ECVF_ReadOnly);


bool AllowHighQualityLightmaps(const FStaticFeatureLevel FeatureLevel)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:17565

Scope: file

Source code excerpt:

FAutoConsoleCommand GSetNearClipPlaneCmd(TEXT("r.SetNearClipPlane"),TEXT("Set the near clipping plane (in cm)"),FConsoleCommandWithArgsDelegate::CreateStatic(SetNearClipPlane));

static TAutoConsoleVariable<int32> CVarAllowHighQualityLightMaps(
	TEXT("r.HighQualityLightMaps"),
	1,
	TEXT("If set to 1, allow high quality lightmaps which don't bake in direct lighting of stationary lights"),
	ECVF_RenderThreadSafe | ECVF_ReadOnly);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:17576

Scope (from outer to inner):

file
function     bool AllowHighQualityLightmaps

Source code excerpt:

	return FPlatformProperties::SupportsHighQualityLightmaps()
		&& (FeatureLevel > ERHIFeatureLevel::ES3_1)
		&& (CVarAllowHighQualityLightMaps.GetValueOnAnyThread() != 0)
		&& !IsMobilePlatform(GShaderPlatformForFeatureLevel[FeatureLevel]);
}

// Helper function for changing system resolution via the r.setres console command
void FSystemResolution::RequestResolutionChange(int32 InResX, int32 InResY, EWindowMode::Type InWindowMode)
{