From a6b95fdea4ed6dc7136e7aff9c9e06d43c9b6a11 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Tue, 21 Feb 2023 18:41:35 +0100 Subject: [PATCH] Fixed multiple issues with the postprocessing shaders. --- es-core/src/renderers/RendererOpenGL.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/es-core/src/renderers/RendererOpenGL.cpp b/es-core/src/renderers/RendererOpenGL.cpp index f4d2d26d5..f0ad9e483 100644 --- a/es-core/src/renderers/RendererOpenGL.cpp +++ b/es-core/src/renderers/RendererOpenGL.cpp @@ -664,16 +664,19 @@ void RendererOpenGL::shaderPostprocessing(unsigned int shaders, mTrans = getProjectionMatrixNormal() * getIdentity(); } else { - if ((shaderCalls + (textureRGBA ? 1 : 0)) % 2 == 0) + if ((shaderCalls + (textureRGBA ? 1 : 0)) % 2 == 0 && !(textureRGBA && shaderCalls == 1)) GL_CHECK_ERROR(glBlitFramebuffer(0, 0, width + mPaddingWidth, height - mScreenOffsetY, -mScreenOffsetX - mPaddingWidth, mScreenOffsetY, width - mScreenOffsetX, height, GL_COLOR_BUFFER_BIT, GL_NEAREST)); else - GL_CHECK_ERROR(glBlitFramebuffer( - 0, 0, width + mPaddingWidth, height + (mPaddingHeight / 2), - width + mScreenOffsetX + mPaddingWidth, height - mScreenOffsetY, mScreenOffsetX, - -(mPaddingHeight / 2) - mScreenOffsetY, GL_COLOR_BUFFER_BIT, GL_NEAREST)); + GL_CHECK_ERROR(glBlitFramebuffer(0, 0, width + mPaddingWidth, height - mScreenOffsetY, + width + mScreenOffsetX + mPaddingWidth, + height - mScreenOffsetY, mScreenOffsetX, 0, + GL_COLOR_BUFFER_BIT, GL_NEAREST)); + // For correct rendering if the blurred background is disabled when opening menus. + if (textureRGBA && shaderCalls == 1) + mTrans = getProjectionMatrixNormal() * getIdentity(); } if (shaderCalls > 1) @@ -704,6 +707,9 @@ void RendererOpenGL::shaderPostprocessing(unsigned int shaders, drawTriangleStrips(vertices, 4, BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA); + if (shaderCalls == 1) + break; + if (firstFBO) { bindTexture(mPostProcTexture2); GL_CHECK_ERROR(glBindFramebuffer(GL_READ_FRAMEBUFFER, mShaderFBO2));