diff options
author | Richard Antalik <richardantalik@gmail.com> | 2022-01-04 03:54:35 +0300 |
---|---|---|
committer | Richard Antalik <richardantalik@gmail.com> | 2022-01-04 04:11:38 +0300 |
commit | d2cc672b0c12287b4602e1c26fd9d75010df9558 (patch) | |
tree | 4d91e0f39da72688ba8a6db44b4c66baa7bc45a8 /source/blender/blenlib | |
parent | 9c85acf61d551ce0dba9b20ebd4b244fe5eb42c3 (diff) |
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.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/math_color_blend_inline.c | 12 |
1 files 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 { |