r.ReflectionEnvironmentLightmapMixLargestWeight

r.ReflectionEnvironmentLightmapMixLargestWeight

#Overview

name: r.ReflectionEnvironmentLightmapMixLargestWeight

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.ReflectionEnvironmentLightmapMixLargestWeight is to control the clamping of lightmap mixing in reflection captures within Unreal Engine’s rendering system. It specifically affects how lightmaps are applied to reflection captures, with a focus on darkening effects.

This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the reflection environment subsystem. It’s referenced in the ReflectionEnvironment.cpp file, which is part of the rendering pipeline responsible for handling environmental reflections.

The value of this variable is set through the Unreal Engine console variable system. It’s initialized with a default value of 10000 and can be modified at runtime using console commands or through project settings.

This variable interacts closely with other reflection environment settings, particularly those related to lightmap mixing. It’s used in conjunction with variables like GReflectionEnvironmentLightmapMixing, GReflectionEnvironmentEndMixingRoughness, and GReflectionEnvironmentBeginMixingRoughness to determine how lightmaps are mixed with reflection captures.

Developers should be aware that setting this variable to 1 will clamp the lightmap mixing in a way that only allows darkening effects from lightmaps to be applied to reflection captures. This can significantly alter the visual appearance of reflections in the scene.

Best practices when using this variable include:

  1. Carefully consider the visual impact before changing the default value.
  2. Use in conjunction with other reflection environment settings for fine-tuned control.
  3. Test thoroughly in different lighting conditions to ensure desired results.

Regarding the associated variable GReflectionEnvironmentLightmapMixLargestWeight:

This is the internal C++ variable that directly corresponds to the console variable r.ReflectionEnvironmentLightmapMixLargestWeight. It’s used within the engine code to actually implement the behavior controlled by the setting.

The purpose of GReflectionEnvironmentLightmapMixLargestWeight is to store and provide access to the current value of the lightmap mix largest weight setting within the C++ code of the engine.

This variable is used in the Renderer module, specifically in the reflection environment calculations. It’s referenced in the GetReflectionEnvironmentRoughnessMixingScaleBiasAndLargestWeight function, which is likely used to determine how roughness and lightmap mixing should be applied in reflection calculations.

The value of this variable is set by the console variable system when r.ReflectionEnvironmentLightmapMixLargestWeight is modified.

GReflectionEnvironmentLightmapMixLargestWeight interacts with other reflection environment variables and is used in calculations that determine the final appearance of reflections in the scene.

Developers should be aware that modifying this variable directly in C++ code is not recommended. Instead, they should use the console variable r.ReflectionEnvironmentLightmapMixLargestWeight to ensure proper synchronization and to take advantage of the console variable system’s features.

Best practices for this variable include:

  1. Treat it as read-only in most cases, relying on the console variable for modifications.
  2. Be aware of its impact on reflection calculations when working on rendering code.
  3. Consider its value when debugging reflection-related issues in the engine.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ReflectionEnvironment.cpp:80

Scope: file

Source code excerpt:

int32 GReflectionEnvironmentLightmapMixLargestWeight = 10000;
FAutoConsoleVariableRef CVarReflectionEnvironmentLightmapMixLargestWeight(
	TEXT("r.ReflectionEnvironmentLightmapMixLargestWeight"),
	GReflectionEnvironmentLightmapMixLargestWeight,
	TEXT("When set to 1 can be used to clamp lightmap mixing such that only darkening from lightmaps are applied to reflection captures."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

static TAutoConsoleVariable<int32> CVarDoTiledReflections(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ReflectionEnvironment.cpp:78

Scope: file

Source code excerpt:

	);

int32 GReflectionEnvironmentLightmapMixLargestWeight = 10000;
FAutoConsoleVariableRef CVarReflectionEnvironmentLightmapMixLargestWeight(
	TEXT("r.ReflectionEnvironmentLightmapMixLargestWeight"),
	GReflectionEnvironmentLightmapMixLargestWeight,
	TEXT("When set to 1 can be used to clamp lightmap mixing such that only darkening from lightmaps are applied to reflection captures."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

static TAutoConsoleVariable<int32> CVarDoTiledReflections(
	TEXT("r.DoTiledReflections"),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ReflectionEnvironment.cpp:117

Scope (from outer to inner):

file
function     FVector GetReflectionEnvironmentRoughnessMixingScaleBiasAndLargestWeight

Source code excerpt:

	if (GReflectionEnvironmentLightmapMixing == 0)
	{
		return FVector(0, 0, GReflectionEnvironmentLightmapMixLargestWeight);
	}

	if (GReflectionEnvironmentEndMixingRoughness == 0.0f && GReflectionEnvironmentBeginMixingRoughness == 0.0f)
	{
		// Make sure a Roughness of 0 results in full mixing when disabling roughness-based mixing
		return FVector(0, 1, GReflectionEnvironmentLightmapMixLargestWeight);
	}

	if (!GReflectionEnvironmentLightmapMixBasedOnRoughness)
	{
		return FVector(0, 1, GReflectionEnvironmentLightmapMixLargestWeight);
	}

	return FVector(RoughnessMixingRange, -GReflectionEnvironmentBeginMixingRoughness * RoughnessMixingRange, GReflectionEnvironmentLightmapMixLargestWeight);
}

bool IsReflectionEnvironmentAvailable(ERHIFeatureLevel::Type InFeatureLevel)
{
	return (SupportsTextureCubeArray(InFeatureLevel)) && (GetReflectionEnvironmentCVar() != 0);
}