From 0a76a4f0a30d28ea6fa1ab7869c88c025a835be3 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Thu, 30 Jan 2025 14:19:05 +0100 Subject: [PATCH] gl_engine: fix color burn/dodge edge cases Aligned with sw_engine implementation. --- src/renderer/gl_engine/tvgGlShaderSrc.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/renderer/gl_engine/tvgGlShaderSrc.cpp b/src/renderer/gl_engine/tvgGlShaderSrc.cpp index 85741773..648f0152 100644 --- a/src/renderer/gl_engine/tvgGlShaderSrc.cpp +++ b/src/renderer/gl_engine/tvgGlShaderSrc.cpp @@ -691,9 +691,9 @@ const char* COLOR_DODGE_BLEND_FRAG = COMPLEX_BLEND_HEADER R"( vec4 dstColor = texture(uDstTexture, vUV); FragColor = vec4( - 1.0 - srcColor.r > 0.0 ? dstColor.r / (1.0 - srcColor.r) : dstColor.r, - 1.0 - srcColor.g > 0.0 ? dstColor.g / (1.0 - srcColor.g) : dstColor.g, - 1.0 - srcColor.b > 0.0 ? dstColor.b / (1.0 - srcColor.b) : dstColor.b, + srcColor.r < 1.0 ? dstColor.r / (1.0 - srcColor.r) : (dstColor.r > 0.0 ? 1.0 : 0.0), + srcColor.g < 1.0 ? dstColor.g / (1.0 - srcColor.g) : (dstColor.g > 0.0 ? 1.0 : 0.0), + srcColor.b < 1.0 ? dstColor.b / (1.0 - srcColor.b) : (dstColor.b > 0.0 ? 1.0 : 0.0), 1.0 ); } @@ -705,9 +705,9 @@ const char* COLOR_BURN_BLEND_FRAG = COMPLEX_BLEND_HEADER R"( vec4 dstColor = texture(uDstTexture, vUV); FragColor = vec4( - srcColor.r > 0.0 ? (1.0 - (1.0 - dstColor.r) / srcColor.r) : dstColor.r, - srcColor.g > 0.0 ? (1.0 - (1.0 - dstColor.g) / srcColor.g) : dstColor.g, - srcColor.b > 0.0 ? (1.0 - (1.0 - dstColor.b) / srcColor.b) : dstColor.b, + srcColor.r > 0.0 ? (1.0 - (1.0 - dstColor.r) / srcColor.r) : (dstColor.r < 1.0 ? 0.0 : 1.0), + srcColor.g > 0.0 ? (1.0 - (1.0 - dstColor.g) / srcColor.g) : (dstColor.g < 1.0 ? 0.0 : 1.0), + srcColor.b > 0.0 ? (1.0 - (1.0 - dstColor.b) / srcColor.b) : (dstColor.b < 1.0 ? 0.0 : 1.0), 1.0 ); }