本文整理汇总了C++中NodeOperation::getInputSocket方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeOperation::getInputSocket方法的具体用法?C++ NodeOperation::getInputSocket怎么用?C++ NodeOperation::getInputSocket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeOperation
的用法示例。
在下文中一共展示了NodeOperation::getInputSocket方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertToOperations
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());
}
}
示例2: add_datatype_conversions
void NodeOperationBuilder::add_datatype_conversions()
{
Links convert_links;
for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
const Link &link = *it;
/* proxy operations can skip data type conversion */
NodeOperation *from_op = &link.from()->getOperation();
NodeOperation *to_op = &link.to()->getOperation();
if (!(from_op->useDatatypeConversion() || to_op->useDatatypeConversion()))
continue;
if (link.from()->getDataType() != link.to()->getDataType())
convert_links.push_back(link);
}
for (Links::const_iterator it = convert_links.begin(); it != convert_links.end(); ++it) {
const Link &link = *it;
NodeOperation *converter = Converter::convertDataType(link.from(), link.to());
if (converter) {
addOperation(converter);
removeInputLink(link.to());
addLink(link.from(), converter->getInputSocket(0));
addLink(converter->getOutputSocket(0), link.to());
}
}
}
示例3: convertToOperations
void ColorBalanceNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
bNode *editorsnode = getbNode();
NodeColorBalance *n = (NodeColorBalance *)editorsnode->storage;
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);
NodeOperation *operation;
ColorBalanceLGGOperation *operationLGG = new ColorBalanceLGGOperation();
operationLGG->setGain(n->gain);
operation = operationLGG;
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());
}
示例4: convertToOperations
void ColorBalanceNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
bNode *node = this->getbNode();
NodeColorBalance *n = (NodeColorBalance *)node->storage;
NodeInput *inputSocket = this->getInputSocket(0);
NodeInput *inputImageSocket = this->getInputSocket(1);
NodeOutput *outputSocket = this->getOutputSocket(0);
NodeOperation *operation;
if (node->custom1 == 0) {
ColorBalanceLGGOperation *operationLGG = new ColorBalanceLGGOperation();
float lift_lgg[3], gamma_inv[3];
for (int c = 0; c < 3; c++) {
lift_lgg[c] = 2.0f - n->lift[c];
gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f;
}
operationLGG->setGain(n->gain);
operationLGG->setLift(lift_lgg);
operationLGG->setGammaInv(gamma_inv);
operation = operationLGG;
}
else {
ColorBalanceASCCDLOperation *operationCDL = new ColorBalanceASCCDLOperation();
float offset[3];
copy_v3_fl(offset, n->offset_basis);
add_v3_v3(offset, n->offset);
operationCDL->setOffset(offset);
operationCDL->setPower(n->power);
operationCDL->setSlope(n->slope);
operation = operationCDL;
}
converter.addOperation(operation);
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.mapInputSocket(inputImageSocket, operation->getInputSocket(1));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
示例5: convertToOperations
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());
}
示例6: convertToOperations
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);
}
示例7: convertToOperations
void ConvertAlphaNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
NodeOperation *operation = NULL;
bNode *node = this->getbNode();
/* value hardcoded in rna_nodetree.c */
if (node->custom1 == 1) {
operation = new ConvertPremulToStraightOperation();
}
else {
operation = new ConvertStraightToPremulOperation();
}
converter.addOperation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
示例8: convertToOperations
void ConvertAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
NodeOperation *operation = NULL;
bNode *node = this->getbNode();
/* value hardcoded in rna_nodetree.c */
if (node->custom1 == 1) {
operation = new ConvertPremulToStraightOperation();
}
else {
operation = new ConvertStraightToPremulOperation();
}
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
graph->addOperation(operation);
}
示例9: add_operation_input_constants
void NodeOperationBuilder::add_operation_input_constants()
{
/* Note: unconnected inputs cached first to avoid modifying
* m_operations while iterating over it
*/
typedef std::vector<NodeOperationInput*> Inputs;
Inputs pending_inputs;
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
NodeOperation *op = *it;
for (int k = 0; k < op->getNumberOfInputSockets(); ++k) {
NodeOperationInput *input = op->getInputSocket(k);
if (!input->isConnected())
pending_inputs.push_back(input);
}
}
for (Inputs::const_iterator it = pending_inputs.begin(); it != pending_inputs.end(); ++it) {
NodeOperationInput *input = *it;
add_input_constant_value(input, find_node_input(m_input_map, input));
}
}
示例10: add_complex_operation_buffers
void NodeOperationBuilder::add_complex_operation_buffers()
{
/* note: complex ops and get cached here first, since adding operations
* will invalidate iterators over the main m_operations
*/
Operations complex_ops;
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it)
if ((*it)->isComplex())
complex_ops.push_back(*it);
for (Operations::const_iterator it = complex_ops.begin(); it != complex_ops.end(); ++it) {
NodeOperation *op = *it;
DebugInfo::operation_read_write_buffer(op);
for (int index = 0; index < op->getNumberOfInputSockets(); index++)
add_input_buffers(op, op->getInputSocket(index));
for (int index = 0; index < op->getNumberOfOutputSockets(); index++)
add_output_buffers(op, op->getOutputSocket(index));
}
}
示例11: convertResolution
void Converter::convertResolution(NodeOperationBuilder &builder, NodeOperationOutput *fromSocket, NodeOperationInput *toSocket)
{
InputResizeMode mode = toSocket->getResizeMode();
NodeOperation *toOperation = &toSocket->getOperation();
const float toWidth = toOperation->getWidth();
const float toHeight = toOperation->getHeight();
NodeOperation *fromOperation = &fromSocket->getOperation();
const float fromWidth = fromOperation->getWidth();
const float fromHeight = fromOperation->getHeight();
bool doCenter = false;
bool doScale = false;
float addX = (toWidth - fromWidth) / 2.0f;
float addY = (toHeight - fromHeight) / 2.0f;
float scaleX = 0;
float scaleY = 0;
switch (mode) {
case COM_SC_NO_RESIZE:
break;
case COM_SC_CENTER:
doCenter = true;
break;
case COM_SC_FIT_WIDTH:
doCenter = true;
doScale = true;
scaleX = scaleY = toWidth / fromWidth;
break;
case COM_SC_FIT_HEIGHT:
doCenter = true;
doScale = true;
scaleX = scaleY = toHeight / fromHeight;
break;
case COM_SC_FIT:
doCenter = true;
doScale = true;
scaleX = toWidth / fromWidth;
scaleY = toHeight / fromHeight;
if (scaleX < scaleY) {
scaleX = scaleY;
}
else {
scaleY = scaleX;
}
break;
case COM_SC_STRETCH:
doCenter = true;
doScale = true;
scaleX = toWidth / fromWidth;
scaleY = toHeight / fromHeight;
break;
}
if (doCenter) {
NodeOperation *first = NULL;
ScaleOperation *scaleOperation = NULL;
if (doScale) {
scaleOperation = new ScaleOperation();
scaleOperation->getInputSocket(1)->setResizeMode(COM_SC_NO_RESIZE);
scaleOperation->getInputSocket(2)->setResizeMode(COM_SC_NO_RESIZE);
first = scaleOperation;
SetValueOperation *sxop = new SetValueOperation();
sxop->setValue(scaleX);
builder.addLink(sxop->getOutputSocket(), scaleOperation->getInputSocket(1));
SetValueOperation *syop = new SetValueOperation();
syop->setValue(scaleY);
builder.addLink(syop->getOutputSocket(), scaleOperation->getInputSocket(2));
builder.addOperation(sxop);
builder.addOperation(syop);
unsigned int resolution[2] = {fromOperation->getWidth(),
fromOperation->getHeight()};
scaleOperation->setResolution(resolution);
sxop->setResolution(resolution);
syop->setResolution(resolution);
builder.addOperation(scaleOperation);
}
TranslateOperation *translateOperation = new TranslateOperation();
translateOperation->getInputSocket(1)->setResizeMode(COM_SC_NO_RESIZE);
translateOperation->getInputSocket(2)->setResizeMode(COM_SC_NO_RESIZE);
if (!first) first = translateOperation;
SetValueOperation *xop = new SetValueOperation();
xop->setValue(addX);
builder.addLink(xop->getOutputSocket(), translateOperation->getInputSocket(1));
SetValueOperation *yop = new SetValueOperation();
yop->setValue(addY);
builder.addLink(yop->getOutputSocket(), translateOperation->getInputSocket(2));
builder.addOperation(xop);
builder.addOperation(yop);
unsigned int resolution[2] = {toOperation->getWidth(),
toOperation->getHeight()};
translateOperation->setResolution(resolution);
xop->setResolution(resolution);
yop->setResolution(resolution);
builder.addOperation(translateOperation);
if (doScale) {
//.........这里部分代码省略.........
示例12: convertToOperations
void OutputFileNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
NodeImageMultiFile *storage = (NodeImageMultiFile *)this->getbNode()->storage;
const bool is_multiview = (context.getRenderData()->scemode & R_MULTIVIEW) != 0;
if (!context.isRendering()) {
/* only output files when rendering a sequence -
* otherwise, it overwrites the output files just
* scrubbing through the timeline when the compositor updates.
*/
return;
}
if (storage->format.imtype == R_IMF_IMTYPE_MULTILAYER) {
/* single output operation for the multilayer file */
OutputOpenExrMultiLayerOperation *outputOperation;
if (is_multiview && storage->format.views_format == R_IMF_VIEWS_MULTIVIEW) {
outputOperation = new OutputOpenExrMultiLayerMultiViewOperation(
context.getRenderData(), context.getbNodeTree(), storage->base_path, storage->format.exr_codec, context.getViewName());
}
else {
outputOperation = new OutputOpenExrMultiLayerOperation(
context.getRenderData(), context.getbNodeTree(), storage->base_path, storage->format.exr_codec, context.getViewName());
}
converter.addOperation(outputOperation);
int num_inputs = getNumberOfInputSockets();
bool previewAdded = false;
for (int i = 0; i < num_inputs; ++i) {
NodeInput *input = getInputSocket(i);
NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage;
/* note: layer becomes an empty placeholder if the input is not linked */
outputOperation->add_layer(sockdata->layer, input->getDataType(), input->isLinked());
converter.mapInputSocket(input, outputOperation->getInputSocket(i));
if (!previewAdded) {
converter.addNodeInputPreview(input);
previewAdded = true;
}
}
}
else { /* single layer format */
int num_inputs = getNumberOfInputSockets();
bool previewAdded = false;
for (int i = 0; i < num_inputs; ++i) {
NodeInput *input = getInputSocket(i);
if (input->isLinked()) {
NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage;
ImageFormatData *format = (sockdata->use_node_format ? &storage->format : &sockdata->format);
char path[FILE_MAX];
/* combine file path for the input */
BLI_join_dirfile(path, FILE_MAX, storage->base_path, sockdata->path);
NodeOperation *outputOperation = NULL;
if (is_multiview && format->views_format == R_IMF_VIEWS_MULTIVIEW) {
outputOperation = new OutputOpenExrSingleLayerMultiViewOperation(
context.getRenderData(), context.getbNodeTree(), input->getDataType(), format, path,
context.getViewSettings(), context.getDisplaySettings(), context.getViewName());
}
else if ((!is_multiview) || (format->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
outputOperation = new OutputSingleLayerOperation(
context.getRenderData(), context.getbNodeTree(), input->getDataType(), format, path,
context.getViewSettings(), context.getDisplaySettings(), context.getViewName());
}
else { /* R_IMF_VIEWS_STEREO_3D */
outputOperation = new OutputStereoOperation(
context.getRenderData(), context.getbNodeTree(), input->getDataType(), format, path,
sockdata->layer, context.getViewSettings(), context.getDisplaySettings(), context.getViewName());
}
converter.addOperation(outputOperation);
converter.mapInputSocket(input, outputOperation->getInputSocket(0));
if (!previewAdded) {
converter.addNodeInputPreview(input);
previewAdded = true;
}
}
}
}
}
示例13: convertToOperations
void ZCombineNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
{
if ((context->getRenderData()->scemode & R_FULL_SAMPLE) || this->getbNode()->custom2) {
if (this->getOutputSocket(0)->isConnected()) {
ZCombineOperation *operation = NULL;
if (this->getbNode()->custom1) {
operation = new ZCombineAlphaOperation();
}
else {
operation = new ZCombineOperation();
}
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, system);
this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, system);
this->getInputSocket(3)->relinkConnections(operation->getInputSocket(3), 3, system);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
system->addOperation(operation);
if (this->getOutputSocket(1)->isConnected()) {
MathMinimumOperation *zoperation = new MathMinimumOperation();
addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), zoperation->getInputSocket(0));
addLink(system, operation->getInputSocket(3)->getConnection()->getFromSocket(), zoperation->getInputSocket(1));
this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket());
system->addOperation(zoperation);
}
}
else {
if (this->getOutputSocket(1)->isConnected()) {
MathMinimumOperation *zoperation = new MathMinimumOperation();
this->getInputSocket(1)->relinkConnections(zoperation->getInputSocket(0), 1, system);
this->getInputSocket(3)->relinkConnections(zoperation->getInputSocket(1), 3, system);
this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket());
system->addOperation(zoperation);
}
}
}
else {
// 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();
this->getInputSocket(1)->relinkConnections(maskoperation->getInputSocket(0), 3, system);
this->getInputSocket(3)->relinkConnections(maskoperation->getInputSocket(1), 1, system);
}
else {
maskoperation = new MathLessThanOperation();
this->getInputSocket(1)->relinkConnections(maskoperation->getInputSocket(0), 1, system);
this->getInputSocket(3)->relinkConnections(maskoperation->getInputSocket(1), 3, system);
}
// step 2 anti alias mask bit of an expensive operation, but does the trick
AntiAliasOperation *antialiasoperation = new AntiAliasOperation();
addLink(system, maskoperation->getOutputSocket(), antialiasoperation->getInputSocket(0));
// use mask to blend between the input colors.
ZCombineMaskOperation *zcombineoperation = this->getbNode()->custom1?new ZCombineMaskAlphaOperation():new ZCombineMaskOperation();
addLink(system, antialiasoperation->getOutputSocket(), zcombineoperation->getInputSocket(0));
this->getInputSocket(0)->relinkConnections(zcombineoperation->getInputSocket(1), 0, system);
this->getInputSocket(2)->relinkConnections(zcombineoperation->getInputSocket(2), 2, system);
this->getOutputSocket(0)->relinkConnections(zcombineoperation->getOutputSocket());
system->addOperation(maskoperation);
system->addOperation(antialiasoperation);
system->addOperation(zcombineoperation);
if (this->getOutputSocket(1)->isConnected()) {
MathMinimumOperation *zoperation = new MathMinimumOperation();
addLink(system, maskoperation->getInputSocket(0)->getConnection()->getFromSocket(), zoperation->getInputSocket(0));
addLink(system, maskoperation->getInputSocket(1)->getConnection()->getFromSocket(), zoperation->getInputSocket(1));
this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket());
system->addOperation(zoperation);
}
}
}
示例14: convertToOperations
void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
/// Image output
OutputSocket *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) {
OutputSocket *socket;
int index;
is_multilayer_ok = true;
for (index = 0; index < numberOfOutputs; index++) {
NodeOperation *operation = NULL;
socket = this->getOutputSocket(index);
if (socket->isConnected() || index == 0) {
bNodeSocket *bnodeSocket = socket->getbNodeSocket();
NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage;
int passindex = storage->pass_index;
RenderPass *rpass = (RenderPass *)BLI_findlink(&rl->passes, passindex);
if (rpass) {
imageuser->pass = passindex;
switch (rpass->channels) {
case 1:
operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, 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(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VECTOR);
break;
case 4:
operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_COLOR);
break;
default:
/* dummy operation is added below */
break;
}
if (index == 0 && operation) {
addPreviewOperation(graph, context, operation->getOutputSocket());
}
}
}
/* incase we can't load the layer */
if (operation == NULL) {
convertToOperations_invalid_index(graph, index);
}
}
}
}
BKE_image_release_ibuf(image, ibuf, NULL);
/* without this, multilayer that fail to load will crash blender [#32490] */
if (is_multilayer_ok == false) {
convertToOperations_invalid(graph, context);
}
}
else {
if (numberOfOutputs > 0) {
ImageOperation *operation = new ImageOperation();
if (outputImage->isConnected()) {
if (outputStraightAlpha) {
NodeOperation *alphaConvertOperation = new ConvertPremulToStraightOperation();
addLink(graph, operation->getOutputSocket(0), alphaConvertOperation->getInputSocket(0));
outputImage->relinkConnections(alphaConvertOperation->getOutputSocket());
graph->addOperation(alphaConvertOperation);
}
else {
outputImage->relinkConnections(operation->getOutputSocket());
}
}
operation->setImage(image);
operation->setImageUser(imageuser);
operation->setFramenumber(framenumber);
graph->addOperation(operation);
addPreviewOperation(graph, context, operation->getOutputSocket());
}
if (numberOfOutputs > 1) {
OutputSocket *alphaImage = this->getOutputSocket(1);
if (alphaImage->isConnected()) {
ImageAlphaOperation *alphaOperation = new ImageAlphaOperation();
alphaOperation->setImage(image);
alphaOperation->setImageUser(imageuser);
alphaOperation->setFramenumber(framenumber);
//.........这里部分代码省略.........
示例15: convertToOperations
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());
}
}