diff options
author | Manuel Castilla <manzanillawork@gmail.com> | 2021-08-13 12:21:29 +0300 |
---|---|---|
committer | Manuel Castilla <manzanillawork@gmail.com> | 2021-08-13 12:21:29 +0300 |
commit | c443b0d47547420d06f2ba76d497c569631137bf (patch) | |
tree | e6bc8023187ae44bbe24b0613be24caf939a4536 /source/blender/compositor | |
parent | 591e46c3355ca81d611c6a9e39f6581489fc4f57 (diff) |
Compositor: Full frame Color Spill node
Diffstat (limited to 'source/blender/compositor')
-rw-r--r-- | source/blender/compositor/operations/COM_ColorSpillOperation.cc | 32 | ||||
-rw-r--r-- | source/blender/compositor/operations/COM_ColorSpillOperation.h | 8 |
2 files changed, 38 insertions, 2 deletions
diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cc b/source/blender/compositor/operations/COM_ColorSpillOperation.cc index 7dc7e2775fc..d579a695a74 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.cc +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cc @@ -118,4 +118,36 @@ void ColorSpillOperation::executePixelSampled(float output[4], } } +void ColorSpillOperation::update_memory_buffer_partial(MemoryBuffer *output, + const rcti &area, + Span<MemoryBuffer *> inputs) +{ + for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) { + const float *color = it.in(0); + const float factor = MIN2(1.0f, *it.in(1)); + + float map; + switch (m_spillMethod) { + case 0: /* simple */ + map = factor * + (color[m_spillChannel] - (m_settings->limscale * color[m_settings->limchan])); + break; + default: /* average */ + map = factor * (color[m_spillChannel] - + (m_settings->limscale * AVG(color[m_channel2], color[m_channel3]))); + break; + } + + if (map > 0.0f) { + it.out[0] = color[0] + m_rmut * (m_settings->uspillr * map); + it.out[1] = color[1] + m_gmut * (m_settings->uspillg * map); + it.out[2] = color[2] + m_bmut * (m_settings->uspillb * map); + it.out[3] = color[3]; + } + else { + copy_v4_v4(it.out, color); + } + } +} + } // namespace blender::compositor diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.h b/source/blender/compositor/operations/COM_ColorSpillOperation.h index 9b82e720527..6a5e688c160 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.h +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.h @@ -18,7 +18,7 @@ #pragma once -#include "COM_NodeOperation.h" +#include "COM_MultiThreadedOperation.h" namespace blender::compositor { @@ -26,7 +26,7 @@ namespace blender::compositor { * this program converts an input color to an output value. * it assumes we are in sRGB color space. */ -class ColorSpillOperation : public NodeOperation { +class ColorSpillOperation : public MultiThreadedOperation { protected: NodeColorspill *m_settings; SocketReader *m_inputImageReader; @@ -65,6 +65,10 @@ class ColorSpillOperation : public NodeOperation { } float calculateMapValue(float fac, float *input); + + void update_memory_buffer_partial(MemoryBuffer *output, + const rcti &area, + Span<MemoryBuffer *> inputs) override; }; } // namespace blender::compositor |