r.VT.EnableAutoImport

r.VT.EnableAutoImport

#Overview

name: r.VT.EnableAutoImport

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.VT.EnableAutoImport is to control the automatic import of textures as virtual textures in Unreal Engine 5. This setting variable is primarily used in the rendering system, specifically for managing virtual textures.

This setting variable is relied upon by the core Engine module, the MegascansPlugin, and the Interchange system. It’s used in conjunction with texture import and creation processes.

The value of this variable is set as a console variable, which means it can be adjusted at runtime or set in configuration files. It’s initialized with a default value of 1, meaning it’s enabled by default.

r.VT.EnableAutoImport interacts closely with other virtual texture-related variables, particularly r.VirtualTextures. These two variables are often checked together to determine if virtual textures should be used.

Developers must be aware that this variable affects the automatic conversion of imported textures to virtual textures. When enabled, textures that meet certain size criteria (defined by UTextureImportSettings::AutoVTSize) will be automatically set up as virtual textures.

Best practices when using this variable include:

  1. Ensure it aligns with your project’s performance and memory requirements. Virtual textures can improve performance in some scenarios but may not be suitable for all projects.
  2. Consider the impact on asset import workflows. Enabling this may change how imported textures are processed.
  3. Use in conjunction with other virtual texture settings for fine-tuned control over the virtual texturing system.
  4. Be aware of the performance implications of enabling or disabling this feature, especially for projects with many large textures.
  5. Monitor texture import times and resulting texture quality when this setting is enabled or disabled.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Texture.cpp:68

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarVirtualTexturesAutoImport(
	TEXT("r.VT.EnableAutoImport"),
	1,
	TEXT("Enable virtual texture on texture import"),
	ECVF_Default);

static TAutoConsoleVariable<int32> CVarVirtualTexturesMenuRestricted(
	TEXT("r.VT.MenuRestricted"),

#Loc: <Workspace>/Engine/Plugins/Bridge/Source/MegascansPlugin/Private/Utilities/MiscUtils.cpp:368

Scope (from outer to inner):

file
function     bool AssetUtils::IsVTEnabled

Source code excerpt:

	static const auto CVarVirtualTexturesEnabled = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VirtualTextures"));
	check(CVarVirtualTexturesEnabled);
	static const auto CVarVirtualTexturesImportEnabled = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VT.EnableAutoImport"));
	check(CVarVirtualTexturesEnabled);

	const bool bVirtualTextureEnabled = CVarVirtualTexturesEnabled->GetValueOnAnyThread() != 0;
	const bool bVirtualTextureImportEnabled = CVarVirtualTexturesImportEnabled->GetValueOnAnyThread() != 0;

	if (bVirtualTextureEnabled && bVirtualTextureImportEnabled)

#Loc: <Workspace>/Engine/Plugins/Interchange/Runtime/Source/Import/Private/Texture/InterchangeTextureFactory.cpp:1452

Scope (from outer to inner):

file
namespace    UE::Interchange::Private::InterchangeTextureFactory
function     void SetupTexture2DSourceDataFromPayload

Source code excerpt:

		check(CVarVirtualTexturesEnabled);

		static const auto CVarVirtualTexturesAutoImportEnabled = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VT.EnableAutoImport"));
		check(CVarVirtualTexturesAutoImportEnabled);

		if (CVarVirtualTexturesEnabled->GetValueOnGameThread() && CVarVirtualTexturesAutoImportEnabled->GetValueOnGameThread())
		{
			const int64 VirtualTextureAutoEnableThreshold = GetDefault<UTextureImportSettings>()->AutoVTSize;
			const int64 VirtualTextureAutoEnableThresholdPixels = VirtualTextureAutoEnableThreshold * VirtualTextureAutoEnableThreshold;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Factories/EditorFactories.cpp:4210

Scope (from outer to inner):

file
function     UObject* UTextureFactory::FactoryCreateBinary

Source code excerpt:

	// But that was unintuitive for many users so now for re-imports we will end up ignoring this and respecting the existing setting below.

	static const auto CVarVirtualTexturesAutoImportEnabled = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VT.EnableAutoImport"));
	check(CVarVirtualTexturesAutoImportEnabled);

	if (CVarVirtualTexturesEnabled->GetValueOnAnyThread() && CVarVirtualTexturesAutoImportEnabled->GetValueOnAnyThread())
	{
		const int64 VirtualTextureAutoEnableThreshold = GetDefault<UTextureImportSettings>()->AutoVTSize;
		const int64 VirtualTextureAutoEnableThresholdPixels = VirtualTextureAutoEnableThreshold * VirtualTextureAutoEnableThreshold;