ShowFlag.VectorFields

ShowFlag.VectorFields

#Overview

name: ShowFlag.VectorFields

This variable is created as a Console Variable (cvar).

It is referenced in 12 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowFlag.VectorFields is to control the visualization of vector fields in Unreal Engine 5. Vector fields are used in particle systems and other visual effects to influence the movement and behavior of particles.

This setting variable is primarily used in the rendering system, particularly for particle systems and visual effects. It is relied upon by the following Unreal Engine subsystems and modules:

  1. Particle System (FXSystem)
  2. Cascade Particle Editor
  3. Rendering system

The value of this variable is set through the engine’s show flags system, which allows toggling various visualization features. It can be accessed and modified through the EngineShowFlags structure.

The associated variable VectorFields interacts with ShowFlag.VectorFields in several places, particularly in the Cascade particle editor and the FXSystem. They share the same value and are used interchangeably in different contexts.

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

  1. It is primarily a visualization tool and does not affect the actual simulation of particles.
  2. It is disabled by default in shipping builds (SHOWFLAG_FIXED_IN_SHIPPING(0, VectorFields, …)).
  3. Enabling this flag may have performance implications, especially in complex scenes with many vector fields.

Best practices when using this variable include:

  1. Use it primarily during development and debugging of particle systems and effects.
  2. Disable it in shipping builds to avoid unnecessary rendering overhead.
  3. When enabled, be mindful of the performance impact, especially on lower-end hardware.

Regarding the associated variable VectorFields:

The purpose of VectorFields is to represent and manage vector field instances in the particle system. It is used in conjunction with ShowFlag.VectorFields to control the visualization and management of vector fields in the engine.

This variable is primarily used in the FXSystem (Effects System) and is a core part of the particle simulation subsystem. It is typically a list or array that stores FVectorFieldInstance objects.

The value of this variable is set and managed within the FXSystem class. It is modified when vector fields are added to or removed from the system.

Developers should be aware that:

  1. This variable represents actual vector field data, not just visualization settings.
  2. Proper management of this variable is crucial for the correct functioning of particle systems using vector fields.

Best practices for using this variable include:

  1. Ensure proper cleanup of vector field instances when they are no longer needed.
  2. Be mindful of the memory usage when creating and storing many vector field instances.
  3. Use this in conjunction with ShowFlag.VectorFields for debugging and visualizing vector fields in the editor.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:87

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(1, ColorGrading, SFG_PostProcess, NSLOCTEXT("UnrealEd", "ColorGradingSF", "Color Grading"))
/** Visualize vector fields. */
SHOWFLAG_FIXED_IN_SHIPPING(0, VectorFields, SFG_Developer, NSLOCTEXT("UnrealEd", "VectorFieldsSF", "Vector Fields"))
/** Depth of Field */
SHOWFLAG_ALWAYS_ACCESSIBLE(DepthOfField, SFG_PostProcess, NSLOCTEXT("UnrealEd", "DepthOfFieldSF", "Depth Of Field"))
/** Highlight materials that indicate performance issues or show unrealistic materials */
SHOWFLAG_FIXED_IN_SHIPPING(0, GBufferHints, SFG_Developer, NSLOCTEXT("UnrealEd", "GBufferHintsSF", "GBuffer Hints (material attributes)"))
/** MotionBlur, for now only camera motion blur, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(MotionBlur, SFG_PostProcess, NSLOCTEXT("UnrealEd", "MotionBlurSF", "Motion Blur"))

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/Cascade/Private/Cascade.cpp:3799

Scope (from outer to inner):

file
function     void FCascade::OnViewLocalVectorFields

Source code excerpt:

void FCascade::OnViewLocalVectorFields()
{
	ToggleDrawOption(FCascadeEdPreviewViewportClient::VectorFields);
}

bool FCascade::IsViewLocalVectorFieldsChecked() const
{
	return IsDrawOptionEnabled(FCascadeEdPreviewViewportClient::VectorFields);
}

void FCascade::OnRestartSimulation()
{
	RestartParticleSystem();
}

#Loc: <Workspace>/Engine/Source/Editor/Cascade/Private/CascadePreviewViewportClient.cpp:269

Scope (from outer to inner):

file
function     void FCascadeEdPreviewViewportClient::Draw

Source code excerpt:

	}

	EngineShowFlags.SetVectorFields(GetDrawElement(VectorFields));

	CascadePreviewScene.AddComponent(LineBatcher,FTransform::Identity);

	FVector2D ScaledViewportSize = FVector2D(InViewport->GetSizeXY()) / Canvas->GetDPIScale();
	FEditorViewportClient::Draw(InViewport, Canvas);

#Loc: <Workspace>/Engine/Source/Editor/Cascade/Private/CascadePreviewViewportClient.h:63

Scope (from outer to inner):

file
class        class FCascadeEdPreviewViewportClient : public FEditorViewportClient

Source code excerpt:

		ParticleTimes = 0x004,
		ParticleMemory = 0x008,
		VectorFields = 0x010,
		Bounds = 0x020,
		WireSphere = 0x040,
		OriginAxis = 0x080,
		Orbit = 0x100,
		ParticleSystemCompleted = 0x200,
		EmitterTickTimes = 0x400

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/FXSystem.cpp:254

Scope (from outer to inner):

file
function     FFXSystem::~FFXSystem

Source code excerpt:

FFXSystem::~FFXSystem()
{
	for (FVectorFieldInstance* VectorFieldInstance : VectorFields)
	{
		if (VectorFieldInstance)
		{
			delete VectorFieldInstance;
		}
	}
	VectorFields.Empty();

	DestroyGPUSimulation();
}

const FName FFXSystem::Name(TEXT("FFXSystem"));

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/FXSystem.cpp:340

Scope (from outer to inner):

file
function     void FFXSystem::AddVectorField
lambda-function

Source code excerpt:

				{
					Instance->UpdateTransforms( ComponentToWorld );
					Instance->Index = FXSystem->VectorFields.AddUninitialized().Index;
					FXSystem->VectorFields[ Instance->Index ] = Instance;
				});
		}
	}
}

void FFXSystem::RemoveVectorField( UVectorFieldComponent* VectorFieldComponent )

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/FXSystem.cpp:365

Scope (from outer to inner):

file
function     void FFXSystem::RemoveVectorField
lambda-function

Source code excerpt:

					if ( Instance->Index != INDEX_NONE )
					{
						FXSystem->VectorFields.RemoveAt( Instance->Index );
						delete Instance;
					}
				});
		}
	}
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/FXSystemPrivate.h:370

Scope (from outer to inner):

file
class        class FFXSystem : public FFXSystemInterface

Source code excerpt:


	/** List of all vector field instances. */
	FVectorFieldInstanceList VectorFields;
	/** List of all active GPU simulations. */
	TSparseArray<FParticleSimulationGPU*> GPUSimulations;
	/** Number of simulations of each type. */
	int32 NumGPUSimulations[EParticleSimulatePhase::Last + 1] = {};
	/** Particle render resources. */
	FParticleSimulationResources* ParticleSimulationResources;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:3080

