r.Nanite.PrimaryRaster.TimeBudgetMs

r.Nanite.PrimaryRaster.TimeBudgetMs

#Overview

name: r.Nanite.PrimaryRaster.TimeBudgetMs

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.Nanite.PrimaryRaster.TimeBudgetMs is to set a time budget in milliseconds for the Nanite primary raster process within Unreal Engine 5’s rendering system.

This setting variable is primarily used by the Nanite subsystem, which is part of Unreal Engine 5’s rendering module. Specifically, it’s utilized in the NaniteCullRaster component of the renderer.

The value of this variable is set through a console variable (CVar) named CVarNanitePrimaryTimeBudgetMs. It’s defined in the NaniteCullRaster.cpp file and can be modified at runtime through console commands or configuration files.

The variable interacts closely with Unreal Engine’s Dynamic Render Scaling system. It’s used in the GetDynamicNaniteScalingPrimarySettings function to set the BudgetMs parameter of a DynamicRenderScaling::FHeuristicSettings structure.

Developers should be aware that this variable directly impacts the performance-quality tradeoff of Nanite rendering. Setting a lower time budget may improve performance but could potentially reduce visual quality, while a higher budget may enhance quality at the cost of performance.

Best practices for using this variable include:

  1. Carefully balancing it with other rendering budgets to maintain overall frame rate targets.
  2. Adjusting it based on the specific needs of your project and target hardware.
  3. Using it in conjunction with other Nanite settings for optimal results.
  4. Monitoring its impact on both performance and visual quality during development.

The associated variable CVarNanitePrimaryTimeBudgetMs is the actual console variable that controls this setting. It’s initialized with a default value of DynamicRenderScaling::FHeuristicSettings::kBudgetMsDisabled, which likely indicates that the time budget is not enforced by default.

This console variable is used to retrieve the current time budget value in the GetDynamicNaniteScalingPrimarySettings function, which suggests that it can be dynamically adjusted during runtime.

When working with CVarNanitePrimaryTimeBudgetMs, developers should:

  1. Understand that changes to this variable will directly affect the r.Nanite.PrimaryRaster.TimeBudgetMs setting.
  2. Be cautious when modifying it at runtime, as it could have immediate impacts on rendering performance and quality.
  3. Consider exposing it as a configurable option for advanced users or for different quality presets in their game settings.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:265

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarNanitePrimaryTimeBudgetMs(
	TEXT("r.Nanite.PrimaryRaster.TimeBudgetMs"),
	DynamicRenderScaling::FHeuristicSettings::kBudgetMsDisabled,
	TEXT("Frame's time budget for Nanite primary raster in milliseconds."),
	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<float> CVarNaniteShadowTimeBudgetMs(
	TEXT("r.Nanite.ShadowRaster.TimeBudgetMs"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:264

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<float> CVarNanitePrimaryTimeBudgetMs(
	TEXT("r.Nanite.PrimaryRaster.TimeBudgetMs"),
	DynamicRenderScaling::FHeuristicSettings::kBudgetMsDisabled,
	TEXT("Frame's time budget for Nanite primary raster in milliseconds."),
	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<float> CVarNaniteShadowTimeBudgetMs(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:291

Scope (from outer to inner):

file
function     static DynamicRenderScaling::FHeuristicSettings GetDynamicNaniteScalingPrimarySettings

Source code excerpt:

	BucketSetting.MinResolutionFraction = DynamicRenderScaling::PercentageToFraction(PixelsPerEdgeScalingPercentage);
	BucketSetting.MaxResolutionFraction = DynamicRenderScaling::PercentageToFraction(100.0f);
	BucketSetting.BudgetMs = CVarNanitePrimaryTimeBudgetMs.GetValueOnAnyThread();
	BucketSetting.ChangeThreshold = DynamicRenderScaling::PercentageToFraction(1.0f);
	BucketSetting.TargetedHeadRoom = DynamicRenderScaling::PercentageToFraction(5.0f); // 5% headroom
	BucketSetting.UpperBoundQuantization = DynamicRenderScaling::FHeuristicSettings::kDefaultUpperBoundQuantization;
	return BucketSetting;
}