[Bf-blender-cvs] [9c85acf61d5] master: Fix out of range color in blend modes

Richard Antalik noreply at git.blender.org
Tue Jan 4 02:11:58 CET 2022


Commit: 9c85acf61d551ce0dba9b20ebd4b244fe5eb42c3
Author: Richard Antalik
Date:   Tue Jan 4 01:34:23 2022 +0100
Branches: master
https://developer.blender.org/rB9c85acf61d551ce0dba9b20ebd4b244fe5eb42c3

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.

===================================================================

M	source/blender/blenlib/intern/math_color_blend_inline.c

===================================================================

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);
     }
   }



More information about the Bf-blender-cvs mailing list