Exemple #1
0
void ColorMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
    bNode *editorsnode = getbNode();

    NodeInput *inputSocketImage = this->getInputSocket(0);
    NodeInput *inputSocketKey = this->getInputSocket(1);
    NodeOutput *outputSocketImage = this->getOutputSocket(0);
    NodeOutput *outputSocketMatte = this->getOutputSocket(1);

    ConvertRGBToHSVOperation *operationRGBToHSV_Image = new ConvertRGBToHSVOperation();
    ConvertRGBToHSVOperation *operationRGBToHSV_Key = new ConvertRGBToHSVOperation();
    converter.addOperation(operationRGBToHSV_Image);
    converter.addOperation(operationRGBToHSV_Key);

    ColorMatteOperation *operation = new ColorMatteOperation();
    operation->setSettings((NodeDiamond *)editorsnode->storage);
    converter.addOperation(operation);

    SetAlphaOperation *operationAlpha = new SetAlphaOperation();
    converter.addOperation(operationAlpha);

    converter.mapInputSocket(inputSocketImage, operationRGBToHSV_Image->getInputSocket(0));
    converter.mapInputSocket(inputSocketKey, operationRGBToHSV_Key->getInputSocket(0));
    converter.addLink(operationRGBToHSV_Image->getOutputSocket(), operation->getInputSocket(0));
    converter.addLink(operationRGBToHSV_Key->getOutputSocket(), operation->getInputSocket(1));
    converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0));

    converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
    converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
    converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket());

    converter.addPreview(operationAlpha->getOutputSocket());
}
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 ColorSpillNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
	bNode *editorsnode = getbNode();
	
	NodeInput *inputSocketImage = this->getInputSocket(0);
	NodeInput *inputSocketFac = this->getInputSocket(1);
	NodeOutput *outputSocketImage = this->getOutputSocket(0);
	
	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
	converter.addOperation(operation);
	
	converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0));
	converter.mapInputSocket(inputSocketFac, operation->getInputSocket(1));
	converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket());
}
void HueSaturationValueCorrectNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
	NodeInput *valueSocket = this->getInputSocket(0);
	NodeInput *colorSocket = this->getInputSocket(1);
	NodeOutput *outputSocket = this->getOutputSocket(0);
	bNode *editorsnode = getbNode();
	CurveMapping *storage = (CurveMapping *)editorsnode->storage;
	
	ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation();
	converter.addOperation(rgbToHSV);
	
	ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation();
	converter.addOperation(hsvToRGB);
	
	HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation();
	changeHSV->setCurveMapping(storage);
	converter.addOperation(changeHSV);
	
	MixBlendOperation *blend = new MixBlendOperation();
	blend->setResolutionInputSocketIndex(1);
	converter.addOperation(blend);

	converter.mapInputSocket(colorSocket, rgbToHSV->getInputSocket(0));
	converter.addLink(rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0));
	converter.addLink(changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0));
	converter.addLink(hsvToRGB->getOutputSocket(), blend->getInputSocket(2));
	converter.mapInputSocket(colorSocket, blend->getInputSocket(1));
	converter.mapInputSocket(valueSocket, blend->getInputSocket(0));
	converter.mapOutputSocket(outputSocket, blend->getOutputSocket());
}
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 Stabilize2dNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
	NodeInput *imageInput = this->getInputSocket(0);
	MovieClip *clip = (MovieClip *)getbNode()->id;
	
	ScaleOperation *scaleOperation = new ScaleOperation();
	scaleOperation->setSampler((PixelSampler)this->getbNode()->custom1);
	RotateOperation *rotateOperation = new RotateOperation();
	rotateOperation->setDoDegree2RadConversion(false);
	TranslateOperation *translateOperation = new TranslateOperation();
	MovieClipAttributeOperation *scaleAttribute = new MovieClipAttributeOperation();
	MovieClipAttributeOperation *angleAttribute = new MovieClipAttributeOperation();
	MovieClipAttributeOperation *xAttribute = new MovieClipAttributeOperation();
	MovieClipAttributeOperation *yAttribute = new MovieClipAttributeOperation();
	SetSamplerOperation *psoperation = new SetSamplerOperation();
	psoperation->setSampler((PixelSampler)this->getbNode()->custom1);
	
	scaleAttribute->setAttribute(MCA_SCALE);
	scaleAttribute->setFramenumber(context.getFramenumber());
	scaleAttribute->setMovieClip(clip);
	
	angleAttribute->setAttribute(MCA_ANGLE);
	angleAttribute->setFramenumber(context.getFramenumber());
	angleAttribute->setMovieClip(clip);
	
	xAttribute->setAttribute(MCA_X);
	xAttribute->setFramenumber(context.getFramenumber());
	xAttribute->setMovieClip(clip);
	
	yAttribute->setAttribute(MCA_Y);
	yAttribute->setFramenumber(context.getFramenumber());
	yAttribute->setMovieClip(clip);
	
	converter.addOperation(scaleAttribute);
	converter.addOperation(angleAttribute);
	converter.addOperation(xAttribute);
	converter.addOperation(yAttribute);
	converter.addOperation(scaleOperation);
	converter.addOperation(translateOperation);
	converter.addOperation(rotateOperation);
	converter.addOperation(psoperation);
	
	converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0));
	converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
	converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
	
	converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
	converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));

	converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
	converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1));
	converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2));
	
	converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0));
	converter.mapOutputSocket(getOutputSocket(), psoperation->getOutputSocket());
}
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 ColorSpillNode::convertToOperations(NodeConverter &converter,
                                         const CompositorContext & /*context*/) const
{
  bNode *editorsnode = getbNode();

  NodeInput *inputSocketImage = this->getInputSocket(0);
  NodeInput *inputSocketFac = this->getInputSocket(1);
  NodeOutput *outputSocketImage = this->getOutputSocket(0);

  ColorSpillOperation *operation;
  operation = new ColorSpillOperation();
  operation->setSettings((NodeColorspill *)editorsnode->storage);
  operation->setSpillChannel(editorsnode->custom1 - 1);  // Channel for spilling
  operation->setSpillMethod(editorsnode->custom2);       // Channel method
  converter.addOperation(operation);

  converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0));
  converter.mapInputSocket(inputSocketFac, operation->getInputSocket(1));
  converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket());
}
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 LuminanceMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
	bNode *editorsnode = getbNode();
	NodeInput *inputSocket = this->getInputSocket(0);
	NodeOutput *outputSocketImage = this->getOutputSocket(0);
	NodeOutput *outputSocketMatte = this->getOutputSocket(1);

	LuminanceMatteOperation *operationSet = new LuminanceMatteOperation();
	operationSet->setSettings((NodeChroma *)editorsnode->storage);
	converter.addOperation(operationSet);

	converter.mapInputSocket(inputSocket, operationSet->getInputSocket(0));
	converter.mapOutputSocket(outputSocketMatte, operationSet->getOutputSocket(0));

	SetAlphaOperation *operation = new SetAlphaOperation();
	converter.addOperation(operation);

	converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
	converter.addLink(operationSet->getOutputSocket(), operation->getInputSocket(1));
	converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket());

	converter.addPreview(operation->getOutputSocket());
}
void MathNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
	MathBaseOperation *operation = NULL;
	
	switch (this->getbNode()->custom1) {
		case 0: /* Add */
			operation = new MathAddOperation();
			break;
		case 1: /* Subtract */
			operation = new MathSubtractOperation();
			break;
		case 2: /* Multiply */
			operation = new MathMultiplyOperation();
			break;
		case 3: /* Divide */
			operation = new MathDivideOperation();
			break;
		case 4: /* Sine */
			operation = new MathSineOperation();
			break;
		case 5: /* Cosine */
			operation = new MathCosineOperation();
			break;
		case 6: /* Tangent */
			operation = new MathTangentOperation();
			break;
		case 7: /* Arc-Sine */
			operation = new MathArcSineOperation();
			break;
		case 8: /* Arc-Cosine */
			operation = new MathArcCosineOperation();
			break;
		case 9: /* Arc-Tangent */
			operation = new MathArcTangentOperation();
			break;
		case 10: /* Power */
			operation = new MathPowerOperation();
			break;
		case 11: /* Logarithm */
			operation = new MathLogarithmOperation();
			break;
		case 12: /* Minimum */
			operation = new MathMinimumOperation();
			break;
		case 13: /* Maximum */
			operation = new MathMaximumOperation();
			break;
		case 14: /* Round */
			operation = new MathRoundOperation();
			break;
		case 15: /* Less Than */
			operation = new MathLessThanOperation();
			break;
		case 16: /* Greater Than */
			operation = new MathGreaterThanOperation();
			break;
		case 17: /* Modulo */
			operation = new MathModuloOperation();
			break;
		case 18: /* Absolute Value */
			operation = new MathAbsoluteOperation();
			break;
	}
	
	if (operation) {
		bool useClamp = getbNode()->custom2;
		operation->setUseClamp(useClamp);
		converter.addOperation(operation);
		
		converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
		converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
		converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
	}
}
void DistanceMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
	bNode *editorsnode = getbNode();
	NodeChroma *storage = (NodeChroma *)editorsnode->storage;
	
	NodeInput *inputSocketImage = this->getInputSocket(0);
	NodeInput *inputSocketKey = this->getInputSocket(1);
	NodeOutput *outputSocketImage = this->getOutputSocket(0);
	NodeOutput *outputSocketMatte = this->getOutputSocket(1);
	
	SetAlphaOperation *operationAlpha = new SetAlphaOperation();
	converter.addOperation(operationAlpha);
	
	/* work in RGB color space */
	NodeOperation *operation;
	if (storage->channel == 1) {
		DistanceRGBMatteOperation *matte = new DistanceRGBMatteOperation();
		matte->setSettings(storage);
		converter.addOperation(matte);
		
		converter.mapInputSocket(inputSocketImage, matte->getInputSocket(0));
		converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
		
		converter.mapInputSocket(inputSocketKey, matte->getInputSocket(1));
		
		operation = matte;
	}
	/* work in YCbCr color space */
	else {
		DistanceYCCMatteOperation *matte = new DistanceYCCMatteOperation();
		matte->setSettings(storage);
		converter.addOperation(matte);
		
		ConvertRGBToYCCOperation *operationYCCImage = new ConvertRGBToYCCOperation();
		ConvertRGBToYCCOperation *operationYCCMatte = new ConvertRGBToYCCOperation();
		operationYCCImage->setMode(0);  /* BLI_YCC_ITU_BT601 */
		operationYCCMatte->setMode(0);  /* BLI_YCC_ITU_BT601 */
		converter.addOperation(operationYCCImage);
		converter.addOperation(operationYCCMatte);
		
		converter.mapInputSocket(inputSocketImage, operationYCCImage->getInputSocket(0));
		converter.addLink(operationYCCImage->getOutputSocket(), matte->getInputSocket(0));
		converter.addLink(operationYCCImage->getOutputSocket(), operationAlpha->getInputSocket(0));
		
		converter.mapInputSocket(inputSocketKey, operationYCCMatte->getInputSocket(0));
		converter.addLink(operationYCCMatte->getOutputSocket(), matte->getInputSocket(1));
		
		operation = matte;
	}
	
	converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0));
	converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
	
	if (storage->channel != 1) {
		ConvertYCCToRGBOperation *inv_convert = new ConvertYCCToRGBOperation();
		inv_convert->setMode(0); /* BLI_YCC_ITU_BT601 */

		converter.addOperation(inv_convert);
		converter.addLink(operationAlpha->getOutputSocket(0), inv_convert->getInputSocket(0));
		converter.mapOutputSocket(outputSocketImage, inv_convert->getOutputSocket());
	}
	else {
		converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket());
	}
	
	converter.addPreview(operationAlpha->getOutputSocket());
}