diff options
Diffstat (limited to 'source/blender')
3 files changed, 16 insertions, 23 deletions
diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.cpp b/source/blender/compositor/nodes/COM_ColorSpillNode.cpp index c3a911e830b..f33f2858397 100644 --- a/source/blender/compositor/nodes/COM_ColorSpillNode.cpp +++ b/source/blender/compositor/nodes/COM_ColorSpillNode.cpp @@ -38,16 +38,10 @@ void ColorSpillNode::convertToOperations(NodeConverter &converter, const Composi NodeOutput *outputSocketImage = this->getOutputSocket(0); ColorSpillOperation *operation; - if (editorsnode->custom2 == 0) { - // Simple color spill - operation = new ColorSpillOperation(); - } - else { - // Average color spill - operation = new ColorSpillAverageOperation(); - } + operation = new ColorSpillOperation(); operation->setSettings((NodeColorspill *)editorsnode->storage); operation->setSpillChannel(editorsnode->custom1 - 1); // Channel for spilling + operation->setSpillMethod(editorsnode->custom2); // Channel method converter.addOperation(operation); converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0)); diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp index 873ec72d9e9..0769e5d0b01 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp @@ -33,6 +33,7 @@ ColorSpillOperation::ColorSpillOperation() : NodeOperation() this->m_inputImageReader = NULL; this->m_inputFacReader = NULL; this->m_spillChannel = 1; // GREEN + this->m_spillMethod = 0; } void ColorSpillOperation::initExecution() @@ -91,7 +92,17 @@ void ColorSpillOperation::executePixelSampled(float output[4], float x, float y, this->m_inputFacReader->readSampled(fac, x, y, sampler); this->m_inputImageReader->readSampled(input, x, y, sampler); float rfac = min(1.0f, fac[0]); - float map = calculateMapValue(rfac, input); + float map; + + switch (this->m_spillMethod) { + case 0: /* simple */ + map = rfac * (input[this->m_spillChannel] - (this->m_settings->limscale * input[this->m_settings->limchan])); + break; + default: /* average */ + map = rfac * (input[this->m_spillChannel] - (this->m_settings->limscale * AVG(input[this->m_channel2], input[this->m_channel3]))); + break; + } + if (map > 0.0f) { output[0] = input[0] + this->m_rmut * (this->m_settings->uspillr * map); output[1] = input[1] + this->m_gmut * (this->m_settings->uspillg * map); @@ -102,13 +113,3 @@ void ColorSpillOperation::executePixelSampled(float output[4], float x, float y, copy_v4_v4(output, input); } } -float ColorSpillOperation::calculateMapValue(float fac, float *input) -{ - return fac * (input[this->m_spillChannel] - (this->m_settings->limscale * input[this->m_settings->limchan])); -} - - -float ColorSpillAverageOperation::calculateMapValue(float fac, float *input) -{ - return fac * (input[this->m_spillChannel] - (this->m_settings->limscale * AVG(input[this->m_channel2], input[this->m_channel3]))); -} diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.h b/source/blender/compositor/operations/COM_ColorSpillOperation.h index f9dc9ef7e25..3b94c293ec9 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.h +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.h @@ -34,6 +34,7 @@ protected: SocketReader *m_inputImageReader; SocketReader *m_inputFacReader; int m_spillChannel; + int m_spillMethod; int m_channel2; int m_channel3; float m_rmut, m_gmut, m_bmut; @@ -53,12 +54,9 @@ public: void setSettings(NodeColorspill *nodeColorSpill) { this->m_settings = nodeColorSpill; } void setSpillChannel(int channel) { this->m_spillChannel = channel; } + void setSpillMethod(int method) { this->m_spillMethod = method; } float calculateMapValue(float fac, float *input); }; -class ColorSpillAverageOperation : public ColorSpillOperation { -public: - float calculateMapValue(float fac, float *input); -}; #endif |