From d2cc672b0c12287b4602e1c26fd9d75010df9558 Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Tue, 4 Jan 2022 01:54:35 +0100 Subject: Fix soft light blend mode math Function `blend_color_softlight_float` used math different to compositor and produced result that had abrupt value changes. Use math based on modified screen blend mode as compositor does. --- source/blender/blenlib/intern/math_color_blend_inline.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/source/blender/blenlib/intern/math_color_blend_inline.c b/source/blender/blenlib/intern/math_color_blend_inline.c index a19537bca0f..73ecb2cf798 100644 --- a/source/blender/blenlib/intern/math_color_blend_inline.c +++ b/source/blender/blenlib/intern/math_color_blend_inline.c @@ -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 { -- cgit v1.2.3