r.Shadow.FarShadowStaticMeshLODBias
r.Shadow.FarShadowStaticMeshLODBias
#Overview
name: r.Shadow.FarShadowStaticMeshLODBias
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Notice: only selected geometry types (static meshes and landscapes) respect this value.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.FarShadowStaticMeshLODBias is to control the Level of Detail (LOD) bias for static meshes and landscapes in far shadow calculations within Unreal Engine’s rendering system.
This setting variable is primarily used by the rendering system, specifically in the shadow rendering subsystem. It affects how detailed static meshes and landscapes are rendered in far shadow cascades.
The value of this variable is set through the console variable system, as indicated by the FAutoConsoleVariableRef declaration. It can be modified at runtime using console commands or through configuration files.
The associated variable GFarShadowStaticMeshLODBias interacts directly with r.Shadow.FarShadowStaticMeshLODBias. They share the same value, with GFarShadowStaticMeshLODBias being the actual int32 variable used in the engine code.
Developers must be aware that:
- This setting only affects selected geometry types (static meshes and landscapes).
- It’s marked as scalability and render thread safe, meaning it can be adjusted for performance reasons and is safe to modify from the render thread.
- The bias is applied specifically to far shadow cascades, not all shadow calculations.
Best practices when using this variable include:
- Use it to balance between shadow quality and performance, especially for distant objects.
- Be cautious when adjusting it, as it can affect the visual quality of shadows for static meshes and landscapes.
- Consider the impact on different hardware configurations, as higher LOD bias values may affect performance on lower-end systems.
Regarding the associated variable GFarShadowStaticMeshLODBias:
- Its purpose is to store the actual integer value of the LOD bias for far shadows on static meshes.
- It’s used in the Renderer module, specifically in SceneRendering.cpp and ShadowSetup.cpp.
- The value is set by the console variable system and can be accessed throughout the engine code.
- It directly affects the LOD selection for static meshes in far shadow calculations.
- Developers should be aware that modifying this variable will have a direct impact on shadow rendering performance and quality for static meshes and landscapes in far shadows.
- Best practices include using this variable in conjunction with other shadow and LOD settings to achieve the desired balance between visual quality and performance.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/DirectionalLightComponent.cpp:67
Scope: file
Source code excerpt:
ENGINE_API int32 GFarShadowStaticMeshLODBias = 0;
FAutoConsoleVariableRef CVarFarShadowStaticMeshLODBias(
TEXT("r.Shadow.FarShadowStaticMeshLODBias"),
GFarShadowStaticMeshLODBias,
TEXT("Notice: only selected geometry types (static meshes and landscapes) respect this value."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarFarShadowDistanceOverride(
#Associated Variable and Callsites
This variable is associated with another variable named GFarShadowStaticMeshLODBias
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/DirectionalLightComponent.cpp:65
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_Scalability );
ENGINE_API int32 GFarShadowStaticMeshLODBias = 0;
FAutoConsoleVariableRef CVarFarShadowStaticMeshLODBias(
TEXT("r.Shadow.FarShadowStaticMeshLODBias"),
GFarShadowStaticMeshLODBias,
TEXT("Notice: only selected geometry types (static meshes and landscapes) respect this value."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarFarShadowDistanceOverride(
TEXT("r.Shadow.FarShadowDistanceOverride"),
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:1940
Scope (from outer to inner):
file
function void FViewInfo::SetupUniformBufferParameters
Source code excerpt:
if (DrawDynamicFlags & EDrawDynamicFlags::FarShadowCascade)
{
extern ENGINE_API int32 GFarShadowStaticMeshLODBias;
ViewUniformShaderParameters.FarShadowStaticMeshLODBias = GFarShadowStaticMeshLODBias;
}
else
{
ViewUniformShaderParameters.FarShadowStaticMeshLODBias = 0;
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:1729
Scope (from outer to inner):
file
function FLODMask FProjectedShadowInfo::CalcAndUpdateLODToRender
Source code excerpt:
if (!ShadowLODToRender.IsLODRange()) // todo: GPU LOD doesn't support this bias.
{
extern ENGINE_API int32 GFarShadowStaticMeshLODBias;
int8 LODToRenderScan = ShadowLODToRender.LODIndex0 + GFarShadowStaticMeshLODBias;
for (int32 Index = PrimitiveSceneInfo->StaticMeshRelevances.Num() - 1; Index >= 0; Index--)
{
if (LODToRenderScan == PrimitiveSceneInfo->StaticMeshRelevances[Index].GetLODIndex())
{
ShadowLODToRender.SetLOD(LODToRenderScan);