r.Paper2D.DrawTwoSided

r.Paper2D.DrawTwoSided

#Overview

name: r.Paper2D.DrawTwoSided

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.Paper2D.DrawTwoSided is to control whether sprites in Paper2D, Unreal Engine’s 2D game framework, are rendered as two-sided or not.

This setting variable is primarily used by the Paper2D plugin, which is part of Unreal Engine’s 2D game development toolkit. Based on the callsites, it’s specifically utilized in the rendering system for Paper2D sprites.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning sprites are drawn as two-sided by default. Developers can change this value at runtime using console commands or through configuration files.

The variable interacts directly with its associated variable CVarDrawSpritesAsTwoSided. They share the same value and purpose. The CVarDrawSpritesAsTwoSided is used in the FPaperRenderSceneProxy constructor to set the bDrawTwoSided member variable.

Developers should be aware that this setting affects the rendering performance and appearance of 2D sprites. When set to 1 (true), sprites will be visible from both sides, which can be useful for certain types of 2D games or effects. However, it may also increase rendering overhead.

Best practices when using this variable include:

  1. Consider the performance implications of two-sided rendering, especially for games with many sprites.
  2. Use it judiciously, only enabling two-sided rendering when necessary for your game’s visual style or gameplay mechanics.
  3. Test your game’s performance with this setting both enabled and disabled to determine the optimal configuration.

Regarding the associated variable CVarDrawSpritesAsTwoSided:

The purpose of CVarDrawSpritesAsTwoSided is identical to r.Paper2D.DrawTwoSided. It’s the actual console variable that controls the two-sided rendering of sprites in the Paper2D system.

This variable is used directly in the Paper2D plugin’s rendering code, specifically in the FPaperRenderSceneProxy class constructor.

The value is set through the console variable system and can be modified at runtime or through configuration files.

It interacts with the bDrawTwoSided member variable of the FPaperRenderSceneProxy class, determining whether sprites should be rendered as two-sided.

Developers should be aware that changes to this variable will affect all sprites rendered through the Paper2D system.

Best practices for using CVarDrawSpritesAsTwoSided are the same as those for r.Paper2D.DrawTwoSided, as they are essentially the same setting represented in different ways within the engine.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/2D/Paper2D/Source/Paper2D/Private/PaperRenderSceneProxy.cpp:12

Scope: file

Source code excerpt:

#include "SceneInterface.h"

static TAutoConsoleVariable<int32> CVarDrawSpritesAsTwoSided(TEXT("r.Paper2D.DrawTwoSided"), 1, TEXT("Draw sprites as two sided."));
static TAutoConsoleVariable<int32> CVarDrawSpritesUsingPrebuiltVertexBuffers(TEXT("r.Paper2D.UsePrebuiltVertexBuffers"), 1, TEXT("Draw sprites using prebuilt vertex buffers."));

DECLARE_CYCLE_STAT(TEXT("Get New Batch Meshes"), STAT_PaperRender_GetNewBatchMeshes, STATGROUP_Paper2D);
DECLARE_CYCLE_STAT(TEXT("SpriteProxy GDME"), STAT_PaperRenderSceneProxy_GetDynamicMeshElements, STATGROUP_Paper2D);

FPackedNormal FPaperSpriteTangents::PackedNormalX(FVector(1.0f, 0.0f, 0.0f));

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/2D/Paper2D/Source/Paper2D/Private/PaperRenderSceneProxy.cpp:12

Scope: file

Source code excerpt:

#include "SceneInterface.h"

static TAutoConsoleVariable<int32> CVarDrawSpritesAsTwoSided(TEXT("r.Paper2D.DrawTwoSided"), 1, TEXT("Draw sprites as two sided."));
static TAutoConsoleVariable<int32> CVarDrawSpritesUsingPrebuiltVertexBuffers(TEXT("r.Paper2D.UsePrebuiltVertexBuffers"), 1, TEXT("Draw sprites using prebuilt vertex buffers."));

DECLARE_CYCLE_STAT(TEXT("Get New Batch Meshes"), STAT_PaperRender_GetNewBatchMeshes, STATGROUP_Paper2D);
DECLARE_CYCLE_STAT(TEXT("SpriteProxy GDME"), STAT_PaperRenderSceneProxy_GetDynamicMeshElements, STATGROUP_Paper2D);

FPackedNormal FPaperSpriteTangents::PackedNormalX(FVector(1.0f, 0.0f, 0.0f));

#Loc: <Workspace>/Engine/Plugins/2D/Paper2D/Source/Paper2D/Private/PaperRenderSceneProxy.cpp:173

Scope (from outer to inner):

file
function     FPaperRenderSceneProxy::FPaperRenderSceneProxy

Source code excerpt:

	SetWireframeColor(FLinearColor::White);

	bDrawTwoSided = CVarDrawSpritesAsTwoSided.GetValueOnAnyThread() != 0;
	bSpritesUseVertexBufferPath = CVarDrawSpritesUsingPrebuiltVertexBuffers.GetValueOnAnyThread() != 0;
}

FPaperRenderSceneProxy::~FPaperRenderSceneProxy()
{
	for (FSpriteTextureOverrideRenderProxy* Proxy : MaterialTextureOverrideProxies)