From 3b634064c923f3544f61d9444466dd8fa539acb0 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Wed, 16 Apr 2025 19:57:01 +0200 Subject: [PATCH] gl_engine: fix drop shadow blended color The shadow color produced incorrect results after blending with the texture color. This was caused by not taking the alpha value into account in the specified shadow color (with OpenGL blending disabled). --- src/renderer/gl_engine/tvgGlRenderer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/renderer/gl_engine/tvgGlRenderer.cpp b/src/renderer/gl_engine/tvgGlRenderer.cpp index c15ae64e..c8cdd986 100644 --- a/src/renderer/gl_engine/tvgGlRenderer.cpp +++ b/src/renderer/gl_engine/tvgGlRenderer.cpp @@ -979,10 +979,11 @@ void GlRenderer::effectDropShadowUpdate(RenderEffectDropShadow* effect, const Ma dropShadow->sigma = sigma; dropShadow->scale = scale; dropShadow->level = int(GL_GAUSSIAN_MAX_LEVEL * ((effect->quality - 1) * 0.01f)) + 1; - dropShadow->color[0] = effect->color[0] / 255.0f; - dropShadow->color[1] = effect->color[1] / 255.0f; - dropShadow->color[2] = effect->color[2] / 255.0f; dropShadow->color[3] = effect->color[3] / 255.0f; + //Drop shadow effect applies blending in the shader (GL_BLEND disabled), so the color should be premultiplied: + dropShadow->color[0] = effect->color[0] / 255.0f * dropShadow->color[3]; + dropShadow->color[1] = effect->color[1] / 255.0f * dropShadow->color[3]; + dropShadow->color[2] = effect->color[2] / 255.0f * dropShadow->color[3]; dropShadow->offset[0] = offset.x; dropShadow->offset[1] = offset.y; dropShadow->extend = 2 * std::max(sigma * scale + std::abs(offset.x), sigma * scale + std::abs(offset.y));