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 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 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 ChannelMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { bNode *node = this->getbNode(); NodeInput *inputSocketImage = this->getInputSocket(0); NodeOutput *outputSocketImage = this->getOutputSocket(0); NodeOutput *outputSocketMatte = this->getOutputSocket(1); NodeOperation *convert = NULL; /* colorspace */ switch (node->custom1) { case CMP_NODE_CHANNEL_MATTE_CS_RGB: break; case CMP_NODE_CHANNEL_MATTE_CS_HSV: /* HSV */ convert = new ConvertRGBToHSVOperation(); break; case CMP_NODE_CHANNEL_MATTE_CS_YUV: /* YUV */ convert = new ConvertRGBToYUVOperation(); break; case CMP_NODE_CHANNEL_MATTE_CS_YCC: /* YCC */ convert = new ConvertRGBToYCCOperation(); ((ConvertRGBToYCCOperation *)convert)->setMode(0); /* BLI_YCC_ITU_BT601 */ break; default: break; } ChannelMatteOperation *operation = new ChannelMatteOperation(); /* pass the ui properties to the operation */ operation->setSettings((NodeChroma *)node->storage, node->custom2); converter.addOperation(operation); SetAlphaOperation *operationAlpha = new SetAlphaOperation(); converter.addOperation(operationAlpha); if (convert) { converter.addOperation(convert); converter.mapInputSocket(inputSocketImage, convert->getInputSocket(0)); converter.addLink(convert->getOutputSocket(), operation->getInputSocket(0)); converter.addLink(convert->getOutputSocket(), operationAlpha->getInputSocket(0)); } else { converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0)); converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); } converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0)); converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1)); converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket()); converter.addPreview(operationAlpha->getOutputSocket()); }
void GlareNode::convertToOperations(NodeConverter &converter, const CompositorContext & /*context*/) const { bNode *node = this->getbNode(); NodeGlare *glare = (NodeGlare *)node->storage; GlareBaseOperation *glareoperation = NULL; switch (glare->type) { default: case 3: glareoperation = new GlareGhostOperation(); break; case 2: // streaks glareoperation = new GlareStreaksOperation(); break; case 1: // fog glow glareoperation = new GlareFogGlowOperation(); break; case 0: // simple star glareoperation = new GlareSimpleStarOperation(); break; } BLI_assert(glareoperation); glareoperation->setGlareSettings(glare); GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation(); thresholdOperation->setGlareSettings(glare); SetValueOperation *mixvalueoperation = new SetValueOperation(); mixvalueoperation->setValue(0.5f + glare->mix * 0.5f); MixGlareOperation *mixoperation = new MixGlareOperation(); mixoperation->setResolutionInputSocketIndex(1); mixoperation->getInputSocket(2)->setResizeMode(COM_SC_FIT); converter.addOperation(glareoperation); converter.addOperation(thresholdOperation); converter.addOperation(mixvalueoperation); converter.addOperation(mixoperation); converter.mapInputSocket(getInputSocket(0), thresholdOperation->getInputSocket(0)); converter.addLink(thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0)); converter.addLink(mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0)); converter.mapInputSocket(getInputSocket(0), mixoperation->getInputSocket(1)); converter.addLink(glareoperation->getOutputSocket(), mixoperation->getInputSocket(2)); converter.mapOutputSocket(getOutputSocket(), mixoperation->getOutputSocket()); }
void DifferenceMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { NodeInput *inputSocket = this->getInputSocket(0); NodeInput *inputSocket2 = this->getInputSocket(1); NodeOutput *outputSocketImage = this->getOutputSocket(0); NodeOutput *outputSocketMatte = this->getOutputSocket(1); bNode *editorNode = this->getbNode(); DifferenceMatteOperation *operationSet = new DifferenceMatteOperation(); operationSet->setSettings((NodeChroma *)editorNode->storage); converter.addOperation(operationSet); converter.mapInputSocket(inputSocket, operationSet->getInputSocket(0)); converter.mapInputSocket(inputSocket2, operationSet->getInputSocket(1)); 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 BoxMaskNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { NodeInput *inputSocket = this->getInputSocket(0); NodeOutput *outputSocket = this->getOutputSocket(0); BoxMaskOperation *operation; operation = new BoxMaskOperation(); operation->setData((NodeBoxMask *)this->getbNode()->storage); operation->setMaskType(this->getbNode()->custom1); converter.addOperation(operation); if (inputSocket->isLinked()) { converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); } else { /* Value operation to produce original transparent image */ SetValueOperation *valueOperation = new SetValueOperation(); valueOperation->setValue(0.0f); converter.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); scaleOperation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE); converter.addOperation(scaleOperation); converter.addLink(valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0)); converter.addLink(scaleOperation->getOutputSocket(0), operation->getInputSocket(0)); converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); } converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); }
void TransformNode::convertToOperations(NodeConverter &converter, const CompositorContext & /*context*/) const { NodeInput *imageInput = this->getInputSocket(0); NodeInput *xInput = this->getInputSocket(1); NodeInput *yInput = this->getInputSocket(2); NodeInput *angleInput = this->getInputSocket(3); NodeInput *scaleInput = this->getInputSocket(4); ScaleOperation *scaleOperation = new ScaleOperation(); converter.addOperation(scaleOperation); RotateOperation *rotateOperation = new RotateOperation(); rotateOperation->setDoDegree2RadConversion(false); converter.addOperation(rotateOperation); TranslateOperation *translateOperation = new TranslateOperation(); converter.addOperation(translateOperation); SetSamplerOperation *sampler = new SetSamplerOperation(); sampler->setSampler((PixelSampler)this->getbNode()->custom1); converter.addOperation(sampler); converter.mapInputSocket(imageInput, sampler->getInputSocket(0)); converter.addLink(sampler->getOutputSocket(), scaleOperation->getInputSocket(0)); converter.mapInputSocket(scaleInput, scaleOperation->getInputSocket(1)); converter.mapInputSocket(scaleInput, scaleOperation->getInputSocket(2)); // xscale = yscale converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0)); converter.mapInputSocket(angleInput, rotateOperation->getInputSocket(1)); converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0)); converter.mapInputSocket(xInput, translateOperation->getInputSocket(1)); converter.mapInputSocket(yInput, translateOperation->getInputSocket(2)); converter.mapOutputSocket(getOutputSocket(), translateOperation->getOutputSocket()); }
void TranslateNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { bNode *bnode = this->getbNode(); NodeTranslateData *data = (NodeTranslateData *)bnode->storage; NodeInput *inputSocket = this->getInputSocket(0); NodeInput *inputXSocket = this->getInputSocket(1); NodeInput *inputYSocket = this->getInputSocket(2); NodeOutput *outputSocket = this->getOutputSocket(0); TranslateOperation *operation = new TranslateOperation(); if (data->relative) { const RenderData *rd = context.getRenderData(); float fx = rd->xsch * rd->size / 100.0f; float fy = rd->ysch * rd->size / 100.0f; operation->setFactorXY(fx, fy); } converter.addOperation(operation); converter.mapInputSocket(inputXSocket, operation->getInputSocket(1)); converter.mapInputSocket(inputYSocket, operation->getInputSocket(2)); converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); if (data->wrap_axis) { WriteBufferOperation *writeOperation = new WriteBufferOperation(COM_DT_COLOR); WrapOperation *wrapOperation = new WrapOperation(COM_DT_COLOR); wrapOperation->setMemoryProxy(writeOperation->getMemoryProxy()); wrapOperation->setWrapping(data->wrap_axis); converter.addOperation(writeOperation); converter.addOperation(wrapOperation); converter.mapInputSocket(inputSocket, writeOperation->getInputSocket(0)); converter.addLink(wrapOperation->getOutputSocket(), operation->getInputSocket(0)); } else { converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); } }
void SplitViewerNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { bNode *editorNode = this->getbNode(); bool do_output = (editorNode->flag & NODE_DO_OUTPUT_RECALC || context.isRendering()) && (editorNode->flag & NODE_DO_OUTPUT); NodeInput *image1Socket = this->getInputSocket(0); NodeInput *image2Socket = this->getInputSocket(1); Image *image = (Image *)this->getbNode()->id; ImageUser *imageUser = (ImageUser *) this->getbNode()->storage; SplitOperation *splitViewerOperation = new SplitOperation(); splitViewerOperation->setSplitPercentage(this->getbNode()->custom1); splitViewerOperation->setXSplit(!this->getbNode()->custom2); converter.addOperation(splitViewerOperation); converter.mapInputSocket(image1Socket, splitViewerOperation->getInputSocket(0)); converter.mapInputSocket(image2Socket, splitViewerOperation->getInputSocket(1)); ViewerOperation *viewerOperation = new ViewerOperation(); viewerOperation->setImage(image); viewerOperation->setImageUser(imageUser); viewerOperation->setViewSettings(context.getViewSettings()); viewerOperation->setDisplaySettings(context.getDisplaySettings()); /* defaults - the viewer node has these options but not exposed for split view * we could use the split to define an area of interest on one axis at least */ viewerOperation->setChunkOrder(COM_ORDER_OF_CHUNKS_DEFAULT); viewerOperation->setCenterX(0.5f); viewerOperation->setCenterY(0.5f); converter.addOperation(viewerOperation); converter.addLink(splitViewerOperation->getOutputSocket(), viewerOperation->getInputSocket(0)); converter.addPreview(splitViewerOperation->getOutputSocket()); if (do_output) converter.registerViewer(viewerOperation); }
void ZCombineNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { if ((context.getRenderData()->scemode & R_FULL_SAMPLE) || this->getbNode()->custom2) { ZCombineOperation *operation = NULL; if (this->getbNode()->custom1) { operation = new ZCombineAlphaOperation(); } else { operation = new ZCombineOperation(); } converter.addOperation(operation); converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3)); converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); MathMinimumOperation *zoperation = new MathMinimumOperation(); converter.addOperation(zoperation); converter.mapInputSocket(getInputSocket(1), zoperation->getInputSocket(0)); converter.mapInputSocket(getInputSocket(3), zoperation->getInputSocket(1)); converter.mapOutputSocket(getOutputSocket(1), zoperation->getOutputSocket()); } else { /* XXX custom1 is "use_alpha", what on earth is this supposed to do here?!? */ // not full anti alias, use masking for Z combine. be aware it uses anti aliasing. // step 1 create mask NodeOperation *maskoperation; if (this->getbNode()->custom1) { maskoperation = new MathGreaterThanOperation(); converter.addOperation(maskoperation); converter.mapInputSocket(getInputSocket(1), maskoperation->getInputSocket(0)); converter.mapInputSocket(getInputSocket(3), maskoperation->getInputSocket(1)); } else { maskoperation = new MathLessThanOperation(); converter.addOperation(maskoperation); converter.mapInputSocket(getInputSocket(1), maskoperation->getInputSocket(0)); converter.mapInputSocket(getInputSocket(3), maskoperation->getInputSocket(1)); } // step 2 anti alias mask bit of an expensive operation, but does the trick AntiAliasOperation *antialiasoperation = new AntiAliasOperation(); converter.addOperation(antialiasoperation); converter.addLink(maskoperation->getOutputSocket(), antialiasoperation->getInputSocket(0)); // use mask to blend between the input colors. ZCombineMaskOperation *zcombineoperation = this->getbNode()->custom1 ? new ZCombineMaskAlphaOperation() : new ZCombineMaskOperation(); converter.addOperation(zcombineoperation); converter.addLink(antialiasoperation->getOutputSocket(), zcombineoperation->getInputSocket(0)); converter.mapInputSocket(getInputSocket(0), zcombineoperation->getInputSocket(1)); converter.mapInputSocket(getInputSocket(2), zcombineoperation->getInputSocket(2)); converter.mapOutputSocket(getOutputSocket(0), zcombineoperation->getOutputSocket()); MathMinimumOperation *zoperation = new MathMinimumOperation(); converter.addOperation(zoperation); converter.mapInputSocket(getInputSocket(1), zoperation->getInputSocket(0)); converter.mapInputSocket(getInputSocket(3), zoperation->getInputSocket(1)); converter.mapOutputSocket(getOutputSocket(1), zoperation->getOutputSocket()); } }
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()); } }
void SeparateColorNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { NodeInput *imageSocket = this->getInputSocket(0); NodeOutput *outputRSocket = this->getOutputSocket(0); NodeOutput *outputGSocket = this->getOutputSocket(1); NodeOutput *outputBSocket = this->getOutputSocket(2); NodeOutput *outputASocket = this->getOutputSocket(3); NodeOperation *color_conv = getColorConverter(context); if (color_conv) { converter.addOperation(color_conv); converter.mapInputSocket(imageSocket, color_conv->getInputSocket(0)); } { SeparateChannelOperation *operation = new SeparateChannelOperation(); operation->setChannel(0); converter.addOperation(operation); if (color_conv) converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0)); else converter.mapInputSocket(imageSocket, operation->getInputSocket(0)); converter.mapOutputSocket(outputRSocket, operation->getOutputSocket(0)); } { SeparateChannelOperation *operation = new SeparateChannelOperation(); operation->setChannel(1); converter.addOperation(operation); if (color_conv) converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0)); else converter.mapInputSocket(imageSocket, operation->getInputSocket(0)); converter.mapOutputSocket(outputGSocket, operation->getOutputSocket(0)); } { SeparateChannelOperation *operation = new SeparateChannelOperation(); operation->setChannel(2); converter.addOperation(operation); if (color_conv) converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0)); else converter.mapInputSocket(imageSocket, operation->getInputSocket(0)); converter.mapOutputSocket(outputBSocket, operation->getOutputSocket(0)); } { SeparateChannelOperation *operation = new SeparateChannelOperation(); operation->setChannel(3); converter.addOperation(operation); if (color_conv) converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0)); else converter.mapInputSocket(imageSocket, operation->getInputSocket(0)); converter.mapOutputSocket(outputASocket, operation->getOutputSocket(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)); } } }
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()); }
void TrackPositionNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { bNode *editorNode = this->getbNode(); MovieClip *clip = (MovieClip *) editorNode->id; NodeTrackPosData *trackpos_data = (NodeTrackPosData *) editorNode->storage; NodeOutput *outputX = this->getOutputSocket(0); NodeOutput *outputY = this->getOutputSocket(1); NodeOutput *outputSpeed = this->getOutputSocket(2); int frame_number; if (editorNode->custom1 == CMP_TRACKPOS_ABSOLUTE_FRAME) { frame_number = editorNode->custom2; } else { frame_number = context.getFramenumber(); } TrackPositionOperation *operationX = new TrackPositionOperation(); operationX->setMovieClip(clip); operationX->setTrackingObject(trackpos_data->tracking_object); operationX->setTrackName(trackpos_data->track_name); operationX->setFramenumber(frame_number); operationX->setAxis(0); operationX->setPosition(editorNode->custom1); operationX->setRelativeFrame(editorNode->custom2); converter.addOperation(operationX); converter.mapOutputSocket(outputX, operationX->getOutputSocket()); TrackPositionOperation *operationY = new TrackPositionOperation(); operationY->setMovieClip(clip); operationY->setTrackingObject(trackpos_data->tracking_object); operationY->setTrackName(trackpos_data->track_name); operationY->setFramenumber(frame_number); operationY->setAxis(1); operationY->setPosition(editorNode->custom1); operationY->setRelativeFrame(editorNode->custom2); converter.addOperation(operationY); converter.mapOutputSocket(outputY, operationY->getOutputSocket()); TrackPositionOperation *operationMotionPreX = create_motion_operation(converter, clip, trackpos_data, 0, frame_number, -1); TrackPositionOperation *operationMotionPreY = create_motion_operation(converter, clip, trackpos_data, 1, frame_number, -1); TrackPositionOperation *operationMotionPostX = create_motion_operation(converter, clip, trackpos_data, 0, frame_number, 1); TrackPositionOperation *operationMotionPostY = create_motion_operation(converter, clip, trackpos_data, 1, frame_number, 1); CombineChannelsOperation *combine_operation = new CombineChannelsOperation(); converter.addOperation(combine_operation); converter.addLink(operationMotionPreX->getOutputSocket(), combine_operation->getInputSocket(0)); converter.addLink(operationMotionPreY->getOutputSocket(), combine_operation->getInputSocket(1)); converter.addLink(operationMotionPostX->getOutputSocket(), combine_operation->getInputSocket(2)); converter.addLink(operationMotionPostY->getOutputSocket(), combine_operation->getInputSocket(3)); converter.mapOutputSocket(outputSpeed, combine_operation->getOutputSocket()); }
void ImageNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { /// Image output NodeOutput *outputImage = this->getOutputSocket(0); bNode *editorNode = this->getbNode(); Image *image = (Image *)editorNode->id; ImageUser *imageuser = (ImageUser *)editorNode->storage; int framenumber = context.getFramenumber(); int numberOfOutputs = this->getNumberOfOutputSockets(); bool outputStraightAlpha = (editorNode->custom1 & CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT) != 0; BKE_image_user_frame_calc(imageuser, context.getFramenumber(), 0); /* force a load, we assume iuser index will be set OK anyway */ if (image && image->type == IMA_TYPE_MULTILAYER) { bool is_multilayer_ok = false; ImBuf *ibuf = BKE_image_acquire_ibuf(image, imageuser, NULL); if (image->rr) { RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer); if (rl) { NodeOutput *socket; int index; is_multilayer_ok = true; for (index = 0; index < numberOfOutputs; index++) { NodeOperation *operation = NULL; socket = this->getOutputSocket(index); bNodeSocket *bnodeSocket = socket->getbNodeSocket(); RenderPass *rpass = (RenderPass *)BLI_findstring(&rl->passes, bnodeSocket->identifier, offsetof(RenderPass, internal_name)); int view = 0; /* Passes in the file can differ from passes stored in sockets (#36755). * Look up the correct file pass using the socket identifier instead. */ #if 0 NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage;*/ int passindex = storage->pass_index;*/ RenderPass *rpass = (RenderPass *)BLI_findlink(&rl->passes, passindex); #endif /* returns the image view to use for the current active view */ if (BLI_listbase_count_ex(&image->rr->views, 2) > 1) { const int view_image = imageuser->view; const bool is_allview = (view_image == 0); /* if view selected == All (0) */ if (is_allview) { /* heuristic to match image name with scene names * check if the view name exists in the image */ view = BLI_findstringindex(&image->rr->views, context.getViewName(), offsetof(RenderView, name)); if (view == -1) view = 0; } else { view = view_image - 1; } } if (rpass) { switch (rpass->channels) { case 1: operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, rpass->passtype, view, COM_DT_VALUE); break; /* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */ /* XXX any way to detect actual vector images? */ case 3: operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, rpass->passtype, view, COM_DT_VECTOR); break; case 4: operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, rpass->passtype, view, COM_DT_COLOR); break; default: /* dummy operation is added below */ break; } if (index == 0 && operation) { converter.addPreview(operation->getOutputSocket()); } if (rpass->passtype == SCE_PASS_COMBINED) { BLI_assert(operation != NULL); BLI_assert(index < numberOfOutputs - 1); NodeOutput *outputSocket = this->getOutputSocket(index + 1); SeparateChannelOperation *separate_operation; separate_operation = new SeparateChannelOperation(); separate_operation->setChannel(3); converter.addOperation(separate_operation); converter.addLink(operation->getOutputSocket(), separate_operation->getInputSocket(0)); converter.mapOutputSocket(outputSocket, separate_operation->getOutputSocket()); index++; } } /* incase we can't load the layer */ if (operation == NULL) converter.setInvalidOutput(getOutputSocket(index)); } } }