r.PathTracing.EnableCameraBackfaceCulling
r.PathTracing.EnableCameraBackfaceCulling
#Overview
name: r.PathTracing.EnableCameraBackfaceCulling
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When non-zero, the path tracer will skip over backfacing triangles when tracing primary rays from the camera. (default = 1 (enabled))
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.PathTracing.EnableCameraBackfaceCulling is to control the backface culling behavior for primary rays in the path tracing rendering system of Unreal Engine 5.
This setting variable is primarily used by the path tracing subsystem within the rendering module of Unreal Engine 5. It specifically affects the behavior of primary rays cast from the camera during path tracing.
The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 1 (enabled) and can be changed at runtime.
The associated variable CVarPathTracingEnableCameraBackfaceCulling directly interacts with r.PathTracing.EnableCameraBackfaceCulling. This C++ variable is used to access and modify the console variable’s value within the engine’s code.
Developers must be aware that enabling this variable (non-zero value) will cause the path tracer to skip over backfacing triangles when tracing primary rays from the camera. This can potentially improve performance but may also affect the visual output in certain scenarios.
Best practices when using this variable include:
- Keep it enabled (default value of 1) for general use cases to benefit from potential performance improvements.
- Consider disabling it (set to 0) if you notice any unexpected visual artifacts, especially in scenes with thin or double-sided geometry.
- Test your scenes with both enabled and disabled states to ensure consistent visual quality across different configurations.
Regarding the associated variable CVarPathTracingEnableCameraBackfaceCulling:
The purpose of CVarPathTracingEnableCameraBackfaceCulling is to provide a programmatic interface to access and modify the r.PathTracing.EnableCameraBackfaceCulling console variable within the engine’s C++ code.
This variable is used within the rendering module, specifically in the path tracing implementation. It’s typically accessed in the render thread to determine the current state of camera backface culling for path tracing.
The value of this variable is set when the console variable r.PathTracing.EnableCameraBackfaceCulling is modified, either through code or via console commands.
CVarPathTracingEnableCameraBackfaceCulling directly interacts with r.PathTracing.EnableCameraBackfaceCulling, serving as its C++ representation within the engine’s codebase.
Developers should be aware that this variable is marked as render thread safe (ECVF_RenderThreadSafe), meaning it can be safely accessed and modified from the render thread.
Best practices for using CVarPathTracingEnableCameraBackfaceCulling include:
- Always use the GetValueOnRenderThread() method to access its value, especially within render thread operations.
- Avoid frequently changing this value during runtime, as it may impact performance and visual consistency.
- When modifying this variable programmatically, consider the potential impact on performance and visual output, similar to the console variable it represents.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:186
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarPathTracingEnableCameraBackfaceCulling(
TEXT("r.PathTracing.EnableCameraBackfaceCulling"),
1,
TEXT("When non-zero, the path tracer will skip over backfacing triangles when tracing primary rays from the camera. (default = 1 (enabled))"),
ECVF_RenderThreadSafe
);
TAutoConsoleVariable<int32> CVarPathTracingAtmosphereOpticalDepthLutResolution(
#Associated Variable and Callsites
This variable is associated with another variable named CVarPathTracingEnableCameraBackfaceCulling
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:185
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarPathTracingEnableCameraBackfaceCulling(
TEXT("r.PathTracing.EnableCameraBackfaceCulling"),
1,
TEXT("When non-zero, the path tracer will skip over backfacing triangles when tracing primary rays from the camera. (default = 1 (enabled))"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:635
Scope (from outer to inner):
file
function static void PreparePathTracingData
Source code excerpt:
}
PathTracingData.ApproximateCaustics = CVarPathTracingApproximateCaustics.GetValueOnRenderThread();
PathTracingData.EnableCameraBackfaceCulling = CVarPathTracingEnableCameraBackfaceCulling.GetValueOnRenderThread();
PathTracingData.SamplerType = CVarPathTracingSamplerType.GetValueOnRenderThread();
PathTracingData.VisualizeLightGrid = CVarPathTracingLightGridVisualize.GetValueOnRenderThread();
PathTracingData.VisualizeDecalGrid = CVarPathTracingDecalGridVisualize.GetValueOnRenderThread();
PathTracingData.FilterWidth = CVarPathTracingFilterWidth.GetValueOnRenderThread();
PathTracingData.CameraFocusDistance = 0;
PathTracingData.CameraLensRadius = FVector2f::ZeroVector;