r.FastVRam.ShadowCSM
r.FastVRam.ShadowCSM
#Overview
name: r.FastVRam.ShadowCSM
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.FastVRam.ShadowCSM is to control the memory allocation and usage for Cascaded Shadow Maps (CSM) in Unreal Engine’s rendering system. It is specifically used to set texture creation flags for shadow maps used in CSM, which is a technique for rendering high-quality shadows for large-scale environments.
This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the shadow rendering and scene rendering subsystems.
The value of this variable is set using the FASTVRAM_CVAR macro, which likely defines it as a console variable (CVar) that can be adjusted at runtime. In the provided code, it is initially set to 0.
The r.FastVRam.ShadowCSM variable interacts closely with its associated variable ShadowCSM. They share the same value, and ShadowCSM is used to apply the texture creation flags when allocating render targets for shadow maps.
Developers should be aware that:
- This variable affects the memory allocation strategy for CSM shadow maps.
- Changing this value can impact rendering performance and memory usage.
- The effect of this variable is applied when allocating new shadow map render targets.
Best practices when using this variable include:
- Only modify it if you understand the implications on memory usage and rendering performance.
- Test thoroughly after changing the value, especially on target hardware.
- Consider the relationship with other shadow-related settings for optimal results.
Regarding the associated variable ShadowCSM:
The purpose of ShadowCSM is to store and apply the texture creation flags for Cascaded Shadow Maps. It is used directly in the rendering code to set up shadow map render targets.
This variable is used in the Renderer module, specifically in shadow setup and scene rendering processes.
The value of ShadowCSM is updated in the FFastVramConfig::Update() function, which copies the value from the r.FastVRam.ShadowCSM console variable.
ShadowCSM interacts with the render target allocation process, influencing how shadow map textures are created and potentially affecting their performance characteristics.
Developers should be aware that:
- ShadowCSM directly affects the creation of shadow map render targets.
- Changes to this variable will impact how shadow maps are stored in memory.
Best practices for using ShadowCSM include:
- Ensure consistency between r.FastVRam.ShadowCSM and ShadowCSM values.
- Consider the hardware capabilities when adjusting these settings, as they can affect performance and memory usage.
- Monitor rendering performance and shadow quality when modifying these values.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:507
Scope: file
Source code excerpt:
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);
FASTVRAM_CVAR(GlobalDistanceFieldCullGridBuffers, 1);
#Associated Variable and Callsites
This variable is associated with another variable named ShadowCSM
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:507
Scope: file
Source code excerpt:
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);
FASTVRAM_CVAR(GlobalDistanceFieldCullGridBuffers, 1);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:705
Scope (from outer to inner):
file
function void FFastVramConfig::Update
Source code excerpt:
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);
bDirty |= UpdateBufferFlagFromCVar(CVarFastVRam_ForwardLightingCullingResources, ForwardLightingCullingResources);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.h:2857
Scope: file
Source code excerpt:
ETextureCreateFlags ShadowPointLight;
ETextureCreateFlags ShadowPerObject;
ETextureCreateFlags ShadowCSM;
// Buffers
EBufferUsageFlags DistanceFieldCulledObjectBuffers;
EBufferUsageFlags DistanceFieldTileIntersectionResources;
EBufferUsageFlags DistanceFieldAOScreenGridResources;
EBufferUsageFlags ForwardLightingCullingResources;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:5901
Scope (from outer to inner):
file
function void FSceneRenderer::AllocateCSMDepthTargets
Source code excerpt:
FIntPoint WholeSceneAtlasSize(CurrentLayout.TextureLayout.GetSizeX(), CurrentLayout.TextureLayout.GetSizeY());
FPooledRenderTargetDesc WholeSceneShadowMapDesc2D(FPooledRenderTargetDesc::Create2DDesc(WholeSceneAtlasSize, PF_ShadowDepth, FClearValueBinding::DepthOne, TexCreate_None, TexCreate_DepthStencilTargetable | TexCreate_ShaderResource, false));
WholeSceneShadowMapDesc2D.Flags |= GFastVRamConfig.ShadowCSM;
static RenderTargetNameSet CsmRtNames(TEXT("WholeSceneShadowmap"));
GRenderTargetPool.FindFreeElement(RHICmdList, WholeSceneShadowMapDesc2D, ShadowMapAtlas.RenderTargets.DepthTarget, CsmRtNames.Get(LayoutIndex));
for (FProjectedShadowInfo* ProjectedShadowInfo : CurrentLayout.Shadows)
{
check(ProjectedShadowInfo->bAllocated);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:6665
Scope (from outer to inner):
file
function void FSceneRenderer::AllocateMobileCSMAndSpotLightShadowDepthTargets
Source code excerpt:
FPooledRenderTargetDesc WholeSceneShadowMapDesc2D(FPooledRenderTargetDesc::Create2DDesc(WholeSceneAtlasSize, PF_ShadowDepth, FClearValueBinding::DepthOne, TexCreate_None, TexCreate_DepthStencilTargetable | TexCreate_ShaderResource, false));
WholeSceneShadowMapDesc2D.Flags |= GFastVRamConfig.ShadowCSM;
GRenderTargetPool.FindFreeElement(RHICmdList, WholeSceneShadowMapDesc2D, ShadowMapAtlas.RenderTargets.DepthTarget, TEXT("MobileCSMAndSpotLightShadowmap"));
for (int32 ShadowIndex = 0; ShadowIndex < MobileCSMAndSpotLightShadowLayout.Shadows.Num(); ShadowIndex++)
{
FProjectedShadowInfo* ProjectedShadowInfo = MobileCSMAndSpotLightShadowLayout.Shadows[ShadowIndex];