r.CookOutUnusedDetailModeComponents

r.CookOutUnusedDetailModeComponents

#Overview

name: r.CookOutUnusedDetailModeComponents

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

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.CookOutUnusedDetailModeComponents is to control whether components that are not relevant for the current detail mode should be cooked out (removed) during the game’s cooking process.

This setting variable is primarily used by the rendering system and the cooking process in Unreal Engine. It affects how actors and components are handled during the cooking process, particularly in relation to different detail modes.

The Unreal Engine subsystems that rely on this setting variable are:

  1. The rendering system
  2. The cooking system
  3. The actor and component management system

The value of this variable is set through the console variable system. It can be set programmatically or through configuration files. The default value is 0, which means all components are kept regardless of their relevance to the current detail mode.

This variable interacts closely with the r.DetailMode variable, which determines the current detail mode of the game. Together, these variables control how components are handled based on their detail level settings.

Developers must be aware of the following when using this variable:

  1. Setting this to 1 can potentially reduce the size of cooked game data by removing unnecessary components.
  2. However, it may also limit the ability to change detail modes at runtime, as components for higher detail modes might be cooked out.
  3. This setting affects both actors and individual components.

Best practices when using this variable include:

  1. Carefully consider the target platforms and their capabilities before enabling this option.
  2. Ensure that all components are correctly set up with appropriate detail mode settings.
  3. Test thoroughly with this setting enabled to ensure no critical components are unexpectedly removed.
  4. Use in conjunction with proper profiling to balance between file size reduction and runtime flexibility.
  5. Document the use of this setting clearly for the development team, as it can have significant impacts on the final game build.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:54, section: [Mobile DeviceProfile]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:4042

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarCookOutUnusedDetailModeComponents(
	TEXT("r.CookOutUnusedDetailModeComponents"),
	0,
	TEXT("If set, components which are not relevant for the current detail mode will be cooked out.\n"
		 " 0: keep components even if not relevant for the current detail mode.\n"
		 " 1: cook out components not relevant for the current detail mode.\n"),
	ECVF_RenderThreadSafe);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Actor.cpp:539

Scope (from outer to inner):

file
function     bool AActor::NeedsLoadForTargetPlatform

Source code excerpt:

		// get local scalability CVars that could cull this actor
		int32 CVarCullBasedOnDetailLevel;
		if(DeviceProfile->GetConsolidatedCVarValue(TEXT("r.CookOutUnusedDetailModeComponents"), CVarCullBasedOnDetailLevel) && CVarCullBasedOnDetailLevel == 1)
		{
			int32 CVarDetailMode;
			if(DeviceProfile->GetConsolidatedCVarValue(TEXT("r.DetailMode"), CVarDetailMode))
			{
				// Check root component's detail mode.
				// If e.g. the component's detail mode is High and the platform detail is Medium,

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/SceneComponent.cpp:439

Scope (from outer to inner):

file
function     static bool SceneComponentNeedsLoadForTarget

Source code excerpt:

		// get local scalability CVars that could cull this actor
		int32 CVarCullBasedOnDetailLevel;
		if(DeviceProfile->GetConsolidatedCVarValue(TEXT("r.CookOutUnusedDetailModeComponents"), CVarCullBasedOnDetailLevel) && CVarCullBasedOnDetailLevel == 1)
		{
			int32 CVarDetailMode;
			if(DeviceProfile->GetConsolidatedCVarValue(TEXT("r.DetailMode"), CVarDetailMode))
			{
				// Check component's detail mode.
				// If e.g. the component's detail mode is High and the platform detail is Medium,

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:743

Scope (from outer to inner):

file
function     void ScalabilityCVarsSinkCallback

Source code excerpt:


	{
		static const auto CookOutUnusedDetailModeComponents = ConsoleMan.FindTConsoleVariableDataInt(TEXT("r.CookOutUnusedDetailModeComponents"));
		LocalScalabilityCVars.CookOutUnusedDetailModeComponents = CookOutUnusedDetailModeComponents->GetValueOnGameThread();
	}

	{
		static const auto DetailMode = ConsoleMan.FindTConsoleVariableDataInt(TEXT("r.DetailMode"));
		LocalScalabilityCVars.DetailMode = DetailMode->GetValueOnGameThread();