forked from bartvdbraak/blender
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.
This commit is contained in:
parent
9c55e7b995
commit
c9f1477fb0
@ -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 */
|
||||
|
@ -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)
|
||||
|
@ -38,6 +38,8 @@ class KeyingOperation : public NodeOperation {
|
||||
protected:
|
||||
SocketReader *pixelReader;
|
||||
SocketReader *screenReader;
|
||||
SocketReader *garbageReader;
|
||||
|
||||
float screenBalance;
|
||||
|
||||
public:
|
||||
|
@ -48,6 +48,7 @@
|
||||
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_FLOAT, 1, "Garbage Matte", 0.0f, 1.0f, 1.0f, 1.0f},
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user