diff --git a/filament/src/PerViewUniforms.cpp b/filament/src/PerViewUniforms.cpp index 8ce3eca063..2382f75044 100644 --- a/filament/src/PerViewUniforms.cpp +++ b/filament/src/PerViewUniforms.cpp @@ -168,7 +168,7 @@ void PerViewUniforms::prepareSSAO(Handle ssao, const float edgeDistance = 1.0f / options.bilateralThreshold; auto& s = mUniforms.edit(); s.aoSamplingQualityAndEdgeDistance = - options.enabled && highQualitySampling ? edgeDistance : 0.0f; + options.enabled ? (highQualitySampling ? edgeDistance : 0.0f) : -1.0f; s.aoBentNormals = options.enabled && options.bentNormals ? 1.0f : 0.0f; } diff --git a/libs/filabridge/include/private/filament/UibStructs.h b/libs/filabridge/include/private/filament/UibStructs.h index e711c52c82..863d029d37 100644 --- a/libs/filabridge/include/private/filament/UibStructs.h +++ b/libs/filabridge/include/private/filament/UibStructs.h @@ -83,7 +83,7 @@ struct PerViewUib { // NOLINT(cppcoreguidelines-pro-type-member-init) float needsAlphaChannel; // AO - float aoSamplingQualityAndEdgeDistance; // 0: bilinear, !0: bilateral edge distance + float aoSamplingQualityAndEdgeDistance; // <0: no AO, 0: bilinear, !0: bilateral edge distance float aoBentNormals; // 0: no AO bent normal, >0.0 AO bent normals float aoReserved0; float aoReserved1; diff --git a/shaders/src/ambient_occlusion.fs b/shaders/src/ambient_occlusion.fs index 2c5336de1d..32f6421986 100644 --- a/shaders/src/ambient_occlusion.fs +++ b/shaders/src/ambient_occlusion.fs @@ -25,6 +25,12 @@ struct SSAOInterpolationCache { float evaluateSSAO(inout SSAOInterpolationCache cache) { #if defined(BLEND_MODE_OPAQUE) || defined(BLEND_MODE_MASKED) + + if (frameUniforms.aoSamplingQualityAndEdgeDistance < 0.0) { + // SSAO is disabled + return 1.0; + } + // Upscale the SSAO buffer in real-time, in high quality mode we use a custom bilinear // filter. This adds about 2.0ms @ 250MHz on Pixel 4.