r.RayTracing.AmbientOcclusion.EnableTwoSidedGeometry

r.RayTracing.AmbientOcclusion.EnableTwoSidedGeometry

#Overview

name: r.RayTracing.AmbientOcclusion.EnableTwoSidedGeometry

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.RayTracing.AmbientOcclusion.EnableTwoSidedGeometry is to control whether two-sided geometry is enabled when tracing shadow rays for ray-traced ambient occlusion.

This setting variable is primarily used in the rendering system, specifically in the ray tracing subsystem for ambient occlusion calculations. Based on the callsites, it is utilized in the Renderer module of Unreal Engine 5, particularly in the ray tracing ambient occlusion implementation.

The value of this variable is set through the console variable system in Unreal Engine. It is defined as a TAutoConsoleVariable with an initial value of 0 (disabled by default).

The associated variable CVarRayTracingAmbientOcclusionEnableTwoSidedGeometry directly interacts with r.RayTracing.AmbientOcclusion.EnableTwoSidedGeometry. They share the same value and purpose.

Developers must be aware that enabling this variable may impact performance, as it increases the complexity of ray tracing calculations by considering both sides of geometry when tracing shadow rays. It may also affect the visual results of ambient occlusion, potentially providing more accurate shadowing in some scenarios.

Best practices when using this variable include:

  1. Testing the visual impact and performance implications before enabling it in production.
  2. Considering enabling it only for high-quality rendering scenarios where the additional accuracy is necessary.
  3. Balancing it with other ray tracing settings to maintain optimal performance.

Regarding the associated variable CVarRayTracingAmbientOcclusionEnableTwoSidedGeometry:

The purpose of this variable is identical to r.RayTracing.AmbientOcclusion.EnableTwoSidedGeometry, as they are essentially the same variable.

It is used in the same Unreal Engine subsystem (rendering, specifically ray tracing ambient occlusion) as part of the Renderer module.

The value is set when the console variable is initialized, and it can be changed at runtime through console commands or code.

This variable directly interacts with the shader permutation system, as seen in the code where it’s used to set a permutation domain for the ray generation shader.

Developers should be aware that changes to this variable will affect shader compilation and may require shader recompilation when changed.

Best practices include:

  1. Consistently using either the console variable name or the CVarRayTracingAmbientOcclusionEnableTwoSidedGeometry variable in code to avoid confusion.
  2. Considering the impact on shader compilation and potential load times when changing this value dynamically.
  3. Documenting any dependencies on this variable in custom rendering code or material functions that interact with ambient occlusion.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingAmbientOcclusion.cpp:48

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRayTracingAmbientOcclusionEnableTwoSidedGeometry(
	TEXT("r.RayTracing.AmbientOcclusion.EnableTwoSidedGeometry"),
	0,
	TEXT("Enables two-sided geometry when tracing shadow rays (default = 0)"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarRayTracingAmbientOcclusionEnableMaterials(

#Associated Variable and Callsites

This variable is associated with another variable named CVarRayTracingAmbientOcclusionEnableTwoSidedGeometry. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingAmbientOcclusion.cpp:47

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarRayTracingAmbientOcclusionEnableTwoSidedGeometry(
	TEXT("r.RayTracing.AmbientOcclusion.EnableTwoSidedGeometry"),
	0,
	TEXT("Enables two-sided geometry when tracing shadow rays (default = 0)"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingAmbientOcclusion.cpp:172

Scope: file

Source code excerpt:


	FRayTracingAmbientOcclusionRGS::FPermutationDomain PermutationVector;
	PermutationVector.Set<FRayTracingAmbientOcclusionRGS::FEnableTwoSidedGeometryDim>(CVarRayTracingAmbientOcclusionEnableTwoSidedGeometry.GetValueOnRenderThread() != 0);
	PermutationVector.Set<FRayTracingAmbientOcclusionRGS::FEnableMaterialsDim>(CVarRayTracingAmbientOcclusionEnableMaterials.GetValueOnRenderThread() != 0);
	TShaderMapRef<FRayTracingAmbientOcclusionRGS> RayGenerationShader(GetGlobalShaderMap(FeatureLevel), PermutationVector);
	ClearUnusedGraphResources(RayGenerationShader, PassParameters);

	FIntPoint RayTracingResolution = View.ViewRect.Size();
	GraphBuilder.AddPass(