r.LumenScene.SurfaceCache.NaniteLODScaleFactor

r.LumenScene.SurfaceCache.NaniteLODScaleFactor

#Overview

name: r.LumenScene.SurfaceCache.NaniteLODScaleFactor

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.LumenScene.SurfaceCache.NaniteLODScaleFactor is to control the LOD (Level of Detail) level used when capturing Nanite meshes into the surface cache for Lumen scene rendering.

This setting variable is primarily used by the Lumen rendering system, which is part of Unreal Engine’s advanced lighting and global illumination solution. Specifically, it’s utilized in the surface cache component of Lumen, which is responsible for storing and managing scene geometry information for efficient lighting calculations.

The value of this variable is set through the Unreal Engine console system. It’s defined as a TAutoConsoleVariable with a default value of 1.0f. The value can be changed at runtime through console commands or programmatically.

The associated variable GLumenSceneSurfaceCacheNaniteLODScaleFactor directly interacts with this setting. It’s used to store and access the value of the console variable within the C++ code.

Developers should be aware that changing this variable will affect the level of detail used for Nanite meshes in the Lumen surface cache. A higher value will result in using a higher LOD (less detailed), while a lower value will use a lower LOD (more detailed). This can impact both rendering quality and performance.

Best practices when using this variable include:

  1. Adjusting it carefully to balance between visual quality and performance.
  2. Testing the impact of different values in various scenes to find the optimal setting for your specific use case.
  3. Being aware that changes to this variable will trigger a reset of the surface cache (as evident from the DebugResetSurfaceCache() call in the console variable delegate).

Regarding the associated variable GLumenSceneSurfaceCacheNaniteLODScaleFactor:

This is a static TAutoConsoleVariable that directly corresponds to the r.LumenScene.SurfaceCache.NaniteLODScaleFactor console variable. It’s used within the engine code to access the current value of the setting.

The purpose of this associated variable is to provide a convenient way to access the LOD scale factor value in C++ code, particularly in the render thread. It’s used in the FCardPageRenderData constructor to set the NaniteLODScaleFactor member variable.

Developers should be aware that this variable is accessed on the render thread (as seen in the GetValueOnRenderThread() call), which is important for thread safety considerations.

When working with this associated variable, best practices include:

  1. Always access it using GetValueOnRenderThread() when in render thread code.
  2. Be aware that changes to this variable will trigger a surface cache reset, which could have performance implications.
  3. Consider the potential impact on rendering quality and performance when modifying this value, especially in performance-critical sections of code.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneCardCapture.cpp:25

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> GLumenSceneSurfaceCacheNaniteLODScaleFactor(
	TEXT("r.LumenScene.SurfaceCache.NaniteLODScaleFactor"),
	1.0f,
	TEXT("Controls which LOD level will be used to capture Nanite meshes into surface cache."),
	FConsoleVariableDelegate::CreateLambda([](IConsoleVariable* InVariable)
	{
		Lumen::DebugResetSurfaceCache();
	}),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneCardCapture.cpp:24

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> GLumenSceneSurfaceCacheNaniteLODScaleFactor(
	TEXT("r.LumenScene.SurfaceCache.NaniteLODScaleFactor"),
	1.0f,
	TEXT("Controls which LOD level will be used to capture Nanite meshes into surface cache."),
	FConsoleVariableDelegate::CreateLambda([](IConsoleVariable* InVariable)
	{
		Lumen::DebugResetSurfaceCache();

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneCardCapture.cpp:753

Scope (from outer to inner):

file
function     FCardPageRenderData::FCardPageRenderData

Source code excerpt:

	ensure(CardIndex >= 0 && PageTableIndex >= 0);

	NaniteLODScaleFactor = GLumenSceneSurfaceCacheNaniteLODScaleFactor.GetValueOnRenderThread();

	UpdateViewMatrices(InMainView);
}

FCardPageRenderData::~FCardPageRenderData() = default;