diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-07-23 22:27:06 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-07-23 22:27:06 +0400 |
commit | 4c22d38f92d4b68b932cfa863e06f15773097518 (patch) | |
tree | 499922211f6014bc6b1601a1c6d03c39a8e92ac2 /source/blender/compositor/nodes/COM_KeyingNode.cpp | |
parent | 72309f65b812d4292281397218d1533b626bf8b5 (diff) |
Keying: apply garbage / core mattes after clamping
Applying this mattes before clamping produced ugly outline around
matte boundaries.
Diffstat (limited to 'source/blender/compositor/nodes/COM_KeyingNode.cpp')
-rw-r--r-- | source/blender/compositor/nodes/COM_KeyingNode.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp index efd50a44a51..6bc9afba32c 100644 --- a/source/blender/compositor/nodes/COM_KeyingNode.cpp +++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp @@ -30,6 +30,8 @@ #include "COM_KeyingDespillOperation.h" #include "COM_KeyingClipOperation.h" +#include "COM_MathBaseOperation.h" + #include "COM_SeparateChannelOperation.h" #include "COM_CombineChannelsOperation.h" #include "COM_ConvertRGBToYCCOperation.h" @@ -239,8 +241,6 @@ 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); - inputCoreMatte->relinkConnections(keyingOperation->getInputSocket(3), 3, graph); if (keying_data->blur_pre) { /* chroma preblur operation for input of keying operation */ @@ -256,18 +256,54 @@ void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext * postprocessedMatte = keyingOperation->getOutputSocket(); + /* black / white clipping */ if (keying_data->clip_black > 0.0f || keying_data->clip_white < 1.0f) { postprocessedMatte = setupClip(graph, postprocessedMatte, keying_data->edge_kernel_radius, keying_data->edge_kernel_tolerance, keying_data->clip_black, keying_data->clip_white, false); } + /* output edge matte */ if (outputEdges->isConnected()) { edgesMatte = setupClip(graph, postprocessedMatte, keying_data->edge_kernel_radius, keying_data->edge_kernel_tolerance, keying_data->clip_black, keying_data->clip_white, true); } + /* apply garbage matte */ + if (inputGarbageMatte->isConnected()) { + SetValueOperation *valueOperation = new SetValueOperation(); + MathSubtractOperation *subtractOperation = new MathSubtractOperation(); + MathMinimumOperation *minOperation = new MathMinimumOperation(); + + valueOperation->setValue(1.0f); + + addLink(graph, valueOperation->getOutputSocket(), subtractOperation->getInputSocket(0)); + inputGarbageMatte->relinkConnections(subtractOperation->getInputSocket(1), 0, graph); + + addLink(graph, subtractOperation->getOutputSocket(), minOperation->getInputSocket(0)); + addLink(graph, postprocessedMatte, minOperation->getInputSocket(1)); + + postprocessedMatte = minOperation->getOutputSocket(); + + graph->addOperation(valueOperation); + graph->addOperation(subtractOperation); + graph->addOperation(minOperation); + } + + /* apply core matte */ + if (inputCoreMatte->isConnected()) { + MathMaximumOperation *maxOperation = new MathMaximumOperation(); + + inputCoreMatte->relinkConnections(maxOperation->getInputSocket(0), 0, graph); + + addLink(graph, postprocessedMatte, maxOperation->getInputSocket(1)); + + postprocessedMatte = maxOperation->getOutputSocket(); + + graph->addOperation(maxOperation); + } + /* apply blur on matte if needed */ if (keying_data->blur_post) postprocessedMatte = setupPostBlur(graph, postprocessedMatte, keying_data->blur_post); |