diff --git a/game/graphics/opengl_renderer/DirectRenderer.cpp b/game/graphics/opengl_renderer/DirectRenderer.cpp index d6d1d5caeb..62242fc4dc 100644 --- a/game/graphics/opengl_renderer/DirectRenderer.cpp +++ b/game/graphics/opengl_renderer/DirectRenderer.cpp @@ -361,7 +361,8 @@ void DirectRenderer::update_gl_blend() { // (Cs - Cd) * As + Cd // Cs * As + (1 - As) * Cd // s, d - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); glBlendEquation(GL_FUNC_ADD); } else if (state.a == GsAlpha::BlendMode::SOURCE && state.b == GsAlpha::BlendMode::ZERO_OR_FIXED && @@ -370,7 +371,7 @@ void DirectRenderer::update_gl_blend() { // Cs * As + (1) * Cd // s, d ASSERT(state.fix == 0); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ZERO); glBlendEquation(GL_FUNC_ADD); } else if (state.a == GsAlpha::BlendMode::ZERO_OR_FIXED && state.b == GsAlpha::BlendMode::SOURCE && state.c == GsAlpha::BlendMode::SOURCE && @@ -378,26 +379,26 @@ void DirectRenderer::update_gl_blend() { // (0 - Cs) * As + Cd // Cd - Cs * As // s, d - glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ZERO); glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); } else if (state.a == GsAlpha::BlendMode::SOURCE && state.b == GsAlpha::BlendMode::DEST && state.c == GsAlpha::BlendMode::ZERO_OR_FIXED && state.d == GsAlpha::BlendMode::DEST) { // (Cs - Cd) * fix + Cd // Cs * fix + (1 - fx) * Cd - glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA); + glBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO); glBlendColor(0, 0, 0, state.fix / 127.f); glBlendEquation(GL_FUNC_ADD); } else if (state.a == GsAlpha::BlendMode::SOURCE && state.b == GsAlpha::BlendMode::SOURCE && state.c == GsAlpha::BlendMode::SOURCE && state.d == GsAlpha::BlendMode::SOURCE) { // this is very weird... - glBlendFunc(GL_ONE, GL_ZERO); + glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO); glBlendEquation(GL_FUNC_ADD); } else if (state.a == GsAlpha::BlendMode::SOURCE && state.b == GsAlpha::BlendMode::ZERO_OR_FIXED && state.c == GsAlpha::BlendMode::DEST && state.d == GsAlpha::BlendMode::DEST) { // (Cs - 0) * Ad + Cd - glBlendFunc(GL_DST_ALPHA, GL_ONE); + glBlendFuncSeparate(GL_DST_ALPHA, GL_ONE, GL_ONE, GL_ZERO); glBlendEquation(GL_FUNC_ADD); m_ogl.color_mult = 0.5; } else { @@ -412,16 +413,9 @@ void DirectRenderer::update_gl_blend() { if (state.a == GsAlpha::BlendMode::SOURCE && state.b == GsAlpha::BlendMode::DEST && state.c == GsAlpha::BlendMode::SOURCE && state.d == GsAlpha::BlendMode::DEST) { if (m_prim_gl_state.fogging_enable) { - // first draw. - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - m_ogl.alpha_mult = .5f; - glBlendEquation(GL_FUNC_ADD); } else { - // second draw. - m_ogl.alpha_mult = 2.f; - glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_ALPHA, GL_ZERO); - glBlendEquation(GL_FUNC_ADD); + glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_ONE, GL_ZERO); } } } @@ -457,7 +451,10 @@ void DirectRenderer::update_gl_test() { ASSERT(false); } - if (state.depth_writes) { + bool alpha_trick_to_disable = m_test_state.alpha_test_enable && + m_test_state.alpha_test == GsTest::AlphaTest::NEVER && + m_test_state.afail == GsTest::AlphaFail::FB_ONLY; + if (state.depth_writes && !alpha_trick_to_disable) { glDepthMask(GL_TRUE); } else { glDepthMask(GL_FALSE); @@ -831,7 +828,6 @@ void DirectRenderer::handle_zbuf1(u64 val, bool write = !x.zmsk(); // ASSERT(write); - if (write != m_test_state.depth_writes) { m_stats.flush_from_zbuf++; flush_pending(render_state, prof); diff --git a/game/graphics/opengl_renderer/DirectRenderer2.cpp b/game/graphics/opengl_renderer/DirectRenderer2.cpp index 7f4d31533c..b495c29df2 100644 --- a/game/graphics/opengl_renderer/DirectRenderer2.cpp +++ b/game/graphics/opengl_renderer/DirectRenderer2.cpp @@ -251,35 +251,35 @@ void DirectRenderer2::setup_opengl_for_draw_mode(const Draw& draw, // (Cs - Cd) * As + Cd // Cs * As + (1 - As) * Cd // s, d - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); glBlendEquation(GL_FUNC_ADD); } else if (draw.mode.get_alpha_blend() == DrawMode::AlphaBlend::SRC_0_SRC_DST) { // (Cs - 0) * As + Cd // Cs * As + (1) * Cd // s, d ASSERT(draw.fix == 0); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ZERO); glBlendEquation(GL_FUNC_ADD); } else if (draw.mode.get_alpha_blend() == DrawMode::AlphaBlend::ZERO_SRC_SRC_DST) { // (0 - Cs) * As + Cd // Cd - Cs * As // s, d - glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ZERO); glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); } else if (draw.mode.get_alpha_blend() == DrawMode::AlphaBlend::SRC_DST_FIX_DST) { // (Cs - Cd) * fix + Cd // Cs * fix + (1 - fx) * Cd - glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA); + glBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO); glBlendColor(0, 0, 0, draw.fix / 127.f); glBlendEquation(GL_FUNC_ADD); } else if (draw.mode.get_alpha_blend() == DrawMode::AlphaBlend::SRC_SRC_SRC_SRC) { // this is very weird... // Cs - glBlendFunc(GL_ONE, GL_ZERO); + glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO); glBlendEquation(GL_FUNC_ADD); } else if (draw.mode.get_alpha_blend() == DrawMode::AlphaBlend::SRC_0_DST_DST) { // (Cs - 0) * Ad + Cd - glBlendFunc(GL_DST_ALPHA, GL_ONE); + glBlendFuncSeparate(GL_DST_ALPHA, GL_ONE, GL_ONE, GL_ZERO); glBlendEquation(GL_FUNC_ADD); color_mult = 0.5; } else { diff --git a/game/graphics/opengl_renderer/background/background_common.cpp b/game/graphics/opengl_renderer/background/background_common.cpp index 92027c5734..aefd747f05 100644 --- a/game/graphics/opengl_renderer/background/background_common.cpp +++ b/game/graphics/opengl_renderer/background/background_common.cpp @@ -37,26 +37,26 @@ DoubleDraw setup_opengl_from_draw_mode(DrawMode mode, u32 tex_unit, bool mipmap) switch (mode.get_alpha_blend()) { case DrawMode::AlphaBlend::SRC_DST_SRC_DST: glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); break; case DrawMode::AlphaBlend::SRC_0_SRC_DST: glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ZERO); break; case DrawMode::AlphaBlend::SRC_0_FIX_DST: glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_ONE, GL_ONE); + glBlendFuncSeparate(GL_ONE, GL_ONE, GL_ONE, GL_ZERO); break; case DrawMode::AlphaBlend::SRC_DST_FIX_DST: // Cv = (Cs - Cd) * FIX + Cd // Cs * FIX * 0.5 // Cd * FIX * 0.5 glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_CONSTANT_COLOR, GL_CONSTANT_COLOR); + glBlendFuncSeparate(GL_CONSTANT_COLOR, GL_CONSTANT_COLOR, GL_ONE, GL_ZERO); glBlendColor(0.5, 0.5, 0.5, 0.5); break; case DrawMode::AlphaBlend::ZERO_SRC_SRC_DST: - glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ZERO); glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); break; default: diff --git a/game/graphics/opengl_renderer/ocean/OceanTexture.cpp b/game/graphics/opengl_renderer/ocean/OceanTexture.cpp index 6d8eb413a7..dca60afe69 100644 --- a/game/graphics/opengl_renderer/ocean/OceanTexture.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanTexture.cpp @@ -305,7 +305,7 @@ void OceanTexture::make_texture_with_mipmaps(SharedRenderState* render_state, FramebufferTexturePairContext ctxt(m_result_texture, i); glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::OCEAN_TEXTURE_MIPMAP].id(), "alpha_intensity"), - std::max(0.f, 1.f - 0.4f * i)); + std::max(0.f, 1.f - 0.51f * i)); glUniform1f( glGetUniformLocation(render_state->shaders[ShaderId::OCEAN_TEXTURE_MIPMAP].id(), "scale"), 1.f / (1 << i));