r.RectLightAtlas.MaxTextureRatio

r.RectLightAtlas.MaxTextureRatio

#Overview

name: r.RectLightAtlas.MaxTextureRatio

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.RectLightAtlas.MaxTextureRatio is to define the maximum width-to-height or height-to-width ratio that a texture can have in the Rect Light Atlas system. This setting is part of Unreal Engine’s rendering system, specifically for managing textures used in rectangular light sources.

This setting variable is primarily used in the Renderer module of Unreal Engine, as evidenced by its location in the RectLightTextureManager.cpp file within the Renderer’s private directory.

The value of this variable is set using a console variable (CVarRectLighMaxTextureRatio) with a default value of 2. It can be changed at runtime through console commands or programmatically.

The associated variable CVarRectLighMaxTextureRatio directly interacts with r.RectLightAtlas.MaxTextureRatio. They share the same value and purpose.

Developers must be aware that this variable affects the resolution and aspect ratio of textures used for rectangular lights. It’s used to clamp the aspect ratio of these textures, which can impact both performance and visual quality.

Best practices when using this variable include:

  1. Keeping the value reasonable (between 1 and 16) to maintain a balance between flexibility and performance.
  2. Adjusting it if you notice issues with rectangular light textures being overly distorted or consuming too much memory.
  3. Testing different values to find the optimal balance for your specific use case.

Regarding the associated variable CVarRectLighMaxTextureRatio:

The purpose of CVarRectLighMaxTextureRatio is identical to r.RectLightAtlas.MaxTextureRatio. It’s the actual console variable that controls the setting.

This variable is used in the Renderer module, specifically in the RectLightAtlas namespace within the RectLightTextureManager.cpp file.

The value is set when the console variable is initialized, but can be changed at runtime using console commands.

It directly interacts with the r.RectLightAtlas.MaxTextureRatio setting, as they represent the same value.

Developers should be aware that changes to this variable will immediately affect the behavior of the Rect Light Atlas system.

Best practices include:

  1. Using the console variable to experiment with different values during development.
  2. Documenting any changes made to this variable in project settings or documentation.
  3. Considering the impact on performance and visual quality when adjusting this value.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RectLightTextureManager.cpp:59

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRectLighMaxTextureRatio(
	TEXT("r.RectLightAtlas.MaxTextureRatio"),
	2,
	TEXT("Define the max Width/Height or Height/Width ratio that a texture can have."),
	ECVF_RenderThreadSafe);

namespace RectLightAtlas
{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RectLightTextureManager.cpp:58

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarRectLighMaxTextureRatio(
	TEXT("r.RectLightAtlas.MaxTextureRatio"),
	2,
	TEXT("Define the max Width/Height or Height/Width ratio that a texture can have."),
	ECVF_RenderThreadSafe);

namespace RectLightAtlas

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RectLightTextureManager.cpp:99

Scope (from outer to inner):

file
namespace    RectLightAtlas
function     FIntPoint GetSourceResolution

Source code excerpt:

		Out = FIntPoint(SourceOriginalResolution.X, SourceOriginalResolution.Y);
		// Max Ratio of 2
		const float RatioThreshold = FMath::Clamp(CVarRectLighMaxTextureRatio.GetValueOnAnyThread(), 1, 16);
		if (RatioYX > RatioThreshold)
		{
			Out.X *= RatioYX / RatioThreshold;
		}
		else if (RatioXY > RatioThreshold)
		{