void ColorSpillNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *inputSocketImage = this->getInputSocket(0); InputSocket *inputSocketFac = this->getInputSocket(1); OutputSocket *outputSocketImage = this->getOutputSocket(0); bNode *editorsnode = getbNode(); ColorSpillOperation *operation; if (editorsnode->custom2 == 0) { // Simple color spill operation = new ColorSpillOperation(); } else { // Average color spill operation = new ColorSpillAverageOperation(); } operation->setSettings((NodeColorspill *)editorsnode->storage); operation->setSpillChannel(editorsnode->custom1 - 1); // Channel for spilling inputSocketImage->relinkConnections(operation->getInputSocket(0), 0, graph); inputSocketFac->relinkConnections(operation->getInputSocket(1), 1, graph); outputSocketImage->relinkConnections(operation->getOutputSocket()); graph->addOperation(operation); }
void DistanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *inputSocketImage = this->getInputSocket(0); InputSocket *inputSocketKey = this->getInputSocket(1); OutputSocket *outputSocketImage = this->getOutputSocket(0); OutputSocket *outputSocketMatte = this->getOutputSocket(1); DistanceMatteOperation *operation = new DistanceMatteOperation(); bNode *editorsnode = getbNode(); operation->setSettings((NodeChroma *)editorsnode->storage); inputSocketImage->relinkConnections(operation->getInputSocket(0), 0, graph); inputSocketKey->relinkConnections(operation->getInputSocket(1), 1, graph); if (outputSocketMatte->isConnected()) { outputSocketMatte->relinkConnections(operation->getOutputSocket()); } graph->addOperation(operation); SetAlphaOperation *operationAlpha = new SetAlphaOperation(); addLink(graph, operation->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0)); addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1)); graph->addOperation(operationAlpha); addPreviewOperation(graph, operationAlpha->getOutputSocket()); if (outputSocketImage->isConnected()) { outputSocketImage->relinkConnections(operationAlpha->getOutputSocket()); } }
void GraphValidator::verify_output_socket_satisfied(const GraphNode &node, const InputSocket& input_socket, ValidationResults &results) const { auto possible_connection = input_socket.connection(); if(!possible_connection) { if(!(node.is_graph_internal_node() && input_socket.optional())) { std::string text = boost::str(boost::format("Output node %1% is missing an input connection.") % node.display_name()); results.add(text); return; } if(graph_.get_input_buffer(node.name())) return; std::string text = boost::str(boost::format("Output node %1% is missing an input connection, or is missing data being set directly on the Graph.") % node.display_name()); results.add(text); return; } const Connection& connection = possible_connection->get(); const OutputSocket& output = connection.output(); if(output.parent() == nullptr) throw std::logic_error("Output socket did not have a parent! Internal error!"); verify_node_satisfied(*output.parent(), results); }
void OutputSocket::removeFirstConnection() { SocketConnection *connection = this->m_connections[0]; InputSocket *inputSocket = connection->getToSocket(); if (inputSocket != NULL) { inputSocket->setConnection(NULL); } this->m_connections.erase(this->m_connections.begin()); }
void MapValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *colorSocket = this->getInputSocket(0); OutputSocket *valueSocket = this->getOutputSocket(0); TexMapping *storage = (TexMapping *)this->getbNode()->storage; MapValueOperation *convertProg = new MapValueOperation(); convertProg->setSettings(storage); colorSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph); valueSocket->relinkConnections(convertProg->getOutputSocket(0)); graph->addOperation(convertProg); }
void SeparateYUVANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { ConvertRGBToYUVOperation *operation = new ConvertRGBToYUVOperation(); InputSocket *inputSocket = this->getInputSocket(0); if (inputSocket->isConnected()) { inputSocket->relinkConnections(operation->getInputSocket(0)); addLink(graph, operation->getOutputSocket(), inputSocket); } graph->addOperation(operation); SeparateRGBANode::convertToOperations(graph, context); }
void MuteNode::reconnect(ExecutionSystem *graph, OutputSocket *output) { vector<InputSocket *> &inputsockets = this->getInputSockets(); for (unsigned int index = 0; index < inputsockets.size(); index++) { InputSocket *input = inputsockets[index]; if (input->getDataType() == output->getDataType()) { if (input->isConnected()) { output->relinkConnections(input->getConnection()->getFromSocket(), false); return; } } } NodeOperation *operation = NULL; switch (output->getDataType()) { case COM_DT_VALUE: { SetValueOperation *valueoperation = new SetValueOperation(); valueoperation->setValue(0.0f); operation = valueoperation; break; } case COM_DT_VECTOR: { SetVectorOperation *vectoroperation = new SetVectorOperation(); vectoroperation->setX(0.0f); vectoroperation->setY(0.0f); vectoroperation->setW(0.0f); operation = vectoroperation; break; } case COM_DT_COLOR: { SetColorOperation *coloroperation = new SetColorOperation(); coloroperation->setChannel1(0.0f); coloroperation->setChannel2(0.0f); coloroperation->setChannel3(0.0f); coloroperation->setChannel4(0.0f); operation = coloroperation; break; } } if (operation) { output->relinkConnections(operation->getOutputSocket(), false); graph->addOperation(operation); } output->clearConnections(); }
void FilterNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *inputSocket = this->getInputSocket(0); InputSocket *inputImageSocket = this->getInputSocket(1); OutputSocket *outputSocket = this->getOutputSocket(0); ConvolutionFilterOperation *operation = NULL; switch (this->getbNode()->custom1) { case CMP_FILT_SOFT: operation = new ConvolutionFilterOperation(); operation->set3x3Filter(1 / 16.0f, 2 / 16.0f, 1 / 16.0f, 2 / 16.0f, 4 / 16.0f, 2 / 16.0f, 1 / 16.0f, 2 / 16.0f, 1 / 16.0f); break; case CMP_FILT_SHARP: operation = new ConvolutionFilterOperation(); operation->set3x3Filter(-1, -1, -1, -1, 9, -1, -1, -1, -1); break; case CMP_FILT_LAPLACE: operation = new ConvolutionFilterOperation(); operation->set3x3Filter(-1 / 8.0f, -1 / 8.0f, -1 / 8.0f, -1 / 8.0f, 1.0f, -1 / 8.0f, -1 / 8.0f, -1 / 8.0f, -1 / 8.0f); break; case CMP_FILT_SOBEL: operation = new ConvolutionEdgeFilterOperation(); operation->set3x3Filter(1, 2, 1, 0, 0, 0, -1, -2, -1); break; case CMP_FILT_PREWITT: operation = new ConvolutionEdgeFilterOperation(); operation->set3x3Filter(1, 1, 1, 0, 0, 0, -1, -1, -1); break; case CMP_FILT_KIRSCH: operation = new ConvolutionEdgeFilterOperation(); operation->set3x3Filter(5, 5, 5, -3, -3, -3, -2, -2, -2); break; case CMP_FILT_SHADOW: operation = new ConvolutionFilterOperation(); operation->set3x3Filter(1, 2, 1, 0, 1, 0, -1, -2, -1); break; default: operation = new ConvolutionFilterOperation(); operation->set3x3Filter(0, 0, 0, 0, 1, 0, 0, 0, 0); break; } operation->setbNode(this->getbNode()); inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph); inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph); outputSocket->relinkConnections(operation->getOutputSocket()); addPreviewOperation(graph, operation->getOutputSocket(0)); graph->addOperation(operation); }
void MathBaseOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) { InputSocket *socket; unsigned int tempPreferredResolution[2] = {0, 0}; unsigned int tempResolution[2]; socket = this->getInputSocket(0); socket->determineResolution(tempResolution, tempPreferredResolution); if ((tempResolution[0] != 0) && (tempResolution[1] != 0)) { this->setResolutionInputSocketIndex(0); } else { this->setResolutionInputSocketIndex(1); } NodeOperation::determineResolution(resolution, preferredResolution); }
SocketConnection *ExecutionSystemHelper::addNodeLink(NodeRange &node_range, vector<SocketConnection *>& links, bNodeLink *b_nodelink) { /// @note: ignore invalid links if (!(b_nodelink->flag & NODE_LINK_VALID)) return NULL; InputSocket *inputSocket = find_input(node_range, b_nodelink->tonode, b_nodelink->tosock); OutputSocket *outputSocket = find_output(node_range, b_nodelink->fromnode, b_nodelink->fromsock); if (inputSocket == NULL || outputSocket == NULL) { return NULL; } if (inputSocket->isConnected()) { return NULL; } SocketConnection *connection = addLink(links, outputSocket, inputSocket); return connection; }
void EllipseMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { EllipseMaskOperation *operation; operation = new EllipseMaskOperation(); operation->setData((NodeEllipseMask *)this->getbNode()->storage); InputSocket *inputSocket = this->getInputSocket(0); OutputSocket *outputSocket = this->getOutputSocket(0); if (inputSocket->isConnected()) { inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph); outputSocket->relinkConnections(operation->getOutputSocket()); } else { /* Value operation to produce original transparent image */ SetValueOperation *valueOperation = new SetValueOperation(); valueOperation->setValue(0.0f); graph->addOperation(valueOperation); /* Scale that image up to render resolution */ const RenderData *rd = context->getRenderData(); ScaleFixedSizeOperation *scaleOperation = new ScaleFixedSizeOperation(); scaleOperation->setIsAspect(false); scaleOperation->setIsCrop(false); scaleOperation->setOffset(0.0f, 0.0f); scaleOperation->setNewWidth(rd->xsch * rd->size / 100.0f); scaleOperation->setNewHeight(rd->ysch * rd->size / 100.0f); addLink(graph, valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0)); addLink(graph, scaleOperation->getOutputSocket(0), operation->getInputSocket(0)); outputSocket->relinkConnections(operation->getOutputSocket(0)); scaleOperation->getInputSocket(0)->getConnection()->setIgnoreResizeCheck(true); graph->addOperation(scaleOperation); } this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); operation->setMaskType(this->getbNode()->custom1); graph->addOperation(operation); }
void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { bNode *b_node = this->getbNode(); InputSocket *inputSizeSocket = this->getInputSocket(2); bool connectedSizeSocket = inputSizeSocket->isConnected(); if ((b_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) && connectedSizeSocket) { VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, graph); operation->setQuality(context->getQuality()); operation->setbNode(this->getbNode()); graph->addOperation(operation); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); operation->setThreshold(0.0f); operation->setMaxBlur(b_node->custom4); operation->setDoScaleSize(true); } else { BokehBlurOperation *operation = new BokehBlurOperation(); const bNodeSocket *sock = this->getInputSocket(2)->getbNodeSocket(); const float size = ((const bNodeSocketValueFloat *)sock->default_value)->value; this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); this->getInputSocket(2)->relinkConnections(operation->getInputSocket(3), 2, graph); this->getInputSocket(3)->relinkConnections(operation->getInputSocket(2), 3, graph); //operation->setSize(((bNodeSocketValueFloat *)this->getInputSocket(2)->getbNodeSocket()->default_value)->value); operation->setQuality(context->getQuality()); operation->setbNode(this->getbNode()); graph->addOperation(operation); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); if (!connectedSizeSocket) { operation->setSize(size); } } }
void DespeckleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { bNode *editorNode = this->getbNode(); InputSocket *inputSocket = this->getInputSocket(0); InputSocket *inputImageSocket = this->getInputSocket(1); OutputSocket *outputSocket = this->getOutputSocket(0); DespeckleOperation *operation = new DespeckleOperation(); operation->setbNode(editorNode); operation->setThreshold(editorNode->custom3); operation->setThresholdNeighbor(editorNode->custom4); inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph); inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph); outputSocket->relinkConnections(operation->getOutputSocket()); addPreviewOperation(graph, context, operation->getOutputSocket(0)); graph->addOperation(operation); }
void ChromaMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *inputSocketImage = this->getInputSocket(0); InputSocket *inputSocketKey = this->getInputSocket(1); OutputSocket *outputSocketImage = this->getOutputSocket(0); OutputSocket *outputSocketMatte = this->getOutputSocket(1); ConvertRGBToYCCOperation *operationRGBToYCC_Image = new ConvertRGBToYCCOperation(); ConvertRGBToYCCOperation *operationRGBToYCC_Key = new ConvertRGBToYCCOperation(); operationRGBToYCC_Image->setMode(0); /* BLI_YCC_ITU_BT601 */ operationRGBToYCC_Key->setMode(0); /* BLI_YCC_ITU_BT601 */ ChromaMatteOperation *operation = new ChromaMatteOperation(); bNode *editorsnode = getbNode(); operation->setSettings((NodeChroma *)editorsnode->storage); inputSocketImage->relinkConnections(operationRGBToYCC_Image->getInputSocket(0), 0, graph); inputSocketKey->relinkConnections(operationRGBToYCC_Key->getInputSocket(0), 0, graph); addLink(graph, operationRGBToYCC_Image->getOutputSocket(), operation->getInputSocket(0)); addLink(graph, operationRGBToYCC_Key->getOutputSocket(), operation->getInputSocket(1)); graph->addOperation(operationRGBToYCC_Image); graph->addOperation(operationRGBToYCC_Key); graph->addOperation(operation); if (outputSocketMatte->isConnected()) { outputSocketMatte->relinkConnections(operation->getOutputSocket()); } SetAlphaOperation *operationAlpha = new SetAlphaOperation(); addLink(graph, operationRGBToYCC_Image->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0)); addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1)); graph->addOperation(operationAlpha); addPreviewOperation(graph, context, operationAlpha->getOutputSocket()); if (outputSocketImage->isConnected()) { outputSocketImage->relinkConnections(operationAlpha->getOutputSocket()); } }
void ColorBalanceNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *inputSocket = this->getInputSocket(0); InputSocket *inputImageSocket = this->getInputSocket(1); OutputSocket *outputSocket = this->getOutputSocket(0); bNode *node = this->getbNode(); NodeColorBalance *n = (NodeColorBalance *)node->storage; NodeOperation *operation; if (node->custom1 == 0) { ColorBalanceLGGOperation *operationLGG = new ColorBalanceLGGOperation(); { int c; for (c = 0; c < 3; c++) { n->lift_lgg[c] = 2.0f - n->lift[c]; n->gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f; } } operationLGG->setGain(n->gain); operationLGG->setLift(n->lift_lgg); operationLGG->setGammaInv(n->gamma_inv); operation = operationLGG; } else { ColorBalanceASCCDLOperation *operationCDL = new ColorBalanceASCCDLOperation(); operationCDL->setGain(n->gain); operationCDL->setLift(n->lift); operationCDL->setGamma(n->gamma); operation = operationCDL; } inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph); inputImageSocket->relinkConnections(operation->getInputSocket(1), 1, graph); outputSocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); }
void GraphValidator::verify_node_socket_satisfied(const GraphNode &node, const InputSocket& input_socket, ValidationResults &results) const { auto possible_connection = input_socket.connection(); if(!possible_connection) { if(input_socket.optional() == false) { std::string text = boost::str(boost::format("Node %1% is missing an input connection for %2%, which is not optional.") % node.display_name() % input_socket.name()); results.add(text); } } else { const Connection& connection = possible_connection->get(); const OutputSocket& output = connection.output(); if(output.parent() == nullptr) throw std::logic_error("Output socket did not have a parent! Internal error!"); verify_node_satisfied(*output.parent(), results); } }
void DistanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *inputSocketImage = this->getInputSocket(0); InputSocket *inputSocketKey = this->getInputSocket(1); OutputSocket *outputSocketImage = this->getOutputSocket(0); OutputSocket *outputSocketMatte = this->getOutputSocket(1); NodeOperation *operation; bNode *editorsnode = getbNode(); NodeChroma *storage = (NodeChroma *)editorsnode->storage; /* work in RGB color space */ if (storage->channel == 1) { operation = new DistanceRGBMatteOperation(); ((DistanceRGBMatteOperation *) operation)->setSettings(storage); inputSocketImage->relinkConnections(operation->getInputSocket(0), 0, graph); inputSocketKey->relinkConnections(operation->getInputSocket(1), 1, graph); } /* work in YCbCr color space */ else { operation = new DistanceYCCMatteOperation(); ((DistanceYCCMatteOperation *) operation)->setSettings(storage); ConvertRGBToYCCOperation *operationYCCImage = new ConvertRGBToYCCOperation(); inputSocketImage->relinkConnections(operationYCCImage->getInputSocket(0), 0, graph); addLink(graph, operationYCCImage->getOutputSocket(), operation->getInputSocket(0)); graph->addOperation(operationYCCImage); ConvertRGBToYCCOperation *operationYCCMatte = new ConvertRGBToYCCOperation(); inputSocketKey->relinkConnections(operationYCCMatte->getInputSocket(0), 1, graph); addLink(graph, operationYCCMatte->getOutputSocket(), operation->getInputSocket(1)); graph->addOperation(operationYCCMatte); } if (outputSocketMatte->isConnected()) { outputSocketMatte->relinkConnections(operation->getOutputSocket()); } graph->addOperation(operation); SetAlphaOperation *operationAlpha = new SetAlphaOperation(); addLink(graph, operation->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0)); addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1)); graph->addOperation(operationAlpha); addPreviewOperation(graph, context, operationAlpha->getOutputSocket()); if (outputSocketImage->isConnected()) { outputSocketImage->relinkConnections(operationAlpha->getOutputSocket()); } }
void SocketProxyNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { OutputSocket *outputsocket = this->getOutputSocket(0); InputSocket *inputsocket = this->getInputSocket(0); if (outputsocket->isConnected()) { if (inputsocket->isConnected()) { SocketProxyOperation *operation = new SocketProxyOperation(this->getOutputSocket()->getDataType()); inputsocket->relinkConnections(operation->getInputSocket(0)); outputsocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); } else { /* If input is not connected, add a constant value operation instead */ switch (outputsocket->getDataType()) { case COM_DT_VALUE: { SetValueOperation *operation = new SetValueOperation(); bNodeSocketValueFloat *dval = (bNodeSocketValueFloat *)inputsocket->getbNodeSocket()->default_value; operation->setValue(dval->value); outputsocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); break; } case COM_DT_COLOR: { SetColorOperation *operation = new SetColorOperation(); bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA *)inputsocket->getbNodeSocket()->default_value; operation->setChannels(dval->value); outputsocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); break; } case COM_DT_VECTOR: { SetVectorOperation *operation = new SetVectorOperation(); bNodeSocketValueVector *dval = (bNodeSocketValueVector *)inputsocket->getbNodeSocket()->default_value; operation->setVector(dval->value); outputsocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); break; } } } } }
void SeparateRGBANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *imageSocket = this->getInputSocket(0); OutputSocket *outputRSocket = this->getOutputSocket(0); OutputSocket *outputGSocket = this->getOutputSocket(1); OutputSocket *outputBSocket = this->getOutputSocket(2); OutputSocket *outputASocket = this->getOutputSocket(3); if (outputRSocket->isConnected()) { SeparateChannelOperation *operation = new SeparateChannelOperation(); operation->setChannel(0); imageSocket->relinkConnectionsDuplicate(operation->getInputSocket(0), 0, graph); outputRSocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); } if (outputGSocket->isConnected()) { SeparateChannelOperation *operation = new SeparateChannelOperation(); operation->setChannel(1); imageSocket->relinkConnectionsDuplicate(operation->getInputSocket(0), 0, graph); outputGSocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); } if (outputBSocket->isConnected()) { SeparateChannelOperation *operation = new SeparateChannelOperation(); operation->setChannel(2); imageSocket->relinkConnectionsDuplicate(operation->getInputSocket(0), 0, graph); outputBSocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); } if (outputASocket->isConnected()) { SeparateChannelOperation *operation = new SeparateChannelOperation(); operation->setChannel(3); imageSocket->relinkConnectionsDuplicate(operation->getInputSocket(0), 0, graph); outputASocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); } /* remove the original connection to the node, this has been duplicated for all operations */ imageSocket->unlinkConnections(graph); }
void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *inputImage = this->getInputSocket(0); InputSocket *inputScreen = this->getInputSocket(1); InputSocket *inputGarbageMatte = this->getInputSocket(2); InputSocket *inputCoreMatte = this->getInputSocket(3); OutputSocket *outputImage = this->getOutputSocket(0); OutputSocket *outputMatte = this->getOutputSocket(1); OutputSocket *outputEdges = this->getOutputSocket(2); OutputSocket *postprocessedMatte = NULL, *postprocessedImage = NULL, *originalImage = NULL, *edgesMatte = NULL; bNode *editorNode = this->getbNode(); NodeKeyingData *keying_data = (NodeKeyingData *) editorNode->storage; /* keying operation */ KeyingOperation *keyingOperation = new KeyingOperation(); keyingOperation->setScreenBalance(keying_data->screen_balance); inputScreen->relinkConnections(keyingOperation->getInputSocket(1), 1, graph); if (keying_data->blur_pre) { /* chroma preblur operation for input of keying operation */ OutputSocket *preBluredImage = setupPreBlur(graph, inputImage, keying_data->blur_pre, &originalImage); addLink(graph, preBluredImage, keyingOperation->getInputSocket(0)); } else { inputImage->relinkConnections(keyingOperation->getInputSocket(0), 0, graph); originalImage = keyingOperation->getInputSocket(0)->getConnection()->getFromSocket(); } graph->addOperation(keyingOperation); 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); /* matte dilate/erode */ if (keying_data->dilate_distance != 0) { postprocessedMatte = setupDilateErode(graph, postprocessedMatte, keying_data->dilate_distance); } /* matte feather */ if (keying_data->feather_distance != 0) { postprocessedMatte = setupFeather(graph, context, postprocessedMatte, keying_data->feather_falloff, keying_data->feather_distance); } /* set alpha channel to output image */ SetAlphaOperation *alphaOperation = new SetAlphaOperation(); addLink(graph, originalImage, alphaOperation->getInputSocket(0)); addLink(graph, postprocessedMatte, alphaOperation->getInputSocket(1)); postprocessedImage = alphaOperation->getOutputSocket(); /* despill output image */ if (keying_data->despill_factor > 0.0f) { postprocessedImage = setupDespill(graph, postprocessedImage, keyingOperation->getInputSocket(1)->getConnection()->getFromSocket(), keying_data->despill_factor, keying_data->despill_balance); } /* connect result to output sockets */ outputImage->relinkConnections(postprocessedImage); outputMatte->relinkConnections(postprocessedMatte); if (edgesMatte) outputEdges->relinkConnections(edgesMatte); graph->addOperation(alphaOperation); }
void MixNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *valueSocket = this->getInputSocket(0); InputSocket *color1Socket = this->getInputSocket(1); InputSocket *color2Socket = this->getInputSocket(2); OutputSocket *outputSocket = this->getOutputSocket(0); bNode *editorNode = this->getbNode(); bool useAlphaPremultiply = this->getbNode()->custom2 & 1; bool useClamp = this->getbNode()->custom2 & 2; MixBaseOperation *convertProg; switch (editorNode->custom1) { case MA_RAMP_ADD: convertProg = new MixAddOperation(); break; case MA_RAMP_MULT: convertProg = new MixMultiplyOperation(); break; case MA_RAMP_LIGHT: convertProg = new MixLightenOperation(); break; case MA_RAMP_BURN: convertProg = new MixBurnOperation(); break; case MA_RAMP_HUE: convertProg = new MixHueOperation(); break; case MA_RAMP_COLOR: convertProg = new MixColorOperation(); break; case MA_RAMP_SOFT: convertProg = new MixSoftLightOperation(); break; case MA_RAMP_SCREEN: convertProg = new MixScreenOperation(); break; case MA_RAMP_LINEAR: convertProg = new MixLinearLightOperation(); break; case MA_RAMP_DIFF: convertProg = new MixDifferenceOperation(); break; case MA_RAMP_SAT: convertProg = new MixSaturationOperation(); break; case MA_RAMP_DIV: convertProg = new MixDivideOperation(); break; case MA_RAMP_SUB: convertProg = new MixSubtractOperation(); break; case MA_RAMP_DARK: convertProg = new MixDarkenOperation(); break; case MA_RAMP_OVERLAY: convertProg = new MixOverlayOperation(); break; case MA_RAMP_VAL: convertProg = new MixValueOperation(); break; case MA_RAMP_DODGE: convertProg = new MixDodgeOperation(); break; case MA_RAMP_BLEND: default: convertProg = new MixBlendOperation(); break; } convertProg->setUseValueAlphaMultiply(useAlphaPremultiply); convertProg->setUseClamp(useClamp); if (color1Socket->isConnected()) { convertProg->setResolutionInputSocketIndex(1); } else { if (color2Socket->isConnected()) convertProg->setResolutionInputSocketIndex(2); else convertProg->setResolutionInputSocketIndex(0); } valueSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph); color1Socket->relinkConnections(convertProg->getInputSocket(1), 1, graph); color2Socket->relinkConnections(convertProg->getInputSocket(2), 2, graph); outputSocket->relinkConnections(convertProg->getOutputSocket(0)); addPreviewOperation(graph, context, convertProg->getOutputSocket(0)); convertProg->getInputSocket(2)->setResizeMode(color2Socket->getResizeMode()); graph->addOperation(convertProg); }