r.Decal.FadeDurationScale

r.Decal.FadeDurationScale

#Overview

name: r.Decal.FadeDurationScale

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.Decal.FadeDurationScale is to control the scaling of fade durations for decals in the rendering system. It affects the lifetime and fade duration of decals in the game world.

This setting variable is primarily used in the Engine module, specifically within the DecalComponent system. It is part of Unreal Engine’s rendering subsystem, which handles the rendering of decals in the game environment.

The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 1.0f, but can be changed at runtime through console commands or programmatically.

The r.Decal.FadeDurationScale interacts directly with its associated variable CVarDecalFadeDurationScale. They share the same value and purpose. This variable is used in the UDecalComponent::SetFadeOut function to scale the start delay and duration of decal fading.

Developers must be aware that lower values of this variable will shorten the lifetime and fade duration of decals. A value of 0 or very close to 0 will effectively disable decal fading.

Best practices when using this variable include:

  1. Use it to globally adjust decal fade behavior without modifying individual decal components.
  2. Be cautious when setting very low values, as it might make decals disappear too quickly.
  3. Consider performance implications when adjusting this value, as longer fade durations might impact rendering performance.

Regarding the associated variable CVarDecalFadeDurationScale:

The purpose of CVarDecalFadeDurationScale is to provide a programmatic interface to the r.Decal.FadeDurationScale setting. It allows the engine to access and modify the decal fade duration scale through C++ code.

This variable is used within the Engine module, specifically in the DecalComponent system. It’s part of the rendering subsystem that handles decal behavior.

The value of CVarDecalFadeDurationScale is set when the r.Decal.FadeDurationScale console variable is initialized or modified.

CVarDecalFadeDurationScale interacts directly with r.Decal.FadeDurationScale, sharing the same value. It’s used in the UDecalComponent::SetFadeOut function to apply the scaling to decal fade durations.

Developers should be aware that this variable provides a way to access the decal fade duration scale in C++ code. It’s particularly useful when you need to read or modify the scale programmatically.

Best practices for using CVarDecalFadeDurationScale include:

  1. Use GetValueOnGameThread() when accessing the value to ensure thread safety.
  2. Consider caching the value if it’s accessed frequently, to avoid potential performance overhead from repeated console variable lookups.
  3. Be mindful of the performance implications when modifying this value, especially in performance-critical code paths.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/DecalComponent.cpp:19

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarDecalFadeDurationScale(
	TEXT("r.Decal.FadeDurationScale"),
	1.0f,
	TEXT("Scales the per decal fade durations. Lower values shortens lifetime and fade duration. Default is 1.0f.")
	);

FDeferredDecalProxy::FDeferredDecalProxy(const UDecalComponent* InComponent)
	: DrawInGame(InComponent->GetVisibleFlag() && !InComponent->bHiddenInGame)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/DecalComponent.cpp:18

Scope: file

Source code excerpt:

#include UE_INLINE_GENERATED_CPP_BY_NAME(DecalComponent)

static TAutoConsoleVariable<float> CVarDecalFadeDurationScale(
	TEXT("r.Decal.FadeDurationScale"),
	1.0f,
	TEXT("Scales the per decal fade durations. Lower values shortens lifetime and fade duration. Default is 1.0f.")
	);

FDeferredDecalProxy::FDeferredDecalProxy(const UDecalComponent* InComponent)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/DecalComponent.cpp:238

Scope (from outer to inner):

file
function     void UDecalComponent::SetFadeOut

Source code excerpt:

void UDecalComponent::SetFadeOut(float StartDelay, float Duration, bool DestroyOwnerAfterFade /*= true*/)
{
	float FadeDurationScale = CVarDecalFadeDurationScale.GetValueOnGameThread();
	FadeDurationScale = (FadeDurationScale <= UE_SMALL_NUMBER) ? 0.0f : FadeDurationScale;

	FadeStartDelay = StartDelay * FadeDurationScale;
	FadeDuration = Duration * FadeDurationScale;
	bDestroyOwnerAfterFade = DestroyOwnerAfterFade;