diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2017-06-04 01:58:38 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2017-06-04 01:58:38 +0300 |
commit | 556942ec0782c5641c3542535988c507be0a51a6 (patch) | |
tree | 42b02868c25e96d8166f234902b8391b9d4a46dd | |
parent | 420d4a70b8febfdfdab253c5d814aef5bb57dda0 (diff) |
Fix T51587: Blender fails to interpret a specific layer in OpenEXR multilayer file
-rw-r--r-- | source/blender/compositor/nodes/COM_ImageNode.cpp | 33 | ||||
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_image.c | 18 |
2 files changed, 31 insertions, 20 deletions
diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp index 462947f32a3..81891d853d2 100644 --- a/source/blender/compositor/nodes/COM_ImageNode.cpp +++ b/source/blender/compositor/nodes/COM_ImageNode.cpp @@ -99,6 +99,11 @@ void ImageNode::convertToOperations(NodeConverter &converter, const CompositorCo RenderPass *rpass = (RenderPass *)BLI_findstring(&rl->passes, storage->pass_name, offsetof(RenderPass, name)); int view = 0; + if (STREQ(storage->pass_name, RE_PASSNAME_COMBINED) && STREQ(bnodeSocket->name, "Alpha")) { + /* Alpha output is already handled with the associated combined output. */ + continue; + } + /* 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; @@ -140,16 +145,24 @@ void ImageNode::convertToOperations(NodeConverter &converter, const CompositorCo converter.addPreview(operation->getOutputSocket()); } if (STREQ(rpass->name, RE_PASSNAME_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++; + for (int alphaIndex = 0; alphaIndex < numberOfOutputs; alphaIndex++) { + NodeOutput *alphaSocket = this->getOutputSocket(alphaIndex); + bNodeSocket *bnodeAlphaSocket = alphaSocket->getbNodeSocket(); + if (!STREQ(bnodeAlphaSocket->name, "Alpha")) { + continue; + } + NodeImageLayer *alphaStorage = (NodeImageLayer *)bnodeSocket->storage; + if (!STREQ(alphaStorage->pass_name, RE_PASSNAME_COMBINED)) { + continue; + } + 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(alphaSocket, separate_operation->getOutputSocket()); + break; + } } } diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index e958ab9a3dc..a95a99449fd 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -116,6 +116,10 @@ static void cmp_node_image_add_pass_output(bNodeTree *ntree, bNode *node, } else { sock = BLI_findlink(&node->outputs, sock_index); + NodeImageLayer *sockdata = sock->storage; + if(sockdata) { + BLI_strncpy(sockdata->pass_name, passname, sizeof(sockdata->pass_name)); + } } BLI_linklist_append(available_sockets, sock); @@ -158,14 +162,11 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree, bNode *node, LinkNod else type = SOCK_RGBA; + cmp_node_image_add_pass_output(ntree, node, rpass->name, rpass->name, -1, type, false, available_sockets, &prev_index); /* Special handling for the Combined pass to ensure compatibility. */ if (STREQ(rpass->name, RE_PASSNAME_COMBINED)) { - cmp_node_image_add_pass_output(ntree, node, "Image", rpass->name, -1, type, false, available_sockets, &prev_index); cmp_node_image_add_pass_output(ntree, node, "Alpha", rpass->name, -1, SOCK_FLOAT, false, available_sockets, &prev_index); } - else { - cmp_node_image_add_pass_output(ntree, node, rpass->name, rpass->name, -1, type, false, available_sockets, &prev_index); - } } BKE_image_release_ibuf(ima, ibuf, NULL); return; @@ -173,13 +174,10 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree, bNode *node, LinkNod } } - cmp_node_image_add_pass_output(ntree, node, "Image", RE_PASSNAME_COMBINED, RRES_OUT_IMAGE, SOCK_RGBA, false, available_sockets, &prev_index); - cmp_node_image_add_pass_output(ntree, node, "Alpha", RE_PASSNAME_COMBINED, RRES_OUT_ALPHA, SOCK_FLOAT, false, available_sockets, &prev_index); + cmp_node_image_add_pass_output(ntree, node, "Image", RE_PASSNAME_COMBINED, -1, SOCK_RGBA, false, available_sockets, &prev_index); + cmp_node_image_add_pass_output(ntree, node, "Alpha", RE_PASSNAME_COMBINED, -1, SOCK_FLOAT, false, available_sockets, &prev_index); if (ima) { - if (!ima->rr) { - cmp_node_image_add_pass_output(ntree, node, RE_PASSNAME_Z, RE_PASSNAME_Z, RRES_OUT_Z, SOCK_FLOAT, false, available_sockets, &prev_index); - } BKE_image_release_ibuf(ima, ibuf, NULL); } } @@ -276,7 +274,7 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rl for (link = ntree->links.first; link; link = link->next) { if (link->fromsock == sock) break; } - if (!link && sock_index > 30) { + if (!link && (!rlayer || sock_index > 30)) { MEM_freeN(sock->storage); nodeRemoveSocket(ntree, node, sock); } |