r.TexturesCookToDerivedDataReferences

r.TexturesCookToDerivedDataReferences

#Overview

name: r.TexturesCookToDerivedDataReferences

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.TexturesCookToDerivedDataReferences is to control whether cooked textures are serialized using Derived Data References in Unreal Engine 5.

This setting variable is primarily used in the texture cooking and serialization process within the Engine module, specifically in the texture derived data system. It’s part of the rendering and asset processing pipeline.

The value of this variable is set through a console variable (CVar) system. It’s defined as a static TAutoConsoleVariable with an initial value of 0, meaning it’s disabled by default.

The associated variable CVarTexturesCookToDerivedDataReferences directly interacts with r.TexturesCookToDerivedDataReferences. They share the same value and purpose.

Developers must be aware that this variable is marked as ECVF_ReadOnly, which means its value should not be changed at runtime. It’s intended to be set before the engine initialization or through configuration files.

Best practices when using this variable include:

  1. Only enable it when you specifically need to serialize cooked textures using Derived Data References.
  2. Be cautious about enabling it in production builds, as it may affect performance and storage requirements.
  3. Test thoroughly when changing this setting, as it can impact how textures are stored and loaded in cooked builds.

The associated variable CVarTexturesCookToDerivedDataReferences is used in the SerializePlatformData function to determine whether to use derived data for texture serialization. This check is only performed in editor builds (#if WITH_EDITOR), which suggests that this setting is primarily for development and cooking processes rather than runtime behavior in shipped games.

When working with this variable, developers should consider the implications on build times, package sizes, and runtime performance, especially for projects with a large number of textures or frequent texture updates.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/TextureDerivedData.cpp:47

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarTexturesCookToDerivedDataReferences(
	TEXT("r.TexturesCookToDerivedDataReferences"),
	0,
	TEXT("Whether cooked textures are serialized using Derived Data References."),
	ECVF_ReadOnly);

/*------------------------------------------------------------------------------
	Versioning for texture derived data.

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/TextureDerivedData.cpp:46

Scope: file

Source code excerpt:

#include "TextureEncodingSettings.h"

static TAutoConsoleVariable<int32> CVarTexturesCookToDerivedDataReferences(
	TEXT("r.TexturesCookToDerivedDataReferences"),
	0,
	TEXT("Whether cooked textures are serialized using Derived Data References."),
	ECVF_ReadOnly);

/*------------------------------------------------------------------------------

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/TextureDerivedData.cpp:2693

Scope (from outer to inner):

file
function     static void SerializePlatformData

Source code excerpt:

		bUsingDerivedData = !bIsVirtual && Ar.IsSaving() && Ar.IsFilterEditorOnly();
	#if WITH_EDITOR
		bUsingDerivedData &= CVarTexturesCookToDerivedDataReferences.GetValueOnAnyThread() != 0;
	#endif
		Ar.Serialize(&bUsingDerivedData, sizeof(bool));
		static_assert(sizeof(bool) == 1);
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////