diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-06-15 12:26:49 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-06-15 12:26:49 +0400 |
commit | c9f1477fb07a89be657b5ca5d2fd29b29b556e5d (patch) | |
tree | 1333c9b8ed5dd1bb43d0e66b78bd4163a402e6f3 | |
parent | 9c55e7b9956313bbaf034925e49abbd0260fe457 (diff) |
Garbage mate input for keying node
This adds garbage matte input to new keying node which is used to
force occluding things which can not be eliminated by color operations.
White areas defines areas which should be removed from final result.
4 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp index 74af25b8e5f..b1bde9643df 100644 --- a/source/blender/compositor/nodes/COM_KeyingNode.cpp +++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp @@ -156,6 +156,7 @@ void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext * { InputSocket *inputImage = this->getInputSocket(0); InputSocket *inputScreen = this->getInputSocket(1); + InputSocket *inputGarbageMatte = this->getInputSocket(2); OutputSocket *outputImage = this->getOutputSocket(0); OutputSocket *outputMatte = this->getOutputSocket(1); OutputSocket *outputEdges = this->getOutputSocket(2); @@ -170,6 +171,7 @@ void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext * keyingOperation->setScreenBalance(keying_data->screen_balance); inputScreen->relinkConnections(keyingOperation->getInputSocket(1), 1, graph); + inputGarbageMatte->relinkConnections(keyingOperation->getInputSocket(2), 2, graph); if (keying_data->blur_pre) { /* chroma preblur operation for input of keying operation */ diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp index fba4dc65faf..599989d52dc 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp @@ -56,33 +56,39 @@ KeyingOperation::KeyingOperation(): NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); this->screenBalance = 0.5f; this->pixelReader = NULL; this->screenReader = NULL; + this->garbageReader = NULL; } void KeyingOperation::initExecution() { this->pixelReader = this->getInputSocketReader(0); this->screenReader = this->getInputSocketReader(1); + this->garbageReader = this->getInputSocketReader(2); } void KeyingOperation::deinitExecution() { this->pixelReader = NULL; this->screenReader = NULL; + this->garbageReader = NULL; } void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float pixelColor[4]; float screenColor[4]; + float garbageValue[4]; this->pixelReader->read(pixelColor, x, y, sampler, inputBuffers); this->screenReader->read(screenColor, x, y, sampler, inputBuffers); + this->garbageReader->read(garbageValue, x, y, sampler, inputBuffers); int primary_channel = get_pixel_primary_channel(screenColor); @@ -100,6 +106,8 @@ void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler color[0] = distance; } + + color[0] *= (1.0f - garbageValue[0]); } bool KeyingOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_KeyingOperation.h b/source/blender/compositor/operations/COM_KeyingOperation.h index 0fc13407d14..657a1ff807c 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.h +++ b/source/blender/compositor/operations/COM_KeyingOperation.h @@ -38,6 +38,8 @@ class KeyingOperation : public NodeOperation { protected: SocketReader *pixelReader; SocketReader *screenReader; + SocketReader *garbageReader; + float screenBalance; public: diff --git a/source/blender/nodes/composite/nodes/node_composite_keying.c b/source/blender/nodes/composite/nodes/node_composite_keying.c index e5bf3b7ae62..31a8a0d67a6 100644 --- a/source/blender/nodes/composite/nodes/node_composite_keying.c +++ b/source/blender/nodes/composite/nodes/node_composite_keying.c @@ -46,8 +46,9 @@ /* **************** Translate ******************** */ static bNodeSocketTemplate cmp_node_keying_in[] = { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - { SOCK_RGBA, 1, "Key Color", 1.0f, 1.0f, 1.0f, 1.0f}, + { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 1, "Key Color", 1.0f, 1.0f, 1.0f, 1.0f}, + { SOCK_FLOAT, 1, "Garbage Matte", 0.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; |