r.PathTracing.MeshDecalBias
r.PathTracing.MeshDecalBias
#Overview
name: r.PathTracing.MeshDecalBias
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Bias applied to mesh decal rays to avoid intersection with geometry (default = 1.0f)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.PathTracing.MeshDecalBias is to apply a bias to mesh decal rays in the path tracing rendering system to avoid intersection with geometry. This setting is part of Unreal Engine 5’s path tracing implementation, which is a more advanced and physically accurate rendering technique compared to traditional rasterization.
This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically within the path tracing subsystem. The code references are found in the PathTracing.cpp file, which is part of the core rendering implementation.
The value of this variable is set using a TAutoConsoleVariable, which means it can be adjusted at runtime through the console or configuration files. The default value is set to 1.0f, but developers can modify this value as needed.
The associated variable CVarPathTracingMeshDecalBias directly interacts with r.PathTracing.MeshDecalBias. They share the same value and purpose.
Developers must be aware that this variable affects the accuracy and visual quality of mesh decals in path-traced scenes. A higher bias value may help prevent artifacts caused by ray intersections with geometry, but it might also lead to visible gaps or floating decals if set too high.
Best practices when using this variable include:
- Start with the default value (1.0f) and adjust as needed based on scene-specific requirements.
- Monitor the visual quality of mesh decals in path-traced scenes when modifying this value.
- Balance the bias value to minimize both intersection artifacts and visible gaps in decal placement.
- Consider scene scale when adjusting this value, as larger scenes might require different bias values compared to smaller scenes.
Regarding the associated variable CVarPathTracingMeshDecalBias:
The purpose of CVarPathTracingMeshDecalBias is identical to r.PathTracing.MeshDecalBias, as they share the same value and functionality. It’s an internal representation of the console variable used within the C++ code.
This variable is used in the Renderer module, specifically in the path tracing implementation. It’s accessed in the PreparePathTracingData function to set the MeshDecalBias value in the PathTracingData structure.
The value of CVarPathTracingMeshDecalBias is set through the TAutoConsoleVariable declaration and can be accessed using the GetValueOnRenderThread() method.
Developers should be aware that modifying CVarPathTracingMeshDecalBias directly in code will have the same effect as changing r.PathTracing.MeshDecalBias through the console or configuration files.
Best practices for using CVarPathTracingMeshDecalBias include:
- Use GetValueOnRenderThread() to access the current value in render thread code.
- Avoid modifying this variable directly in code unless absolutely necessary; prefer using the console variable for adjustments.
- Consider caching the value if it’s accessed frequently in performance-critical code sections.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:315
Scope: file
Source code excerpt:
TAutoConsoleVariable<float> CVarPathTracingMeshDecalBias(
TEXT("r.PathTracing.MeshDecalBias"),
1.0f,
TEXT("Bias applied to mesh decal rays to avoid intersection with geometry (default = 1.0f)"),
ECVF_RenderThreadSafe
);
TAutoConsoleVariable<int32> CVarPathTracingLightFunctionColor(
#Associated Variable and Callsites
This variable is associated with another variable named CVarPathTracingMeshDecalBias
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:314
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<float> CVarPathTracingMeshDecalBias(
TEXT("r.PathTracing.MeshDecalBias"),
1.0f,
TEXT("Bias applied to mesh decal rays to avoid intersection with geometry (default = 1.0f)"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:676
Scope (from outer to inner):
file
function static void PreparePathTracingData
Source code excerpt:
PathTracingData.MeshDecalRoughnessCutoff = PathTracing::UsesDecals(*View.Family) && Scene->RayTracingScene.GetRHIRayTracingScene()->GetInitializer().NumNativeInstancesPerLayer[(uint32)ERayTracingSceneLayer::Decals] > 0 ? CVarPathTracingMeshDecalRoughnessCutoff.GetValueOnRenderThread() : -1.0f;
PathTracingData.MeshDecalBias = CVarPathTracingMeshDecalBias.GetValueOnRenderThread();
PathTracingData.MaxRaymarchSteps = CVarPathTracingMaxRaymarchSteps.GetValueOnRenderThread();
// NOTE: Diffuse and Specular show flags also modify the override colors, but we prefer to tie those to the lighting contribution mechanism below which is more principled
PathTracingData.ApplyDiffuseSpecularOverrides =
ShowFlags.LightingOnlyOverride != 0 ||