r.ViewTextureMipBias.Min
r.ViewTextureMipBias.Min
#Overview
name: r.ViewTextureMipBias.Min
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Automatic view mip bias\'s minimum value (default to -2).
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ViewTextureMipBias.Min is to set the minimum value for the automatic view mip bias in Unreal Engine 5’s rendering system. This setting is used to control the level of detail for textures based on the view distance and resolution.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically in the scene visibility and rendering components. It’s also utilized in the ImgMedia plugin, which suggests it has implications for media-related rendering as well.
The value of this variable is set as a console variable with a default value of -2.0f. It can be changed at runtime through the console or configuration files.
The r.ViewTextureMipBias.Min variable interacts closely with another variable called r.ViewTextureMipBias.Offset. Together, these variables determine the final mip bias applied to textures in the scene.
Developers should be aware that this variable sets a lower limit for the mip bias. A lower value allows for higher detail textures at greater distances, but may impact performance. Conversely, a higher value can improve performance at the cost of texture detail.
Best practices when using this variable include:
- Balancing performance and visual quality by adjusting this value in conjunction with other texture and rendering settings.
- Testing the impact of different values in various scenarios to find the optimal setting for your specific game or application.
- Consider the target hardware when setting this value, as lower-end devices may benefit from a higher minimum to maintain performance.
Regarding the associated variable CVarMinAutomaticViewMipBias:
The purpose of CVarMinAutomaticViewMipBias is to provide a programmatic way to access and modify the r.ViewTextureMipBias.Min value within the engine’s C++ code.
This variable is used in both the Renderer module and the ImgMedia plugin, indicating its importance in core rendering processes and media-related functionality.
The value of CVarMinAutomaticViewMipBias is set by retrieving the console variable r.ViewTextureMipBias.Min, ensuring it always reflects the current setting.
It interacts directly with r.ViewTextureMipBias.Min and is often used in calculations alongside CVarMinAutomaticViewMipBiasOffset to determine the final material texture mip bias.
Developers should be aware that this variable provides a thread-safe way to access the minimum automatic view mip bias setting, and it’s used in performance-critical rendering code.
Best practices for using CVarMinAutomaticViewMipBias include:
- Using it for read-only access to the minimum mip bias value in rendering code.
- Ensuring any modifications to the mip bias are done through the console variable system rather than directly modifying this variable.
- Consider the implications on both the render thread and game thread when accessing or using this variable, as it’s designed to be render thread safe.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneVisibility.cpp:135
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarMinAutomaticViewMipBias(
TEXT("r.ViewTextureMipBias.Min"),
-2.0f,
TEXT("Automatic view mip bias's minimum value (default to -2)."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarMinAutomaticViewMipBiasOffset(
TEXT("r.ViewTextureMipBias.Offset"),
#Loc: <Workspace>/Engine/Plugins/Media/ImgMedia/Source/ImgMedia/Private/ImgMediaSceneViewExtension.cpp:74
Scope (from outer to inner):
file
function void FImgMediaSceneViewExtension::CacheViewInfo
Source code excerpt:
}
static const auto CVarMinAutomaticViewMipBiasOffset = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.ViewTextureMipBias.Offset"));
static const auto CVarMinAutomaticViewMipBias = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.ViewTextureMipBias.Min"));
const float FieldOfViewMultiplier = CVarImgMediaFieldOfViewMultiplier.GetValueOnGameThread();
float ResolutionFraction = InViewFamily.SecondaryViewFraction;
if (InViewFamily.GetScreenPercentageInterface())
{
#Associated Variable and Callsites
This variable is associated with another variable named CVarMinAutomaticViewMipBias
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Media/ImgMedia/Source/ImgMedia/Private/ImgMediaSceneViewExtension.cpp:74
Scope (from outer to inner):
file
function void FImgMediaSceneViewExtension::CacheViewInfo
Source code excerpt:
}
static const auto CVarMinAutomaticViewMipBiasOffset = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.ViewTextureMipBias.Offset"));
static const auto CVarMinAutomaticViewMipBias = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.ViewTextureMipBias.Min"));
const float FieldOfViewMultiplier = CVarImgMediaFieldOfViewMultiplier.GetValueOnGameThread();
float ResolutionFraction = InViewFamily.SecondaryViewFraction;
if (InViewFamily.GetScreenPercentageInterface())
{
#Loc: <Workspace>/Engine/Plugins/Media/ImgMedia/Source/ImgMedia/Private/ImgMediaSceneViewExtension.cpp:127
Scope (from outer to inner):
file
function void FImgMediaSceneViewExtension::CacheViewInfo
Source code excerpt:
const float EffectivePrimaryResolutionFraction = float(Info.ViewportRect.Width()) / (View.UnscaledViewRect.Width() * InViewFamily.SecondaryViewFraction);
Info.MaterialTextureMipBias = -(FMath::Max(-FMath::Log2(EffectivePrimaryResolutionFraction), 0.0f)) + CVarMinAutomaticViewMipBiasOffset->GetValueOnGameThread();
Info.MaterialTextureMipBias = FMath::Max(Info.MaterialTextureMipBias, CVarMinAutomaticViewMipBias->GetValueOnGameThread());
if (!ensureMsgf(!FMath::IsNaN(Info.MaterialTextureMipBias) && FMath::IsFinite(Info.MaterialTextureMipBias), TEXT("Calculated material texture mip bias is invalid, defaulting to zero.")))
{
Info.MaterialTextureMipBias = 0.0f;
}
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneVisibility.cpp:134
Scope: file
Source code excerpt:
ECVF_Scalability | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarMinAutomaticViewMipBias(
TEXT("r.ViewTextureMipBias.Min"),
-2.0f,
TEXT("Automatic view mip bias's minimum value (default to -2)."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarMinAutomaticViewMipBiasOffset(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneVisibility.cpp:4908
Scope (from outer to inner):
file
function void FSceneRenderer::PrepareViewStateForVisibility
Source code excerpt:
View.MaterialTextureMipBias = -(FMath::Max(-FMath::Log2(EffectivePrimaryResolutionFraction), 0.0f) ) + CVarMinAutomaticViewMipBiasOffset.GetValueOnRenderThread();
View.MaterialTextureMipBias = FMath::Max(View.MaterialTextureMipBias, CVarMinAutomaticViewMipBias.GetValueOnRenderThread());
}
else if( CVarTemporalAASamplesValue == 2 )
{
// 2xMSAA
// Pattern docs: http://msdn.microsoft.com/en-us/library/windows/desktop/ff476218(v=vs.85).aspx
// N.