FX.Trail.MaxDistanceTessellation

FX.Trail.MaxDistanceTessellation

#Overview

name: FX.Trail.MaxDistanceTessellation

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 FX.Trail.MaxDistanceTessellation is to control the maximum number of tessellation steps allowed for distance-based tessellation in particle trail effects. This setting is part of Unreal Engine’s particle system, specifically for trail effects.

The Unreal Engine subsystem that relies on this setting variable is the particle system, particularly the trail emitter instances. It’s used in the Engine module, within the ParticleTrail2EmitterInstance.cpp file.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands. It’s initialized with the value of MAX_TRAIL_INDICES.

This variable interacts with another variable named MaxDistanceTessellation. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable limits the tessellation steps for distance-based tessellation. It’s used in conjunction with MaxTangentTessellation to determine the total interpolation count for trail particles.

Best practices when using this variable include:

  1. Consider performance implications when adjusting this value, as higher values may increase tessellation and potentially impact performance.
  2. Use it in conjunction with the DistanceTessellationStepSize parameter of the trail type data for fine-tuning trail appearance.
  3. Be mindful of the MAX_TRAIL_INDICES constant, which sets the upper limit for this variable.

Regarding the associated variable MaxDistanceTessellation:

The purpose of MaxDistanceTessellation is to store the actual value used in the code for limiting distance-based tessellation steps. It’s directly associated with the FX.Trail.MaxDistanceTessellation console variable.

This variable is used in the Engine module, specifically in the ParticleTrail2EmitterInstance for both ribbon and animated trail emitters.

The value of MaxDistanceTessellation is set by the FX.Trail.MaxDistanceTessellation console variable, allowing for runtime adjustments.

It interacts directly with the FX.Trail.MaxDistanceTessellation console variable and is used in calculations alongside MaxTangentTessellation.

Developers should be aware that this variable directly affects the tessellation of particle trails and can impact both visual quality and performance.

Best practices for using MaxDistanceTessellation include:

  1. Adjust it through the FX.Trail.MaxDistanceTessellation console variable for easy tweaking during development.
  2. Balance it with MaxTangentTessellation for optimal trail appearance and performance.
  3. Consider the specific requirements of your trail effects when setting this value, as different effects may benefit from different tessellation limits.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleTrail2EmitterInstance.cpp:62

Scope (from outer to inner):

file
namespace    FXConsoleVariables

Source code excerpt:


	FAutoConsoleVariableRef CVarMaxDistanceTessellation(
		TEXT("FX.Trail.MaxDistanceTessellation"),
		MaxDistanceTessellation,
		TEXT("Maximum tessellation steps allowed for distance based tessellation."),
		ECVF_Default
	);

	FAutoConsoleVariableRef CVarMaxTangentTessellation(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleTrail2EmitterInstance.cpp:58

Scope (from outer to inner):

file
namespace    FXConsoleVariables

Source code excerpt:

namespace FXConsoleVariables
{
	int32 MaxDistanceTessellation = MAX_TRAIL_INDICES;
	int32 MaxTangentTessellation = MAX_TRAIL_INDICES;

	FAutoConsoleVariableRef CVarMaxDistanceTessellation(
		TEXT("FX.Trail.MaxDistanceTessellation"),
		MaxDistanceTessellation,
		TEXT("Maximum tessellation steps allowed for distance based tessellation."),
		ECVF_Default
	);

	FAutoConsoleVariableRef CVarMaxTangentTessellation(
		TEXT("FX.Trail.MaxTangentTessellation"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleTrail2EmitterInstance.cpp:2544

Scope (from outer to inner):

file
function     void FParticleRibbonEmitterInstance::DetermineVertexAndTriangleCount

Source code excerpt:

					//@todo. Need to adjust the tangent diff count when the distance is REALLY small...
					float TangDiff = CheckTangent * TrailTypeData->TangentTessellationScalar;
					int32 InterpCount = FMath::Min(FMath::TruncToInt(DistDiff), FXConsoleVariables::MaxDistanceTessellation) + FMath::Min(FMath::TruncToInt(TangDiff), FXConsoleVariables::MaxTangentTessellation);

					// There always is at least 1 point (the source particle itself)
					InterpCount = (InterpCount > 0) ? InterpCount : 1;

					// Store off the rendering interp count for this particle
					CurrTrailData->RenderingInterpCount = InterpCount;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleTrail2EmitterInstance.cpp:3836

Scope (from outer to inner):

file
function     void FParticleAnimTrailEmitterInstance::DetermineVertexAndTriangleCount

Source code excerpt:

						float CheckDistance = (CurrParticle->Location - PrevParticle->Location).Size();
						float DistDiff = CheckDistance / TrailTypeData->DistanceTessellationStepSize;
						InterpCount += FMath::Min(FMath::TruncToInt(DistDiff), FXConsoleVariables::MaxDistanceTessellation);
					}
					
					if (bApplyTangentTessellation )
					{
						//Alter tessellation based on difference between tangents.
						float CheckTangent = (CurrTrailData->Tangent | PrevTrailData->Tangent);