r.VT.MaxAnisotropy
r.VT.MaxAnisotropy
#Overview
name: r.VT.MaxAnisotropy
The value of this variable can be defined or overridden in .ini config files. 5
.ini config files referencing this setting variable.
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
MaxAnisotropy setting for Virtual Texture sampling.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VT.MaxAnisotropy is to control the maximum anisotropy setting for Virtual Texture sampling in Unreal Engine 5. This setting is primarily related to the rendering system, specifically the Virtual Texturing (VT) subsystem.
The Unreal Engine subsystem that relies on this setting variable is the Virtual Texturing system, which is part of the rendering pipeline. It’s used in the Engine module, particularly in the VirtualTextureScalability namespace and the material rendering process.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 8 in the VirtualTextureScalability namespace.
This variable interacts with another variable called r.VT.AnisotropicFiltering. Together, they determine the actual anisotropic filtering applied to virtual textures.
Developers must be aware that:
- This setting affects the quality of virtual texture rendering, particularly at oblique viewing angles.
- Higher values can improve texture quality but may impact performance.
- The setting is marked as render thread safe and scalable, meaning it can be adjusted dynamically and may be affected by scalability settings.
Best practices when using this variable include:
- Balance between visual quality and performance based on target hardware.
- Consider using it in conjunction with r.VT.AnisotropicFiltering for fine-tuned control.
- Test different values to find the optimal setting for your specific use case.
Regarding the associated variable CVarVTMaxAnisotropy:
The purpose of CVarVTMaxAnisotropy is to provide a programmatic interface to the r.VT.MaxAnisotropy setting within the engine’s C++ code.
This variable is used internally by the Virtual Texturing system to retrieve and apply the maximum anisotropy setting. It’s defined in the VirtualTextureScalability namespace and is used in functions like GetMaxAnisotropy() to provide the current setting value to other parts of the engine.
The value of CVarVTMaxAnisotropy is set automatically based on the r.VT.MaxAnisotropy console variable. It’s updated whenever the console variable changes.
Developers should be aware that:
- Changes to r.VT.MaxAnisotropy will be reflected in CVarVTMaxAnisotropy.
- This variable is used in performance-critical rendering code, so frequent changes might have a performance impact.
Best practices for using CVarVTMaxAnisotropy include:
- Use it for reading the current maximum anisotropy setting in C++ code rather than directly accessing the console variable.
- Be mindful of threading when accessing this variable, as it’s marked as render thread safe.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseScalability.ini:561, section: [TextureQuality@0]
- INI Section:
TextureQuality@0
- Raw value:
4
- Is Array:
False
Location: <Workspace>/Engine/Config/BaseScalability.ini:572, section: [TextureQuality@1]
- INI Section:
TextureQuality@1
- Raw value:
4
- Is Array:
False
Location: <Workspace>/Engine/Config/BaseScalability.ini:583, section: [TextureQuality@2]
- INI Section:
TextureQuality@2
- Raw value:
8
- Is Array:
False
Location: <Workspace>/Engine/Config/BaseScalability.ini:594, section: [TextureQuality@3]
- INI Section:
TextureQuality@3
- Raw value:
8
- Is Array:
False
Location: <Workspace>/Engine/Config/BaseScalability.ini:605, section: [TextureQuality@Cine]
- INI Section:
TextureQuality@Cine
- Raw value:
8
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/VirtualTextureScalability.cpp:117
Scope (from outer to inner):
file
namespace VirtualTextureScalability
Source code excerpt:
static TAutoConsoleVariable<int32> CVarVTMaxAnisotropy(
TEXT("r.VT.MaxAnisotropy"),
8,
TEXT("MaxAnisotropy setting for Virtual Texture sampling."),
ECVF_RenderThreadSafe | ECVF_Scalability
);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Materials/MaterialUniformExpressions.cpp:1418
Scope (from outer to inner):
file
function void FUniformExpressionSet::FillUniformBuffer
Source code excerpt:
static const auto CVarVTAnisotropic = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VT.AnisotropicFiltering"));
const bool VTAnisotropic = CVarVTAnisotropic && CVarVTAnisotropic->GetValueOnAnyThread() != 0;
static const auto CVarVTMaxAnisotropic = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VT.MaxAnisotropy"));
const int32 VTMaxAnisotropic = (VTAnisotropic && CVarVTMaxAnisotropic) ? CVarVTMaxAnisotropic->GetValueOnAnyThread(): 1;
// Now check for runtime virtual texture
if (!bValidResources)
{
const URuntimeVirtualTexture* Texture = nullptr;
GetTextureValue(ExpressionIndex, MaterialRenderContext, MaterialRenderContext.Material, Texture);
#Associated Variable and Callsites
This variable is associated with another variable named CVarVTMaxAnisotropy
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/VirtualTextureScalability.cpp:116
Scope (from outer to inner):
file
namespace VirtualTextureScalability
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_ReadOnly);
static TAutoConsoleVariable<int32> CVarVTMaxAnisotropy(
TEXT("r.VT.MaxAnisotropy"),
8,
TEXT("MaxAnisotropy setting for Virtual Texture sampling."),
ECVF_RenderThreadSafe | ECVF_Scalability
);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/VirtualTextureScalability.cpp:127
Scope (from outer to inner):
file
namespace VirtualTextureScalability
function static void OnUpdate
Source code excerpt:
static void OnUpdate()
{
const float MaxAnisotropy = CVarVTMaxAnisotropy.GetValueOnGameThread();
static float LastMaxAnisotropy = MaxAnisotropy;
static float LastTileCountBiases[3] = { GTileCountBiases[0], GTileCountBiases[1], GTileCountBiases[2] };
bool bUpdate = false;
if (LastMaxAnisotropy != MaxAnisotropy)
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/VirtualTextureScalability.cpp:222
Scope (from outer to inner):
file
namespace VirtualTextureScalability
function int32 GetMaxAnisotropy
Source code excerpt:
int32 GetMaxAnisotropy()
{
return CVarVTMaxAnisotropy.GetValueOnAnyThread();
}
// Begin deprecated functions.
// Can remove include of VirtualTexturePoolConfig.h when these are removed.
float GetPoolSizeScale()
{