From 37f2512068f521da69cb9d81033f413c8125a331 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Mon, 14 Oct 2024 19:51:17 -0700 Subject: [PATCH] remove unnecessary fullscreen pass when haze is off/disabled --- libraries/graphics/src/graphics/Haze.cpp | 5 +++++ libraries/graphics/src/graphics/Haze.h | 3 +++ libraries/render-utils/src/DrawHaze.cpp | 5 +++++ libraries/render-utils/src/Haze.slf | 5 +---- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libraries/graphics/src/graphics/Haze.cpp b/libraries/graphics/src/graphics/Haze.cpp index 9e3cc15c576..c53dc680b03 100644 --- a/libraries/graphics/src/graphics/Haze.cpp +++ b/libraries/graphics/src/graphics/Haze.cpp @@ -4,6 +4,7 @@ // // Created by Nissim Hadar on 9/13/2017. // Copyright 2014 High Fidelity, Inc. +// Copyright 2024 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -182,3 +183,7 @@ void Haze::setHazeBackgroundBlend(const float hazeBackgroundBlend) { _hazeParametersBuffer.edit().hazeBackgroundBlend = newBlend; } } + +bool Haze::isActive() const { + return (_hazeParametersBuffer.get().hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE; +} diff --git a/libraries/graphics/src/graphics/Haze.h b/libraries/graphics/src/graphics/Haze.h index 25004f098fc..415237b879d 100644 --- a/libraries/graphics/src/graphics/Haze.h +++ b/libraries/graphics/src/graphics/Haze.h @@ -4,6 +4,7 @@ // // Created by Nissim Hadar on 9/13/2017. // Copyright 2014 High Fidelity, Inc. +// Copyright 2024 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -95,6 +96,8 @@ namespace graphics { using UniformBufferView = gpu::BufferView; UniformBufferView getHazeParametersBuffer() const { return _hazeParametersBuffer; } + bool isActive() const; + protected: class Parameters { public: diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 71845be7313..134f12174bb 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -4,6 +4,7 @@ // // Created by Nissim Hadar on 9/1/2017. // Copyright 2015 High Fidelity, Inc. +// Copyright 2024 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -55,6 +56,10 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu auto depthBuffer = framebuffer->getLinearDepthTexture(); + if (!lightingModel->isHazeEnabled() || !haze->isActive()) { + return; + } + RenderArgs* args = renderContext->args; if (!_hazePipeline) { diff --git a/libraries/render-utils/src/Haze.slf b/libraries/render-utils/src/Haze.slf index 9be64e76953..e7c3459f4ab 100644 --- a/libraries/render-utils/src/Haze.slf +++ b/libraries/render-utils/src/Haze.slf @@ -6,6 +6,7 @@ // // Created by Nissim Hadar on 9/5/2107. // Copyright 2016 High Fidelity, Inc. +// Copyright 2024 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -45,10 +46,6 @@ layout(location=0) in vec2 varTexCoord0; layout(location=0) out vec4 outFragColor; void main(void) { - if ((isHazeEnabled() == 0.0) || (hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) != HAZE_MODE_IS_ACTIVE) { - discard; - } - vec4 fragPositionES = unpackPositionFromZeye(varTexCoord0); mat4 viewInverse = getViewInverse();