r.SkySpecularOcclusionStrength

r.SkySpecularOcclusionStrength

#Overview

name: r.SkySpecularOcclusionStrength

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.SkySpecularOcclusionStrength is to control the strength of skylight specular occlusion from Distance Field Ambient Occlusion (DFAO) in Unreal Engine’s rendering system.

This setting variable is primarily used by the Renderer module of Unreal Engine 5, specifically in the indirect lighting rendering subsystem. It’s referenced in the IndirectLightRendering.cpp file, which suggests it plays a role in calculating indirect lighting and reflections.

The value of this variable is set as a console variable (CVar) with a default value of 1.0. It can be modified at runtime through the console or programmatically.

The associated variable CVarSkySpecularOcclusionStrength directly interacts with r.SkySpecularOcclusionStrength. They share the same value and purpose.

Developers should be aware that this variable affects the visual quality of specular reflections from the skylight. A higher value will result in stronger occlusion, potentially leading to more dramatic lighting effects but also potentially reducing the overall brightness of specular reflections.

Best practices when using this variable include:

  1. Adjusting it in small increments to find the right balance for your scene.
  2. Testing in various lighting conditions to ensure consistent visual quality.
  3. Being mindful of performance impacts, as stronger occlusion calculations may have a slight performance cost.

Regarding the associated variable CVarSkySpecularOcclusionStrength:

The purpose of CVarSkySpecularOcclusionStrength is identical to r.SkySpecularOcclusionStrength. It’s the C++ representation of the console variable.

This variable is used within the Renderer module, specifically in the FAmbientCubemapCompositePS class, which is likely responsible for compositing ambient cubemap lighting.

The value is set when the console variable is initialized, but can be accessed and potentially modified at runtime using the GetValueOnRenderThread() method.

It directly interacts with r.SkySpecularOcclusionStrength, as they represent the same setting.

Developers should be aware that this variable is used in shader calculations, specifically in computing the inverse of the sky specular occlusion strength. The code ensures a minimum value of 0.1 to prevent division by zero.

Best practices for using this variable include:

  1. Accessing it through the appropriate render thread methods to ensure thread safety.
  2. Considering caching its value if used frequently, to avoid repeated calls to GetValueOnRenderThread().
  3. Being cautious when modifying it directly, as it could affect the entire rendering pipeline’s behavior.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightRendering.cpp:73

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarSkySpecularOcclusionStrength(
	TEXT("r.SkySpecularOcclusionStrength"),
	1,
	TEXT("Strength of skylight specular occlusion from DFAO (default is 1.0)"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarReflectionCaptureEnableDeferredReflectionsAndSkyLighting(
	TEXT("r.ReflectionCapture.EnableDeferredReflectionsAndSkyLighting"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightRendering.cpp:72

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarSkySpecularOcclusionStrength(
	TEXT("r.SkySpecularOcclusionStrength"),
	1,
	TEXT("Strength of skylight specular occlusion from DFAO (default is 1.0)"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarReflectionCaptureEnableDeferredReflectionsAndSkyLighting(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightRendering.cpp:276

Scope (from outer to inner):

file
function     class FAmbientCubemapCompositePS : public FGlobalShader { /*ARE_GLOBAL_SHADER
class        class FAmbientCubemapCompositePS : public FGlobalShader
function     BEGIN_SHADER_PARAMETER_STRUCT

Source code excerpt:

	Out.OcclusionCombineMode = SkyLightOcclusionCombineMode == OCM_Minimum ? 0.0f : 1.0f;
	Out.ApplyBentNormalAO = DynamicBentNormalAO;
	Out.InvSkySpecularOcclusionStrength = 1.0f / FMath::Max(CVarSkySpecularOcclusionStrength.GetValueOnRenderThread(), 0.1f);
	return Out;
}

/** Pixel shader that does tiled deferred culling of reflection captures, then sorts and composites them. */
class FReflectionEnvironmentSkyLightingPS : public FGlobalShader
{