r.FastVRam.ShadowPerObject
r.FastVRam.ShadowPerObject
#Overview
name: r.FastVRam.ShadowPerObject
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.FastVRam.ShadowPerObject is to control the memory allocation strategy for per-object shadow textures in Unreal Engine’s rendering system. This setting variable is primarily used by the rendering subsystem to optimize shadow rendering performance.
This setting variable is mainly relied upon by Unreal Engine’s Renderer module, specifically in the shadow rendering and memory management components.
The value of this variable is set using the FASTVRAM_CVAR macro, which likely defines it as a console variable (CVar) with an initial value of 0. This allows the value to be changed at runtime through console commands or configuration files.
The r.FastVRam.ShadowPerObject variable interacts closely with its associated variable ShadowPerObject. They share the same value and are used together in the FFastVramConfig structure to determine the texture creation flags for per-object shadows.
Developers must be aware that this variable affects the memory allocation strategy for shadow textures. Setting it to 1 (or true) will likely prioritize using fast VRAM for per-object shadow textures, which can improve rendering performance at the cost of using more expensive memory resources.
Best practices when using this variable include:
- Only enable it if you’re experiencing performance issues related to shadow rendering.
- Monitor performance and memory usage when changing this setting, as it may impact overall system performance.
- Consider the target hardware capabilities when deciding to enable this option.
Regarding the associated variable ShadowPerObject:
The purpose of ShadowPerObject is to store the texture creation flags for per-object shadow textures within the FFastVramConfig structure. It is directly influenced by the r.FastVRam.ShadowPerObject console variable.
This variable is used in the Renderer module, specifically in shadow setup and rendering processes.
The value of ShadowPerObject is updated in the FFastVramConfig::Update function based on the value of r.FastVRam.ShadowPerObject.
ShadowPerObject interacts with the GFastVRamConfig global variable and is used when allocating shadow depth targets for atlased shadows.
Developers should be aware that changing the value of r.FastVRam.ShadowPerObject will directly affect the ShadowPerObject variable, which in turn influences how shadow textures are created and managed.
Best practices for using ShadowPerObject include:
- Understand that it’s controlled by r.FastVRam.ShadowPerObject and not meant to be modified directly.
- Be aware of its impact on shadow texture creation when optimizing rendering performance.
- Consider its effects in conjunction with other shadow-related settings in the rendering pipeline.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:506
Scope: file
Source code excerpt:
FASTVRAM_CVAR(CustomDepth, 0);
FASTVRAM_CVAR(ShadowPointLight, 0);
FASTVRAM_CVAR(ShadowPerObject, 0);
FASTVRAM_CVAR(ShadowCSM, 0);
FASTVRAM_CVAR(DistanceFieldCulledObjectBuffers, 1);
FASTVRAM_CVAR(DistanceFieldTileIntersectionResources, 1);
FASTVRAM_CVAR(DistanceFieldAOScreenGridResources, 1);
FASTVRAM_CVAR(ForwardLightingCullingResources, 1);
#Associated Variable and Callsites
This variable is associated with another variable named ShadowPerObject
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:506
Scope: file
Source code excerpt:
FASTVRAM_CVAR(CustomDepth, 0);
FASTVRAM_CVAR(ShadowPointLight, 0);
FASTVRAM_CVAR(ShadowPerObject, 0);
FASTVRAM_CVAR(ShadowCSM, 0);
FASTVRAM_CVAR(DistanceFieldCulledObjectBuffers, 1);
FASTVRAM_CVAR(DistanceFieldTileIntersectionResources, 1);
FASTVRAM_CVAR(DistanceFieldAOScreenGridResources, 1);
FASTVRAM_CVAR(ForwardLightingCullingResources, 1);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:704
Scope (from outer to inner):
file
function void FFastVramConfig::Update
Source code excerpt:
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_CustomDepth, CustomDepth);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_ShadowPointLight, ShadowPointLight);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_ShadowPerObject, ShadowPerObject);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_ShadowCSM, ShadowCSM);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_PostProcessMaterial, PostProcessMaterial);
bDirty |= UpdateBufferFlagFromCVar(CVarFastVRam_DistanceFieldCulledObjectBuffers, DistanceFieldCulledObjectBuffers);
bDirty |= UpdateBufferFlagFromCVar(CVarFastVRam_DistanceFieldTileIntersectionResources, DistanceFieldTileIntersectionResources);
bDirty |= UpdateBufferFlagFromCVar(CVarFastVRam_DistanceFieldAOScreenGridResources, DistanceFieldAOScreenGridResources);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.h:2856
Scope: file
Source code excerpt:
ETextureCreateFlags CustomDepth;
ETextureCreateFlags ShadowPointLight;
ETextureCreateFlags ShadowPerObject;
ETextureCreateFlags ShadowCSM;
// Buffers
EBufferUsageFlags DistanceFieldCulledObjectBuffers;
EBufferUsageFlags DistanceFieldTileIntersectionResources;
EBufferUsageFlags DistanceFieldAOScreenGridResources;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:5777
Scope (from outer to inner):
file
function void FSceneRenderer::AllocateAtlasedShadowDepthTargets
Source code excerpt:
FPooledRenderTargetDesc ShadowMapDesc2D = FPooledRenderTargetDesc::Create2DDesc(AtlasSize, PF_ShadowDepth, FClearValueBinding::DepthOne, TexCreate_None, TexCreate_DepthStencilTargetable | TexCreate_ShaderResource, false);
ShadowMapDesc2D.Flags |= GFastVRamConfig.ShadowPerObject;
GRenderTargetPool.FindFreeElement(RHICmdList, ShadowMapDesc2D, ShadowMapAtlas.RenderTargets.DepthTarget, TEXT("ShadowDepthAtlas"));
for (int32 ShadowIndex = 0; ShadowIndex < CurrentLayout.Shadows.Num(); ShadowIndex++)
{
FProjectedShadowInfo* ProjectedShadowInfo = CurrentLayout.Shadows[ShadowIndex];