r.Mobile.AmbientOcclusionShaderType
r.Mobile.AmbientOcclusionShaderType
#Overview
name: r.Mobile.AmbientOcclusionShaderType
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0: ComputeShader.\n1: Seperate ComputeShader.\n2: PixelShader.\n
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Mobile.AmbientOcclusionShaderType is to control the type of shader used for ambient occlusion calculations on mobile platforms in Unreal Engine 5. This setting variable is part of the rendering system, specifically for mobile ambient occlusion.
Based on the details in the Callsites section, this variable is used in the Renderer module, particularly in the mobile post-processing for ambient occlusion. It’s referenced in the file “PostProcessAmbientOcclusionMobile.cpp”, which suggests it’s specifically tailored for mobile rendering.
The value of this variable is set using a console variable (CVarMobileAmbientOcclusionShaderType). It can be set to three different values: 0: ComputeShader 1: Separate ComputeShader 2: PixelShader (default)
This variable interacts closely with CVarMobileAmbientOcclusionShaderType, which is its associated variable. They share the same value and are used interchangeably in the code.
Developers must be aware that:
- The choice of shader type can affect performance and visual quality on mobile devices.
- The default value is 2 (PixelShader), which might be the most compatible option across different mobile platforms.
- The ComputeShader options (0 and 1) are only used under specific conditions, such as on OpenGL platforms with certain hardware capabilities.
Best practices when using this variable include:
- Testing different shader types to find the best balance between performance and visual quality for your target mobile devices.
- Considering the hardware capabilities of your target devices, especially when using ComputeShader options.
- Being aware that changing this value at runtime may have performance implications.
Regarding CVarMobileAmbientOcclusionShaderType: This is the actual console variable that controls the shader type. It’s used in conditional statements to determine which shader implementation to use for ambient occlusion calculations. The variable is checked on the render thread, indicating that it can be changed dynamically during runtime. Developers should use this variable when they need to programmatically control the ambient occlusion shader type in their game code or for debugging purposes.
#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:57
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarMobileAmbientOcclusionShaderType(
TEXT("r.Mobile.AmbientOcclusionShaderType"),
2,
TEXT("0: ComputeShader.\n")
TEXT("1: Seperate ComputeShader.\n")
TEXT("2: PixelShader.\n"),
ECVF_RenderThreadSafe
);
#Associated Variable and Callsites
This variable is associated with another variable named CVarMobileAmbientOcclusionShaderType
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessAmbientOcclusionMobile.cpp:56
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarMobileAmbientOcclusionShaderType(
TEXT("r.Mobile.AmbientOcclusionShaderType"),
2,
TEXT("0: ComputeShader.\n")
TEXT("1: Seperate ComputeShader.\n")
TEXT("2: PixelShader.\n"),
ECVF_RenderThreadSafe
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessAmbientOcclusionMobile.cpp:448
Scope (from outer to inner):
file
function FRDGTextureRef CreateMobileScreenSpaceAOTexture
Source code excerpt:
if (bGTAO
&& IsOpenGLPlatform(Config.ShaderPlatform)
&& ((GetMaxWorkGroupInvocations() >= 1024 && CVarMobileAmbientOcclusionShaderType.GetValueOnRenderThread() == 0) || CVarMobileAmbientOcclusionShaderType.GetValueOnRenderThread() == 1)
)
{
Format = PF_R8G8B8A8;
}
return GraphBuilder.CreateTexture(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessAmbientOcclusionMobile.cpp:507
Scope (from outer to inner):
file
function static void RenderGTAO
Source code excerpt:
FVector4f WorldRadiusAdjSinCosDeltaAngleThickness(FallOffStartEndScaleBias.Y * DepthBufferSize.Y * View.ViewMatrices.GetProjectionMatrix().M[0][0], SinDeltaAngle, CosDeltaAngle, ThicknessBlend);
if (GetMaxWorkGroupInvocations() >= 1024 && CVarMobileAmbientOcclusionShaderType.GetValueOnRenderThread() == 0)
{
FGTAOMobile_HorizonSearchIntegralSpatialFilterCS::FParameters* HorizonSearchIntegralSpatialFilterParameters = GraphBuilder.AllocParameters<FGTAOMobile_HorizonSearchIntegralSpatialFilterCS::FParameters>();
FGTAOMobile_HorizonSearchIntegral::SetupShaderParameters(HorizonSearchIntegralSpatialFilterParameters->Common, GraphBuilder, View, ViewRect, DepthBufferSize, BufferSize, FallOffStartEndScaleBias, WorldRadiusAdjSinCosDeltaAngleThickness, SceneDepthTexture);
HorizonSearchIntegralSpatialFilterParameters->Power_Intensity_ScreenPixelsToSearch = FVector4f(Settings.AmbientOcclusionPower * 0.5f, Settings.AmbientOcclusionIntensity, 0.0f, 0.0f);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessAmbientOcclusionMobile.cpp:527
Scope (from outer to inner):
file
function static void RenderGTAO
Source code excerpt:
FComputeShaderUtils::GetGroupCount(ViewRect.Size(), FGTAOMobile_HorizonSearchIntegralSpatialFilterCS::TexelsPerThreadGroup));
}
else if (CVarMobileAmbientOcclusionShaderType.GetValueOnRenderThread() != 1)
{
TShaderMapRef<FScreenPassVS> VertexShader(View.ShaderMap);
FScreenPassRenderTarget HorizonSearchIntegralRT(HorizonSearchIntegralTexture, ViewRect, ViewIndex > 0 ? ERenderTargetLoadAction::ELoad : ERenderTargetLoadAction::EClear);
FGTAOMobile_HorizonSearchIntegralPS::FParameters* HorizonSearchIntegralParameters = GraphBuilder.AllocParameters<FGTAOMobile_HorizonSearchIntegralPS::FParameters>();