r.DecalDepthBias
r.DecalDepthBias
#Overview
name: r.DecalDepthBias
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Global depth bias used by mesh decals. Default is 0.005
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.DecalDepthBias is to set a global depth bias used by mesh decals in Unreal Engine’s rendering system. This setting helps to prevent z-fighting artifacts when rendering decals on surfaces.
This setting variable is primarily used by the Renderer module of Unreal Engine, specifically in the scene rendering subsystem. It’s defined in the SceneRendering.cpp file, which is a core part of the rendering pipeline.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0.005f, but can be changed at runtime through console commands or programmatically.
The r.DecalDepthBias setting interacts directly with an associated variable named CVarDecalDepthBias. This is the actual TAutoConsoleVariable object that stores and manages the value of r.DecalDepthBias.
Developers should be aware that this variable affects all mesh decals globally. Changing this value can impact the visual quality and performance of decal rendering across the entire scene. It’s a render thread safe variable, meaning it can be safely accessed and modified from the render thread.
Best practices when using this variable include:
- Only modify it if you’re experiencing z-fighting issues with decals.
- Use small incremental changes, as large values can cause decals to appear detached from surfaces.
- Test thoroughly across different scenes and lighting conditions after modifying this value.
Regarding the associated variable CVarDecalDepthBias:
The purpose of CVarDecalDepthBias is to provide a programmatic interface for the r.DecalDepthBias setting. It’s the actual console variable object that stores and manages the depth bias value.
This variable is used in the Renderer module, specifically in the view setup process for shader parameters. It’s accessed in the SetupUniformBufferParameters function of the FViewInfo class.
The value of CVarDecalDepthBias is set when the r.DecalDepthBias console variable is modified, either through console commands or programmatically.
CVarDecalDepthBias interacts directly with the r.DecalDepthBias setting, and its value is used to set the DecalDepthBias parameter in the view’s uniform shader parameters.
Developers should be aware that accessing CVarDecalDepthBias should be done using the GetValueOnRenderThread() method to ensure thread-safety when used in rendering code.
Best practices for using CVarDecalDepthBias include:
- Always access it using GetValueOnRenderThread() in render thread code.
- Avoid frequent changes to this value during runtime, as it affects global rendering state.
- Consider caching the value if used frequently in performance-critical sections of code.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:196
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarDecalDepthBias(
TEXT("r.DecalDepthBias"),
0.005f,
TEXT("Global depth bias used by mesh decals. Default is 0.005"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRefractionQuality(
TEXT("r.RefractionQuality"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarDecalDepthBias
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:195
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarDecalDepthBias(
TEXT("r.DecalDepthBias"),
0.005f,
TEXT("Global depth bias used by mesh decals. Default is 0.005"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRefractionQuality(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:1785
Scope (from outer to inner):
file
function void FViewInfo::SetupUniformBufferParameters
Source code excerpt:
}
ViewUniformShaderParameters.DecalDepthBias = CVarDecalDepthBias.GetValueOnRenderThread();
ViewUniformShaderParameters.IndirectLightingColorScale = FVector3f(FinalPostProcessSettings.IndirectLightingColor.R * FinalPostProcessSettings.IndirectLightingIntensity,
FinalPostProcessSettings.IndirectLightingColor.G * FinalPostProcessSettings.IndirectLightingIntensity,
FinalPostProcessSettings.IndirectLightingColor.B * FinalPostProcessSettings.IndirectLightingIntensity);
ViewUniformShaderParameters.PrecomputedIndirectLightingColorScale = ViewUniformShaderParameters.IndirectLightingColorScale;