r.ViewTextureMipBias.Offset
r.ViewTextureMipBias.Offset
#Overview
name: r.ViewTextureMipBias.Offset
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Automatic view mip bias\'s constant offset (default to -0.3).
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ViewTextureMipBias.Offset is to provide a constant offset for the automatic view mip bias calculation in Unreal Engine’s rendering system. This setting variable is primarily used in the rendering subsystem to adjust the mip level selection for textures, which can affect the visual quality and performance of the rendered scene.
Based on the callsites, this setting variable is used in the Renderer module and the ImgMedia plugin. It’s particularly relevant in scene visibility calculations and image media rendering.
The value of this variable is set as a console variable with a default value of -0.3. It can be modified at runtime through the console or programmatically.
This variable interacts closely with another variable called r.ViewTextureMipBias.Min, which sets the minimum value for the automatic view mip bias. Together, these variables control the final mip bias applied to textures.
Developers should be aware that modifying this variable can affect the sharpness and detail of textures in the rendered scene. A more negative value will tend to select higher resolution mip levels, potentially increasing visual quality at the cost of performance and memory usage.
Best practices when using this variable include:
- Testing different values to find the optimal balance between visual quality and performance for your specific project.
- Being cautious about setting very low (highly negative) values, as this could significantly impact performance.
- Considering the interaction with r.ViewTextureMipBias.Min when adjusting this offset.
Regarding the associated variable CVarMinAutomaticViewMipBiasOffset:
The purpose of CVarMinAutomaticViewMipBiasOffset is to provide a programmatic way to access and modify the r.ViewTextureMipBias.Offset value within the engine’s C++ code.
This variable is used in both the Renderer module and the ImgMedia plugin to retrieve the current value of the offset for calculations related to material texture mip bias.
The value of this variable is set by the console variable system and can be accessed using GetValueOnRenderThread() or GetValueOnGameThread() depending on the context.
CVarMinAutomaticViewMipBiasOffset interacts directly with the r.ViewTextureMipBias.Offset console variable, essentially serving as its C++ representation within the engine code.
Developers should be aware that this variable provides thread-safe access to the offset value and should be used instead of directly accessing the console variable in multi-threaded contexts.
Best practices for using CVarMinAutomaticViewMipBiasOffset include:
- Using the appropriate thread-specific getter (GetValueOnRenderThread or GetValueOnGameThread) based on the current execution context.
- Caching the variable for repeated use within a function to avoid multiple lookups.
- Being aware that changes to this variable will affect the entire rendering pipeline and should be done cautiously.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneVisibility.cpp:141
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarMinAutomaticViewMipBiasOffset(
TEXT("r.ViewTextureMipBias.Offset"),
-0.3,
TEXT("Automatic view mip bias's constant offset (default to -0.3)."),
ECVF_RenderThreadSafe);
static int32 GILCUpdatePrimTaskEnabled = 1;
#Loc: <Workspace>/Engine/Plugins/Media/ImgMedia/Source/ImgMedia/Private/ImgMediaSceneViewExtension.cpp:73
Scope (from outer to inner):
file
function void FImgMediaSceneViewExtension::CacheViewInfo
Source code excerpt:
return;
}
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 CVarMinAutomaticViewMipBiasOffset
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Media/ImgMedia/Source/ImgMedia/Private/ImgMediaSceneViewExtension.cpp:73
Scope (from outer to inner):
file
function void FImgMediaSceneViewExtension::CacheViewInfo
Source code excerpt:
return;
}
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:126
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:140
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarMinAutomaticViewMipBiasOffset(
TEXT("r.ViewTextureMipBias.Offset"),
-0.3,
TEXT("Automatic view mip bias's constant offset (default to -0.3)."),
ECVF_RenderThreadSafe);
static int32 GILCUpdatePrimTaskEnabled = 1;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneVisibility.cpp:4907
Scope (from outer to inner):
file
function void FSceneRenderer::PrepareViewStateForVisibility
Source code excerpt:
SampleY = Halton(TemporalSampleIndex + 1, 3) - 0.5f;
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