diff --git a/Source/Managers/FrameMan.cpp b/Source/Managers/FrameMan.cpp index 0799a475c6..57936a4b59 100644 --- a/Source/Managers/FrameMan.cpp +++ b/Source/Managers/FrameMan.cpp @@ -901,8 +901,11 @@ void FrameMan::Draw() { backgroundShader.End(); if (screenCount > 1) { m_BackBuffer->Begin(false); + // Copy without blending, otherwise anything drawn translucent comes out darker. + rlDisableColorBlend(); DrawTextureRec(m_PlayerScreen->GetColorTexture(), {0, 0, static_cast(m_PlayerScreen8->w), -static_cast(m_PlayerScreen8->h)}, {screenOffset.m_X, screenOffset.m_Y}, {255, 255, 255, 255}); m_BackBuffer->End(); + rlEnableColorBlend(); } g_PostProcessMan.AdjustEffectsPosToPlayerScreen(playerScreen, drawScreen, screenOffset, screenRelativeEffects, screenRelativeGlowBoxes); } diff --git a/Source/Managers/PostProcessMan.cpp b/Source/Managers/PostProcessMan.cpp index 7afe820782..bb9b1ccdff 100644 --- a/Source/Managers/PostProcessMan.cpp +++ b/Source/Managers/PostProcessMan.cpp @@ -337,6 +337,8 @@ void PostProcessMan::PostProcess() { rlDisableDepthTest(); DrawTextureRec(g_FrameMan.GetBackBuffer()->GetColorTexture(), {0, 0, g_FrameMan.GetBackBuffer()->GetSize().w, -g_FrameMan.GetBackBuffer()->GetSize().h}, {0.0f, 0.0f}, {255, 255, 255, 255}); //m_Blit8->End(); + // Draw the copy while blending is still off, otherwise anything drawn translucent comes out darker. + rlDrawRenderBatchActive(); // Set the screen blender mode for glows set_screen_blender(128, 128, 128, 128); diff --git a/Source/Managers/PrimitiveMan.cpp b/Source/Managers/PrimitiveMan.cpp index a16bc14beb..2fe52b3637 100644 --- a/Source/Managers/PrimitiveMan.cpp +++ b/Source/Managers/PrimitiveMan.cpp @@ -254,7 +254,15 @@ void PrimitiveMan::DrawPrimitives(int player, BITMAP* targetBitmap, const Vector rlEnableShader(rlGetShaderCurrent()); g_FrameMan.SetBlendMode(blendMode); GLint colorUniform = glGetUniformLocation(rlGetShaderCurrent(), "rteColor"); - glUniform4f(colorUniform, blendAmounts[0] / static_cast(MaxBlend), blendAmounts[1] / static_cast(MaxBlend), blendAmounts[2] / static_cast(MaxBlend), blendAmounts[3] / static_cast(MaxBlend)); + // Blend amounts go from 0 for the full effect to 100 for invisible. Transparency uses the RGB amounts, averaged since alpha blending can't do each channel separately, and the other modes only use the alpha amount. + int blendAmount = (blendMode == BlendTransparency) ? (blendAmounts[0] + blendAmounts[1] + blendAmounts[2]) / 3 : blendAmounts[3]; + float strength = 1.0f - RoundToNearestMultiple(blendAmount, c_BlendAmountStep) / static_cast(MaxBlend); + if (blendMode == BlendTransparency || blendMode == BlendInvert || blendMode == BlendDissolve) { + glUniform4f(colorUniform, 1.0f, 1.0f, 1.0f, strength); + } else { + // The other blend equations take the color premultiplied by its alpha. + glUniform4f(colorUniform, strength, strength, strength, strength); + } lastBlendMode = blendMode; lastBlendAmounts = blendAmounts; }