diff --git a/source/common/rendering/gl/system/gl_framebuffer.cpp b/source/common/rendering/gl/system/gl_framebuffer.cpp index 047e116a1..ee37dc7fa 100644 --- a/source/common/rendering/gl/system/gl_framebuffer.cpp +++ b/source/common/rendering/gl/system/gl_framebuffer.cpp @@ -432,20 +432,20 @@ void OpenGLFrameBuffer::PostProcessScene(int fixedcm, const std::functionAmbientOccludeScene(GLInterface.GetMatrix(Matrix_Projection).get()[5]); + if (gl_ssao) + { + glDrawBuffers(1, buffers); + OpenGLRenderer::GLRenderer->AmbientOccludeScene(GLInterface.GetProjectionM5()); glViewport(screen->mSceneViewport.left, screen->mSceneViewport.top, screen->mSceneViewport.width, screen->mSceneViewport.height); - OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(true); - glDrawBuffers(3, buffers); + OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(true); + glDrawBuffers(3, buffers); // To do: the translucent part of the scene should be drawn here glDrawBuffers(1, buffers); - } + } OpenGLRenderer::GLRenderer->mBuffers->BlitSceneToTexture(); // Copy the resulting scene to the current post process texture screen->PostProcessScene(0, []() { diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index bd04412fc..176eee4fa 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -317,6 +317,7 @@ void GLInstance::UnbindAllTextures() void GLInstance::SetMatrix(int num, const VSMatrix *mat) { + if (num == Matrix_Projection) mProjectionM5 = mat->get()[5]; renderState.matrixIndex[num] = matrixArray.Size(); matrixArray.Push(*mat); } diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index 7369659c2..d5e497dd4 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -199,8 +199,7 @@ class GLInstance int LastVB_Offset[2] = {}; IIndexBuffer* LastIndexBuffer = nullptr; - - VSMatrix matrices[NUMMATRICES]; + float mProjectionM5 = 1.0f; // needed by ssao PolymostRenderState renderState; FShader* activeShader; PolymostShader* polymostShader; @@ -260,10 +259,7 @@ public: LastIndexBuffer = (IIndexBuffer*)~intptr_t(0); } - const VSMatrix &GetMatrix(int num) - { - return matrices[num]; - } + float GetProjectionM5() { return mProjectionM5; } void SetMatrix(int num, const VSMatrix *mat ); void SetMatrix(int num, const float *mat) {