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(); }
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 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 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 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); }