r.MeshCardRepresentation
r.MeshCardRepresentation
#Overview
name: r.MeshCardRepresentation
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.MeshCardRepresentation is to control the use of mesh card representations in Unreal Engine 5. Mesh card representations are simplified versions of 3D meshes used to optimize rendering and lighting calculations, particularly in the Lumen global illumination system.
This setting variable is primarily used by the rendering system, specifically the Lumen global illumination subsystem. It is referenced in the Engine and Renderer modules of Unreal Engine 5.
The value of this variable is set as a console variable, initialized with a default value of 1. It can be changed at runtime through console commands or project settings.
This variable interacts with other related settings, such as r.MeshCardRepresentation.MinDensity, which is defined alongside it in the MeshCardRepresentation.cpp file.
Developers should be aware that this variable is marked as ECVF_ReadOnly, meaning its value should not be changed frequently during runtime. It’s primarily intended to be set at the start of the application or in project settings.
Best practices when using this variable include:
- Ensure it is enabled (set to 1) when using Lumen global illumination for better performance and quality.
- Consider the performance implications of enabling or disabling mesh card representations, especially on different target platforms.
- Use in conjunction with other Lumen-related settings for optimal results.
- Test the impact of enabling or disabling this feature on your specific project, as its effectiveness may vary depending on the complexity of your scenes and the target hardware.
When modifying this setting, developers should also consider adjusting related settings like the minimum density of mesh cards to find the right balance between performance and visual quality for their specific use case.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/MeshCardRepresentation.cpp:43
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarCardRepresentation(
TEXT("r.MeshCardRepresentation"),
1,
TEXT(""),
ECVF_ReadOnly);
static TAutoConsoleVariable<float> CVarCardRepresentationMinDensity(
TEXT("r.MeshCardRepresentation.MinDensity"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/MeshCardRepresentation.cpp:125
Scope (from outer to inner):
file
function void BeginCacheMeshCardRepresentation
Source code excerpt:
void BeginCacheMeshCardRepresentation(const ITargetPlatform* TargetPlatform, UStaticMesh* StaticMeshAsset, FStaticMeshRenderData& RenderData, const FString& DistanceFieldKey, FSourceMeshDataForDerivedDataTask* OptionalSourceMeshData)
{
static const auto CVarCards = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MeshCardRepresentation"));
if (CVarCards->GetValueOnAnyThread() != 0)
{
const FMeshBuildSettings& BuildSettings = StaticMeshAsset->GetSourceModel(0).BuildSettings;
FString Key = BuildCardRepresentationDerivedDataKey(DistanceFieldKey, BuildSettings.MaxLumenMeshCards);
if (RenderData.LODResources.IsValidIndex(0))
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenScene.cpp:549
Scope (from outer to inner):
file
function FLumenSceneData::FLumenSceneData
Source code excerpt:
bFinalLightingAtlasContentsValid(false)
{
static const auto MeshCardCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MeshCardRepresentation"));
bTrackAllPrimitives = (DoesPlatformSupportLumenGI(ShaderPlatform))
&& MeshCardCVar->GetValueOnGameThread() != 0
&& WorldType != EWorldType::EditorPreview;
}