r.Mobile.SSAOHalfResolution

r.Mobile.SSAOHalfResolution

#Overview

name: r.Mobile.SSAOHalfResolution

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.Mobile.SSAOHalfResolution is to control the resolution and upsampling method for Screen Space Ambient Occlusion (SSAO) in mobile rendering. This setting variable is part of the rendering system, specifically for optimizing SSAO performance on mobile devices.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically in the mobile post-processing pipeline for SSAO. It’s referenced in the PostProcessAmbientOcclusionMobile.cpp file, which suggests it’s tailored for mobile rendering optimizations.

The value of this variable is set through a console variable (CVarMobileSSAOHalfResolution) and can be changed at runtime. It offers four options: 0: Disabled (full resolution SSAO) 1: Half Resolution with bilinear upsample 2: Half Resolution with 4 tap bilateral upsample 3: Half Resolution with 9 tap bilateral upsample

The associated variable CVarMobileSSAOHalfResolution directly interacts with r.Mobile.SSAOHalfResolution. They share the same value and purpose.

Developers must be aware that this variable affects both performance and visual quality. Using half-resolution SSAO can improve performance but may reduce the quality of ambient occlusion effects. The choice of upsampling method (bilinear vs bilateral) also impacts the final image quality.

Best practices when using this variable include:

  1. Testing different settings to find the optimal balance between performance and visual quality for your specific mobile game.
  2. Consider using higher quality settings (2 or 3) for high-end mobile devices and lower settings (0 or 1) for less powerful devices.
  3. Be aware that changing this setting at runtime may cause a noticeable shift in visual quality, so it’s best to set it based on device capabilities at the start of the application.

Regarding the associated variable CVarMobileSSAOHalfResolution: This is a TAutoConsoleVariable that directly controls the r.Mobile.SSAOHalfResolution setting. It’s defined in the same file and is used to get the current value of the setting in the render thread (GetValueOnRenderThread()). Developers can use this variable to programmatically read or modify the SSAO half-resolution setting in C++ code, allowing for dynamic adjustments based on performance metrics or other runtime conditions.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarMobileSSAOHalfResolution(
	TEXT("r.Mobile.SSAOHalfResolution"),
	0,
	TEXT("Whether to calculate SSAO at half resolution.\n")
	TEXT("0: Disabled.\n")
	TEXT("1: Half Resolution with bilinear upsample\n")
	TEXT("2: Half Resolution with 4 tap bilateral upsample\n")
	TEXT("3: Half Resolution with 9 tap bilateral upsample\n"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessAmbientOcclusionMobile.cpp:71

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarMobileSSAOHalfResolution(
	TEXT("r.Mobile.SSAOHalfResolution"),
	0,
	TEXT("Whether to calculate SSAO at half resolution.\n")
	TEXT("0: Disabled.\n")
	TEXT("1: Half Resolution with bilinear upsample\n")
	TEXT("2: Half Resolution with 4 tap bilateral upsample\n")

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessAmbientOcclusionMobile.cpp:1112

Scope (from outer to inner):

file
function     static void RenderSSAO

Source code excerpt:

	RDG_GPU_STAT_SCOPE(GraphBuilder, MobileSSAO);

	const int32 HalfResolutionSetting = CVarMobileSSAOHalfResolution.GetValueOnRenderThread();
	const bool bHalfResolution = HalfResolutionSetting > 0;
	const int32 UpsampleQuality = FMath::Clamp(HalfResolutionSetting - 1, 0, 2);
	const bool bBilateralUpsample = UpsampleQuality > 0;

	FRDGTextureRef HalfResolutionTexture = nullptr;
	if (bHalfResolution)