From 9c85acf61d551ce0dba9b20ebd4b244fe5eb42c3 Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Tue, 4 Jan 2022 01:34:23 +0100 Subject: Fix out of range color in blend modes Result of Exclusion and Pin Light blend modes could be greater than 255 which caused artifacts. Limit color value to 0-255 range. --- source/blender/blenlib/intern/math_color_blend_inline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenlib/intern') diff --git a/source/blender/blenlib/intern/math_color_blend_inline.c b/source/blender/blenlib/intern/math_color_blend_inline.c index 53257cc9285..a19537bca0f 100644 --- a/source/blender/blenlib/intern/math_color_blend_inline.c +++ b/source/blender/blenlib/intern/math_color_blend_inline.c @@ -382,7 +382,7 @@ MINLINE void blend_color_pinlight_byte(uchar dst[4], const uchar src1[4], const else { temp = min_ii(2 * src2[i], src1[i]); } - dst[i] = (uchar)((temp * fac + src1[i] * mfac) / 255); + dst[i] = (uchar)((min_ii(temp, 255) * fac + src1[i] * mfac) / 255); } } else { @@ -473,7 +473,7 @@ MINLINE void blend_color_exclusion_byte(uchar dst[4], const uchar src1[4], const int i = 3; while (i--) { - const int temp = 127 - ((2 * (src1[i] - 127) * (src2[i] - 127)) / 255); + const int temp = 127 - min_ii(((2 * (src1[i] - 127) * (src2[i] - 127)) / 255), 127); dst[i] = (uchar)((temp * fac + src1[i] * mfac) / 255); } } -- cgit v1.2.3