r.MeshCardRepresentation.MinDensity

r.MeshCardRepresentation.MinDensity

#Overview

name: r.MeshCardRepresentation.MinDensity

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.MeshCardRepresentation.MinDensity is to control the minimum density threshold for spawning mesh card representations in Unreal Engine 5’s rendering system. This setting variable is used to determine how much of a filled area needs to be present for a card to be spawned, with a range of 0 to 1.

This setting variable is primarily used in the rendering system, specifically in the mesh card representation subsystem. Based on the callsites, it appears to be part of the Engine module, as the code is located in the Engine/Source/Runtime/Engine directory.

The value of this variable is set as a console variable using TAutoConsoleVariable. It has a default value of 0.2f and is marked as read-only (ECVF_ReadOnly).

The variable interacts with its associated variable CVarCardRepresentationMinDensity, which shares the same value. This associated variable is used to retrieve the actual value in the GetMinDensity() function of the MeshCardRepresentation class.

Developers must be aware that this variable affects the performance and visual quality trade-off in mesh card representation. A lower value will result in more cards being spawned, potentially increasing visual fidelity but at the cost of performance. A higher value will reduce the number of cards, improving performance but potentially reducing visual quality.

Best practices when using this variable include:

  1. Experimenting with different values to find the optimal balance between performance and visual quality for your specific use case.
  2. Considering the target hardware and performance requirements when adjusting this value.
  3. Using it in conjunction with other mesh card representation settings for fine-tuning.

Regarding the associated variable CVarCardRepresentationMinDensity:

The purpose of CVarCardRepresentationMinDensity is to provide a programmatic interface to access and modify the r.MeshCardRepresentation.MinDensity value within the engine’s code.

This variable is used directly in the MeshCardRepresentation class to retrieve the current minimum density value. It’s part of the Engine module and is closely tied to the mesh card representation system.

The value of CVarCardRepresentationMinDensity is set when the r.MeshCardRepresentation.MinDensity console variable is initialized.

CVarCardRepresentationMinDensity interacts directly with the r.MeshCardRepresentation.MinDensity console variable, effectively serving as its in-code representation.

Developers should be aware that this variable is used to retrieve the actual value in runtime code, and any changes to r.MeshCardRepresentation.MinDensity will be reflected through this variable.

Best practices for using CVarCardRepresentationMinDensity include:

  1. Using the GetValueOnAnyThread() method to retrieve the current value, as shown in the GetMinDensity() function.
  2. Being aware that the value is clamped between 0.0f and 1.0f when retrieved through GetMinDensity().
  3. Considering thread safety when accessing this variable, as it’s designed to be read from any thread.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/MeshCardRepresentation.cpp:49

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarCardRepresentationMinDensity(
	TEXT("r.MeshCardRepresentation.MinDensity"),
	0.2f,
	TEXT("How much of filled area needs to be there to spawn a card, [0;1] range."),
	ECVF_ReadOnly);

static TAutoConsoleVariable<float> CVarCardRepresentationNormalTreshold(
	TEXT("r.MeshCardRepresentation.NormalTreshold"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/MeshCardRepresentation.cpp:48

Scope: file

Source code excerpt:

	ECVF_ReadOnly);

static TAutoConsoleVariable<float> CVarCardRepresentationMinDensity(
	TEXT("r.MeshCardRepresentation.MinDensity"),
	0.2f,
	TEXT("How much of filled area needs to be there to spawn a card, [0;1] range."),
	ECVF_ReadOnly);

static TAutoConsoleVariable<float> CVarCardRepresentationNormalTreshold(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/MeshCardRepresentation.cpp:74

Scope (from outer to inner):

file
function     float MeshCardRepresentation::GetMinDensity

Source code excerpt:

float MeshCardRepresentation::GetMinDensity()
{
	return FMath::Clamp(CVarCardRepresentationMinDensity.GetValueOnAnyThread(), 0.0f, 1.0f);
}

float MeshCardRepresentation::GetNormalTreshold()
{
	return FMath::Clamp(CVarCardRepresentationNormalTreshold.GetValueOnAnyThread(), 0.0f, 1.0f);
}