Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Antalik <richardantalik@gmail.com>2022-01-04 03:34:23 +0300
committerRichard Antalik <richardantalik@gmail.com>2022-01-04 04:11:38 +0300
commit9c85acf61d551ce0dba9b20ebd4b244fe5eb42c3 (patch)
tree1d7ad4a1015c9c02a43350740ffd632817620436 /source/blender/blenlib/intern/math_color_blend_inline.c
parentd3ad04172de2b928aeb561b74a58996586b1db1c (diff)
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.
Diffstat (limited to 'source/blender/blenlib/intern/math_color_blend_inline.c')
-rw-r--r--source/blender/blenlib/intern/math_color_blend_inline.c4
1 files changed, 2 insertions, 2 deletions
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);
}
}