diff options
author | Antonioya <blendergit@gmail.com> | 2019-05-28 16:55:17 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2019-05-28 16:55:31 +0300 |
commit | f139caa6322fc71a16f9c22f4202d6dde42573a7 (patch) | |
tree | 7c58661e76dc51676cb5d1b75612ae5e1465b558 /source/blender/draw | |
parent | 5778e616e5adc58a5669f3f24ad2358e947dd8d8 (diff) |
Fix T65187: Overlay blend increase wrongly the opacity
The calculation of the mix color was not using the bottom color when the alpha was lower than 1.0.
Also added clamp code to avoid values outside valid ranges.
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl index 0482ea50916..d415ce53137 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl @@ -43,39 +43,38 @@ vec4 get_blend_color(int mode, vec4 src_color, vec4 blend_color) outcolor = src_color; } else if (mode == MODE_OVERLAY) { - mix_color.rgb = mix_color.rgb * mix_color.a * blend_opacity; + mix_color.rgb = mix(src_color.rgb, mix_color.rgb, mix_color.a * blend_opacity); outcolor.r = overlay_color(src_color.r, mix_color.r); outcolor.g = overlay_color(src_color.g, mix_color.g); outcolor.b = overlay_color(src_color.b, mix_color.b); outcolor.a = src_color.a; } else if (mode == MODE_ADD) { - mix_color.rgb = mix_color.rgb * mix_color.a * blend_opacity; + mix_color.rgb = mix(src_color.rgb, mix_color.rgb, mix_color.a * blend_opacity); outcolor = src_color + mix_color; outcolor.a = src_color.a; } else if (mode == MODE_SUB) { + mix_color.rgb = mix(src_color.rgb, mix_color.rgb, mix_color.a * blend_opacity); outcolor = src_color - mix_color; outcolor.a = clamp(src_color.a - (mix_color.a * blend_opacity), 0.0, 1.0); } else if (mode == MODE_MULTIPLY) { - /* interpolate between 1 and color using opacity */ - mix_color.rgb = mix(vec3(1, 1, 1), mix_color.rgb * mix_color.a, blend_opacity); + mix_color.rgb = mix(src_color.rgb, mix_color.rgb, mix_color.a * blend_opacity); outcolor = src_color * mix_color; outcolor.a = src_color.a; } else if (mode == MODE_DIVIDE) { - mix_color.rgb = mix_color.rgb * mix_color.a * blend_opacity; + mix_color.rgb = mix(src_color.rgb, mix_color.rgb, mix_color.a * blend_opacity); outcolor = src_color / mix_color; outcolor.a = src_color.a; } else { outcolor = mix_color * blend_opacity; - ; outcolor.a = src_color.a; } - return outcolor; + return clamp(outcolor, 0.0, 1.0); } float linearrgb_to_srgb(float c) |