r.RectLightAtlas.MaxResolution
r.RectLightAtlas.MaxResolution
#Overview
name: r.RectLightAtlas.MaxResolution
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The maximum resolution for storing rect. light textures.\n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RectLightAtlas.MaxResolution is to set the maximum resolution for storing rectangular light textures in Unreal Engine 5’s rendering system. This console variable is used to control the size of the texture atlas used for rectangular lights.
This setting variable is primarily used in the rendering subsystem of Unreal Engine 5, specifically in the RectLightTextureManager module. It’s an important parameter for managing memory and performance related to rectangular light rendering.
The value of this variable is set through the console variable system. It’s defined with a default value of 4096, but can be changed at runtime using console commands or through engine configuration files.
The associated variable CVarRectLightTextureResolution directly interacts with r.RectLightAtlas.MaxResolution. They share the same value and purpose.
Developers must be aware that changing this value affects memory usage and potentially rendering performance. A higher resolution allows for more detailed light textures but requires more memory and may impact performance.
Best practices when using this variable include:
- Balancing between quality and performance based on target hardware.
- Monitoring memory usage when increasing the value.
- Testing thoroughly after changes to ensure no negative impacts on performance or visual quality.
Regarding CVarRectLightTextureResolution: This is the actual console variable object that stores and manages the r.RectLightAtlas.MaxResolution setting. It’s used in the code to retrieve the current value of the setting, particularly in the RectLightAtlas namespace.
The variable is accessed in key functions like PackAtlas and UpdateAtlasTexture, where it determines the maximum size of the atlas texture. Changes to this variable can trigger updates to the atlas layout and texture, potentially affecting rendering performance and quality.
Developers should be aware that this variable is marked as ECVF_RenderThreadSafe, meaning it can be safely accessed from the render thread. When making changes to this value, consider the potential impact on real-time performance and ensure changes are made at appropriate times in the rendering cycle.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RectLightTextureManager.cpp:29
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarRectLightTextureResolution(
TEXT("r.RectLightAtlas.MaxResolution"),
4096,
TEXT("The maximum resolution for storing rect. light textures.\n"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRectLighTextureDebug(
TEXT("r.RectLightAtlas.Debug"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarRectLightTextureResolution
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RectLightTextureManager.cpp:28
Scope: file
Source code excerpt:
// * Support non-square atlas
static TAutoConsoleVariable<int32> CVarRectLightTextureResolution(
TEXT("r.RectLightAtlas.MaxResolution"),
4096,
TEXT("The maximum resolution for storing rect. light textures.\n"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRectLighTextureDebug(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RectLightTextureManager.cpp:1272
Scope (from outer to inner):
file
namespace RectLightAtlas
function static void PackAtlas
Source code excerpt:
TArray<FAtlasSlot>& NewSlots)
{
const int32 MaxAtlasResolution = CVarRectLightTextureResolution.GetValueOnRenderThread();
// Extract slots which are already parts of the current layout from the new/requested slots.
// Estimate of the target resolution;
uint32 TargetPixelCount = 0;
TArray<FAtlasSlot> ValidSlots;
TArray<FAtlasSlot> ValidNewSlots;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RectLightTextureManager.cpp:1537
Scope (from outer to inner):
file
namespace RectLightAtlas
function void UpdateAtlasTexture
Source code excerpt:
// Force update by resetting the atlas layout
static int32 CachedMaxAtlasResolution = CVarRectLightTextureResolution.GetValueOnRenderThread();
const bool bForceUpdate = CVarRectLighForceUpdate.GetValueOnRenderThread() > 0 || CachedMaxAtlasResolution != CVarRectLightTextureResolution.GetValueOnRenderThread();
if (bForceUpdate)
{
CachedMaxAtlasResolution = CVarRectLightTextureResolution.GetValueOnRenderThread();
GRectLightTextureManager.bHasPendingAdds = true;
GRectLightTextureManager.AtlasLayout = FAtlasLayout(FIntPoint(CachedMaxAtlasResolution, CachedMaxAtlasResolution));
for (FAtlasSlot& Slot : GRectLightTextureManager.AtlasSlots)
{
Slot.Rect.Origin = InvalidOrigin;
}