Skip to content

Commit

Permalink
remove unnecessary fullscreen pass when haze is off/disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
HifiExperiments committed Oct 21, 2024
1 parent 9da839f commit 5aabb5f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions libraries/graphics/src/graphics/Haze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -182,3 +183,7 @@ void Haze::setHazeBackgroundBlend(const float hazeBackgroundBlend) {
_hazeParametersBuffer.edit<Parameters>().hazeBackgroundBlend = newBlend;
}
}

bool Haze::isActive() const {
return (_hazeParametersBuffer.get<Parameters>().hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE;
}
3 changes: 3 additions & 0 deletions libraries/graphics/src/graphics/Haze.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -95,6 +96,8 @@ namespace graphics {
using UniformBufferView = gpu::BufferView;
UniformBufferView getHazeParametersBuffer() const { return _hazeParametersBuffer; }

bool isActive() const;

protected:
class Parameters {
public:
Expand Down
5 changes: 5 additions & 0 deletions libraries/render-utils/src/DrawHaze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 1 addition & 4 deletions libraries/render-utils/src/Haze.slf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 5aabb5f

Please sign in to comment.