r.MipMapLODBias
r.MipMapLODBias
#Overview
name: r.MipMapLODBias
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Apply additional mip map bias for all 2D textures, range of -15.0 to 15.0
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.MipMapLODBias is to apply an additional mip map bias for all 2D textures in the rendering system. This setting variable allows developers to adjust the level of detail (LOD) for textures, affecting the visual quality and performance of texture rendering.
This setting variable is primarily used by the Unreal Engine’s rendering system, specifically in the texture management and rendering pipeline. It is defined and used in the Engine module, as evidenced by its location in the Engine/Source/Runtime/Engine/Private/Texture2D.cpp file.
The value of this variable is set through the console variable system in Unreal Engine. It is initialized with a default value of 0.0f and can be changed at runtime using console commands or through configuration files.
The associated variable CVarSetMipMapLODBias interacts directly with r.MipMapLODBias. They share the same value and purpose. CVarSetMipMapLODBias is used to access and modify the value of r.MipMapLODBias within the C++ code.
Developers must be aware of the following when using this variable:
- The valid range for this variable is -15.0 to 15.0.
- Changes to this variable are render thread safe and can affect scalability.
- Modifying this value will impact all 2D textures in the scene.
Best practices when using this variable include:
- Use it sparingly and with caution, as it affects all 2D textures globally.
- Test thoroughly after adjusting the value to ensure desired visual quality and performance.
- Consider using it in conjunction with other LOD and texture streaming settings for optimal results.
- Document any changes made to this variable in project settings or configuration files.
Regarding the associated variable CVarSetMipMapLODBias:
- Its purpose is to provide a programmatic way to access and modify the r.MipMapLODBias value.
- It is used within the Engine module, specifically in the texture rendering system.
- The value is set and retrieved using the TAutoConsoleVariable template class, which provides thread-safe access.
- It interacts directly with r.MipMapLODBias, sharing the same value and purpose.
- Developers should be aware that this variable is used to implement the functionality of r.MipMapLODBias in the C++ code.
- Best practices include using the GetValueOnAnyThread() method to retrieve the value safely from multiple threads, as demonstrated in the GetGlobalMipMapLODBias() function.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Texture2D.cpp:73
Scope: file
Source code excerpt:
/** CVars */
static TAutoConsoleVariable<float> CVarSetMipMapLODBias(
TEXT("r.MipMapLODBias"),
0.0f,
TEXT("Apply additional mip map bias for all 2D textures, range of -15.0 to 15.0"),
ECVF_RenderThreadSafe | ECVF_Scalability);
TAutoConsoleVariable<int32> CVarFlushRHIThreadOnSTreamingTextureLocks(
TEXT("r.FlushRHIThreadOnSTreamingTextureLocks"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarSetMipMapLODBias
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Texture2D.cpp:72
Scope: file
Source code excerpt:
/** CVars */
static TAutoConsoleVariable<float> CVarSetMipMapLODBias(
TEXT("r.MipMapLODBias"),
0.0f,
TEXT("Apply additional mip map bias for all 2D textures, range of -15.0 to 15.0"),
ECVF_RenderThreadSafe | ECVF_Scalability);
TAutoConsoleVariable<int32> CVarFlushRHIThreadOnSTreamingTextureLocks(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Texture2D.cpp:1426
Scope (from outer to inner):
file
function float UTexture2D::GetGlobalMipMapLODBias
Source code excerpt:
float UTexture2D::GetGlobalMipMapLODBias()
{
float BiasOffset = CVarSetMipMapLODBias.GetValueOnAnyThread(); // called from multiple threads.
return FMath::Clamp(BiasOffset, -15.0f, 15.0f);
}
void UTexture2D::RefreshSamplerStates()
{
if (GetResource())