Scope (from outer to inner):

file
function     virtual void GetDynamicMeshElementsEmitter

Source code excerpt:


				const bool bHaveLocalVectorField = Simulation && Simulation->LocalVectorField.Resource;
				if (bHaveLocalVectorField && ViewFamily.EngineShowFlags.VectorFields)
				{
					// Create a vertex factory for visualization if needed.
					Simulation->CreateVectorFieldVisualizationVertexFactory(RHICmdList, FeatureLevel);
					check(Simulation->VectorFieldVisualizationVertexFactory);
					DrawVectorFieldBounds(Collector.GetPDI(ViewIndex), View, &Simulation->LocalVectorField);
					GetVectorFieldMesh(Simulation->VectorFieldVisualizationVertexFactory, &Simulation->LocalVectorField, ViewIndex, Collector);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleSystemRender.cpp:6862

Scope (from outer to inner):

file
function     FPrimitiveViewRelevance FParticleSystemSceneProxy::GetViewRelevance

Source code excerpt:

		MaterialRelevance.SetPrimitiveViewRelevance(Result);
	}
	if (View->Family->EngineShowFlags.Bounds || View->Family->EngineShowFlags.VectorFields)
	{
		Result.bOpaque = true;
	}
	// see if any of the emitters use dynamic vertex data
	if (DynamicData == NULL)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VectorField.cpp:753

Scope (from outer to inner):

file
class        class FVectorFieldSceneProxy final : public FPrimitiveSceneProxy
function     virtual void GetDynamicMeshElements

Source code excerpt:


				// Draw a visualization of the vectors contained in the field when selected.
				if (IsSelected() || View->Family->EngineShowFlags.VectorFields)
				{
					FVectorFieldCollectorResources& CollectorResources = Collector.AllocateOneFrameResource<FVectorFieldCollectorResources>(View->GetFeatureLevel());
					CollectorResources.VisualizationVertexFactory.InitResource(Collector.GetRHICommandList());

					GetVectorFieldMesh(&CollectorResources.VisualizationVertexFactory, VectorFieldInstance, ViewIndex, Collector);
				}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:87

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(1, ColorGrading, SFG_PostProcess, NSLOCTEXT("UnrealEd", "ColorGradingSF", "Color Grading"))
/** Visualize vector fields. */
SHOWFLAG_FIXED_IN_SHIPPING(0, VectorFields, SFG_Developer, NSLOCTEXT("UnrealEd", "VectorFieldsSF", "Vector Fields"))
/** Depth of Field */
SHOWFLAG_ALWAYS_ACCESSIBLE(DepthOfField, SFG_PostProcess, NSLOCTEXT("UnrealEd", "DepthOfFieldSF", "Depth Of Field"))
/** Highlight materials that indicate performance issues or show unrealistic materials */
SHOWFLAG_FIXED_IN_SHIPPING(0, GBufferHints, SFG_Developer, NSLOCTEXT("UnrealEd", "GBufferHintsSF", "GBuffer Hints (material attributes)"))
/** MotionBlur, for now only camera motion blur, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(MotionBlur, SFG_PostProcess, NSLOCTEXT("UnrealEd", "MotionBlurSF", "Motion Blur"))