From 1350720a8f926f89ae03604ad3017109b9817ca0 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Thu, 28 Jul 2022 12:18:49 +0300 Subject: [PATCH] Fix Rotxel with Smear producing wrong alpha values for pixels outside the selection --- src/Shaders/Rotation/SmearRotxel.shader | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Shaders/Rotation/SmearRotxel.shader b/src/Shaders/Rotation/SmearRotxel.shader index 79f6adab8..a89d381ca 100644 --- a/src/Shaders/Rotation/SmearRotxel.shader +++ b/src/Shaders/Rotation/SmearRotxel.shader @@ -119,9 +119,11 @@ void fragment() { vec4 rotated_selection = rotate(selection_tex, UV, TEXTURE_PIXEL_SIZE); vec4 rotated = rotate(TEXTURE, UV, TEXTURE_PIXEL_SIZE); rotated = mix(vec4(0.0), rotated, rotated_selection.a); + rotated.a *= rotated_selection.a; // Combine with selection mask + float mask = mix(selection.a, 1.0, 1.0 - ceil(original.a)); // Combine selection mask with area outside original // Combine original and rotated image only when intersecting, otherwise just pure rotated image. - COLOR.rgb = mix(mix(original.rgb, rotated.rgb, rotated.a), rotated.rgb, selection.a); + COLOR.rgb = mix(mix(original.rgb, rotated.rgb, rotated.a), rotated.rgb, mask); COLOR.a = mix(original.a, 0.0, selection.a); // Remove alpha on the selected area COLOR.a = mix(COLOR.a, 1.0, rotated.a); // Combine alpha of original image and rotated }