r.VT.PlaybackMipBias

r.VT.PlaybackMipBias

#Overview

name: r.VT.PlaybackMipBias

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.VT.PlaybackMipBias is to apply a mip bias during the playback of recorded feedback requests in the Virtual Texture system of Unreal Engine 5. This setting is primarily used for fine-tuning the rendering of virtual textures.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the Virtual Texture system. This can be seen from the file path where the variable is defined: Engine/Source/Runtime/Renderer/Private/VT/VirtualTextureSystem.cpp.

The value of this variable is set through the console variable system in Unreal Engine. It is defined as a TAutoConsoleVariable with a default value of 0, which means no additional bias is applied by default.

This variable interacts with another variable named CVarVTPlaybackMipBias. They share the same value and are essentially the same variable, with r.VT.PlaybackMipBias being the console command to set the value, and CVarVTPlaybackMipBias being the C++ variable used in the code.

Developers must be aware that this variable affects the mip level selection during virtual texture feedback request playback. A positive value will bias towards lower resolution mips, while a negative value will bias towards higher resolution mips. This can impact both visual quality and performance.

Best practices when using this variable include:

  1. Use it for fine-tuning visual quality and performance of virtual textures.
  2. Be cautious with extreme values as they may significantly impact visual quality or performance.
  3. Test thoroughly with different values to find the optimal setting for your specific use case.

Regarding the associated variable CVarVTPlaybackMipBias:

The purpose of CVarVTPlaybackMipBias is to store and provide access to the mip bias value set by r.VT.PlaybackMipBias within the C++ code of the Virtual Texture system.

This variable is used directly in the Renderer module, specifically in the FVirtualTextureSystem::GatherFeedbackRequests function.

The value of this variable is set automatically by the console variable system when r.VT.PlaybackMipBias is modified.

It interacts with the global mip bias (GetGlobalMipBias()) to calculate the final level bias applied to virtual texture requests.

Developers should be aware that this variable is accessed on the render thread (GetValueOnRenderThread()), which means changes to it will be applied on the next frame.

Best practices for using CVarVTPlaybackMipBias include:

  1. Access it only on the render thread to avoid potential race conditions.
  2. Consider its interaction with the global mip bias when calculating the final bias to apply.
  3. Use it in conjunction with other Virtual Texture system parameters for comprehensive control over virtual texture rendering.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/VirtualTextureSystem.cpp:104

Scope: file

Source code excerpt:

);
static TAutoConsoleVariable<float> CVarVTPlaybackMipBias(
	TEXT("r.VT.PlaybackMipBias"),
	0,
	TEXT("Mip bias to apply during playback of recorded feedback requests."),
	ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarVTNumGatherTasks(
	TEXT("r.VT.NumGatherTasks"),

#Associated Variable and Callsites

This variable is associated with another variable named CVarVTPlaybackMipBias. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/VirtualTextureSystem.cpp:103

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarVTPlaybackMipBias(
	TEXT("r.VT.PlaybackMipBias"),
	0,
	TEXT("Mip bias to apply during playback of recorded feedback requests."),
	ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarVTNumGatherTasks(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/VirtualTextureSystem.cpp:2569

Scope (from outer to inner):

file
function     void FVirtualTextureSystem::GatherFeedbackRequests

Source code excerpt:

			FAddRequestedTilesParameters Parameters;
			Parameters.System = this;
			Parameters.LevelBias = FMath::FloorToInt(CVarVTPlaybackMipBias.GetValueOnRenderThread() + GetGlobalMipBias() + 0.5f);
			Parameters.RequestBuffer = PageRequestPlaybackBuffer.GetData();
			Parameters.NumRequests = PageRequestPlaybackBuffer.Num();
			Parameters.UniquePageList = Allocator.Create<FUniquePageList>();

			FAddRequestedTilesTask::DoTask(Parameters);
			MergedUniquePageList->MergePages(Parameters.UniquePageList);