Пример #1
0
OutputSocket *KeyingNode::setupFeather(ExecutionSystem *graph, CompositorContext *context,
                                       OutputSocket *featherInput, int falloff, int distance)
{
	/* this uses a modified gaussian blur function otherwise its far too slow */
	CompositorQuality quality = context->getQuality();

	/* initialize node data */
	NodeBlurData *data = &this->m_alpha_blur;
	memset(data, 0, sizeof(*data));
	data->filtertype = R_FILTER_GAUSS;

	if (distance > 0) {
		data->sizex = data->sizey = distance;
	}
	else {
		data->sizex = data->sizey = -distance;
	}

	GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation();
	operationx->setData(data);
	operationx->setQuality(quality);
	operationx->setSize(1.0f);
	operationx->setSubtract(distance < 0);
	operationx->setFalloff(falloff);
	operationx->setbNode(this->getbNode());
	graph->addOperation(operationx);
	
	GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
	operationy->setData(data);
	operationy->setQuality(quality);
	operationy->setSize(1.0f);
	operationy->setSubtract(distance < 0);
	operationy->setFalloff(falloff);
	operationy->setbNode(this->getbNode());
	graph->addOperation(operationy);

	addLink(graph, featherInput, operationx->getInputSocket(0));
	addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0));

	return operationy->getOutputSocket();
}
Пример #2
0
void BlurNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
	bNode *editorNode = this->getbNode();
	NodeBlurData *data = (NodeBlurData *)editorNode->storage;
	NodeInput *inputSizeSocket = this->getInputSocket(1);
	bool connectedSizeSocket = inputSizeSocket->isLinked();

	const float size = this->getInputSocket(1)->getEditorValueFloat();
	
	CompositorQuality quality = context.getQuality();
	NodeOperation *input_operation = NULL, *output_operation = NULL;

	if (data->filtertype == R_FILTER_FAST_GAUSS) {
		FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation();
		operationfgb->setData(data);
		converter.addOperation(operationfgb);
		
		converter.mapInputSocket(getInputSocket(1), operationfgb->getInputSocket(1));
		
		input_operation = operationfgb;
		output_operation = operationfgb;
	}
	else if (editorNode->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) {
		MathAddOperation *clamp = new MathAddOperation();
		SetValueOperation *zero = new SetValueOperation();
		zero->setValue(0.0f);
		clamp->setUseClamp(true);
		
		converter.addOperation(clamp);
		converter.addOperation(zero);
		converter.mapInputSocket(getInputSocket(1), clamp->getInputSocket(0));
		converter.addLink(zero->getOutputSocket(), clamp->getInputSocket(1));
		
		GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation();
		operationx->setData(data);
		operationx->setQuality(quality);
		operationx->setSize(1.0f);
		operationx->setFalloff(PROP_SMOOTH);
		operationx->setSubtract(false);
		
		converter.addOperation(operationx);
		converter.addLink(clamp->getOutputSocket(), operationx->getInputSocket(0));
		
		GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
		operationy->setData(data);
		operationy->setQuality(quality);
		operationy->setSize(1.0f);
		operationy->setFalloff(PROP_SMOOTH);
		operationy->setSubtract(false);
		
		converter.addOperation(operationy);
		converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));
		
		GaussianBlurReferenceOperation *operation = new GaussianBlurReferenceOperation();
		operation->setData(data);
		operation->setQuality(quality);
		
		converter.addOperation(operation);
		converter.addLink(operationy->getOutputSocket(), operation->getInputSocket(1));
		
		output_operation = operation;
		input_operation = operation;
	}
	else if (!data->bokeh) {
		GaussianXBlurOperation *operationx = new GaussianXBlurOperation();
		operationx->setData(data);
		operationx->setQuality(quality);
		
		converter.addOperation(operationx);
		converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1));
		
		GaussianYBlurOperation *operationy = new GaussianYBlurOperation();
		operationy->setData(data);
		operationy->setQuality(quality);

		converter.addOperation(operationy);
		converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1));
		converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));

		if (!connectedSizeSocket) {
			operationx->setSize(size);
			operationy->setSize(size);
		}

		input_operation = operationx;
		output_operation = operationy;
	}
	else {
		GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation();
		operation->setData(data);
		operation->setQuality(quality);
		
		converter.addOperation(operation);
		converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));

		if (!connectedSizeSocket) {
			operation->setSize(size);
		}

		input_operation = operation;
		output_operation = operation;
	}

	if (data->gamma) {
		GammaCorrectOperation *correct = new GammaCorrectOperation();
		GammaUncorrectOperation *inverse = new GammaUncorrectOperation();
		converter.addOperation(correct);
		converter.addOperation(inverse);
		
		converter.mapInputSocket(getInputSocket(0), correct->getInputSocket(0));
		converter.addLink(correct->getOutputSocket(), input_operation->getInputSocket(0));
		converter.addLink(output_operation->getOutputSocket(), inverse->getInputSocket(0));
		converter.mapOutputSocket(getOutputSocket(), inverse->getOutputSocket());
		
		converter.addPreview(inverse->getOutputSocket());
	}
	else {
		converter.mapInputSocket(getInputSocket(0), input_operation->getInputSocket(0));
		converter.mapOutputSocket(getOutputSocket(), output_operation->getOutputSocket());
		
		converter.addPreview(output_operation->getOutputSocket());
	}
}
Пример #3
0
void DilateErodeNode::convertToOperations(NodeConverter &converter,
                                          const CompositorContext &context) const
{

  bNode *editorNode = this->getbNode();
  if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_THRESH) {
    DilateErodeThresholdOperation *operation = new DilateErodeThresholdOperation();
    operation->setDistance(editorNode->custom2);
    operation->setInset(editorNode->custom3);
    converter.addOperation(operation);

    converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));

    if (editorNode->custom3 < 2.0f) {
      AntiAliasOperation *antiAlias = new AntiAliasOperation();
      converter.addOperation(antiAlias);

      converter.addLink(operation->getOutputSocket(), antiAlias->getInputSocket(0));
      converter.mapOutputSocket(getOutputSocket(0), antiAlias->getOutputSocket(0));
    }
    else {
      converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
    }
  }
  else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE) {
    if (editorNode->custom2 > 0) {
      DilateDistanceOperation *operation = new DilateDistanceOperation();
      operation->setDistance(editorNode->custom2);
      converter.addOperation(operation);

      converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
      converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
    }
    else {
      ErodeDistanceOperation *operation = new ErodeDistanceOperation();
      operation->setDistance(-editorNode->custom2);
      converter.addOperation(operation);

      converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
      converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
    }
  }
  else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_FEATHER) {
    /* this uses a modified gaussian blur function otherwise its far too slow */
    CompositorQuality quality = context.getQuality();

    GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation();
    operationx->setData(&m_alpha_blur);
    operationx->setQuality(quality);
    operationx->setFalloff(PROP_SMOOTH);
    converter.addOperation(operationx);

    converter.mapInputSocket(getInputSocket(0), operationx->getInputSocket(0));
    // converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1)); // no size input
    // yet

    GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
    operationy->setData(&m_alpha_blur);
    operationy->setQuality(quality);
    operationy->setFalloff(PROP_SMOOTH);
    converter.addOperation(operationy);

    converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));
    // converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1)); // no size input
    // yet
    converter.mapOutputSocket(getOutputSocket(0), operationy->getOutputSocket());

    converter.addPreview(operationy->getOutputSocket());

    /* TODO? */
    /* see gaussian blue node for original usage */
#if 0
    if (!connectedSizeSocket) {
      operationx->setSize(size);
      operationy->setSize(size);
    }
#else
    operationx->setSize(1.0f);
    operationy->setSize(1.0f);
#endif
    operationx->setSubtract(editorNode->custom2 < 0);
    operationy->setSubtract(editorNode->custom2 < 0);

    if (editorNode->storage) {
      NodeDilateErode *data_storage = (NodeDilateErode *)editorNode->storage;
      operationx->setFalloff(data_storage->falloff);
      operationy->setFalloff(data_storage->falloff);
    }
  }
  else {
    if (editorNode->custom2 > 0) {
      DilateStepOperation *operation = new DilateStepOperation();
      operation->setIterations(editorNode->custom2);
      converter.addOperation(operation);

      converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
      converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
    }
    else {
      ErodeStepOperation *operation = new ErodeStepOperation();
      operation->setIterations(-editorNode->custom2);
      converter.addOperation(operation);

      converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
      converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
    }
  }
}