diff options
Diffstat (limited to 'source/blender/blenlib/intern/math_color_blend_inline.c')
-rw-r--r-- | source/blender/blenlib/intern/math_color_blend_inline.c | 16 |
1 files changed, 5 insertions, 11 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..73ecb2cf798 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); } } @@ -896,15 +896,9 @@ MINLINE void blend_color_softlight_float(float dst[4], const float src1[4], cons int i = 3; while (i--) { - float temp; - - if (src1[i] < 0.5f) { - temp = (src2[i] + 0.5f) * src1[i]; - } - else { - temp = 1.0f - ((1.0f - (src2[i] + 0.5f)) * (1.0f - src1[i])); - } - dst[i] = (temp * fac + src1[i] * mfac); + float screen = 1.0f - (1.0f - src1[i]) * (1.0f - src2[i]); + float soft_light = ((1.0f - src1[i]) * src2[i] + screen) * src1[i]; + dst[i] = src1[i] * mfac + soft_light * fac; } } else { |