From ac58a7fa190de82ee8265cfe9f1b7a7323b86982 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 7 Dec 2016 13:52:12 +0100 Subject: Compositor: Make HSV node inputs a real sockets This is much more flexible solution which will allow doing some more procedural features. Reviewers: brecht, dfelinto, mont29 Reviewed By: mont29 Subscribers: Severin Differential Revision: https://developer.blender.org/D2403 --- .../compositor/nodes/COM_HueSaturationValueNode.cpp | 15 +++++++++------ .../compositor/operations/COM_ChangeHSVOperation.cpp | 19 ++++++++++++++++--- .../compositor/operations/COM_ChangeHSVOperation.h | 11 +++-------- 3 files changed, 28 insertions(+), 17 deletions(-) (limited to 'source/blender/compositor') diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp index 29c296a896d..b8971fffe3e 100644 --- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp +++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp @@ -37,8 +37,11 @@ HueSaturationValueNode::HueSaturationValueNode(bNode *editorNode) : Node(editorN void HueSaturationValueNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const { - NodeInput *valueSocket = this->getInputSocket(0); - NodeInput *colorSocket = this->getInputSocket(1); + NodeInput *colorSocket = this->getInputSocket(0); + NodeInput *hueSocket = this->getInputSocket(1); + NodeInput *saturationSocket = this->getInputSocket(2); + NodeInput *valueSocket = this->getInputSocket(3); + NodeInput *facSocket = this->getInputSocket(4); NodeOutput *outputSocket = this->getOutputSocket(0); bNode *editorsnode = getbNode(); NodeHueSat *storage = (NodeHueSat *)editorsnode->storage; @@ -50,9 +53,9 @@ void HueSaturationValueNode::convertToOperations(NodeConverter &converter, const converter.addOperation(hsvToRGB); ChangeHSVOperation *changeHSV = new ChangeHSVOperation(); - changeHSV->setHue(storage->hue); - changeHSV->setSaturation(storage->sat); - changeHSV->setValue(storage->val); + converter.mapInputSocket(hueSocket, changeHSV->getInputSocket(1)); + converter.mapInputSocket(saturationSocket, changeHSV->getInputSocket(2)); + converter.mapInputSocket(valueSocket, changeHSV->getInputSocket(3)); converter.addOperation(changeHSV); MixBlendOperation *blend = new MixBlendOperation(); @@ -64,6 +67,6 @@ void HueSaturationValueNode::convertToOperations(NodeConverter &converter, const converter.addLink(changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); converter.addLink(hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); converter.mapInputSocket(colorSocket, blend->getInputSocket(1)); - converter.mapInputSocket(valueSocket, blend->getInputSocket(0)); + converter.mapInputSocket(facSocket, blend->getInputSocket(0)); converter.mapOutputSocket(outputSocket, blend->getOutputSocket()); } diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp index 964f1d64667..7ea974a41dc 100644 --- a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp +++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp @@ -25,6 +25,9 @@ ChangeHSVOperation::ChangeHSVOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_VALUE); + this->addInputSocket(COM_DT_VALUE); + this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->m_inputOperation = NULL; } @@ -32,24 +35,34 @@ ChangeHSVOperation::ChangeHSVOperation() : NodeOperation() void ChangeHSVOperation::initExecution() { this->m_inputOperation = getInputSocketReader(0); + this->m_hueOperation = getInputSocketReader(1); + this->m_saturationOperation = getInputSocketReader(2); + this->m_valueOperation = getInputSocketReader(3); } void ChangeHSVOperation::deinitExecution() { this->m_inputOperation = NULL; + this->m_hueOperation = NULL; + this->m_saturationOperation = NULL; + this->m_valueOperation = NULL; } void ChangeHSVOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; + float hue[4], saturation[4], value[4]; this->m_inputOperation->readSampled(inputColor1, x, y, sampler); + this->m_hueOperation->readSampled(hue, x, y, sampler); + this->m_saturationOperation->readSampled(saturation, x, y, sampler); + this->m_valueOperation->readSampled(value, x, y, sampler); - output[0] = inputColor1[0] + (this->m_hue - 0.5f); + output[0] = inputColor1[0] + (hue[0] - 0.5f); if (output[0] > 1.0f) output[0] -= 1.0f; else if (output[0] < 0.0f) output[0] += 1.0f; - output[1] = inputColor1[1] * this->m_saturation; - output[2] = inputColor1[2] * this->m_value; + output[1] = inputColor1[1] * saturation[0]; + output[2] = inputColor1[2] * value[0]; output[3] = inputColor1[3]; } diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.h b/source/blender/compositor/operations/COM_ChangeHSVOperation.h index 76025e86b7a..800c09c05ff 100644 --- a/source/blender/compositor/operations/COM_ChangeHSVOperation.h +++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.h @@ -32,10 +32,9 @@ class ChangeHSVOperation : public NodeOperation { private: SocketReader *m_inputOperation; - - float m_hue; - float m_saturation; - float m_value; + SocketReader *m_hueOperation; + SocketReader *m_saturationOperation; + SocketReader *m_valueOperation; public: /** @@ -51,9 +50,5 @@ public: */ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); - void setHue(float hue) { this->m_hue = hue; } - void setSaturation(float saturation) { this->m_saturation = saturation; } - void setValue(float value) { this->m_value = value; } - }; #endif -- cgit v1.2.3