r.MipMapLODBias

r.MipMapLODBias

#Overview

name: r.MipMapLODBias

This variable is created as a Console Variable (cvar).

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:

  1. The valid range for this variable is -15.0 to 15.0.
  2. Changes to this variable are render thread safe and can affect scalability.
  3. Modifying this value will impact all 2D textures in the scene.

Best practices when using this variable include:

  1. Use it sparingly and with caution, as it affects all 2D textures globally.
  2. Test thoroughly after adjusting the value to ensure desired visual quality and performance.
  3. Consider using it in conjunction with other LOD and texture streaming settings for optimal results.
  4. Document any changes made to this variable in project settings or configuration files.

Regarding the associated variable CVarSetMipMapLODBias:

#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())