diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-04-25 14:00:35 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2014-04-25 14:05:23 +0400 |
commit | 005dabbd9ad51b75aef260168c81d5a826d4eb4f (patch) | |
tree | cf65862b2f2f685cc587c80b7311bd87f87d6962 /source/blender/compositor/nodes | |
parent | 1eb13519768f5735c9931fec0da07d92155796f1 (diff) |
Fix T39799: Backdrop (compositor) ignores alpha.
This issue is because of a somewhat "special" behavior in old code, which got lost during rB09874df:
There was a variant of the `relinkConnections` function which would leave the socket completely unconnected. This is not a valid state really (given that each unconnected input must otherwise connected to a constant `Set` type node), but was used as a way to distinguish connected alpha/depth sockets in composite and viewer output nodes.
https://developer.blender.org/diffusion/B/browse/master/source/blender/compositor/intern/COM_InputSocket.cpp;28a829893c702918afc5ac1945a06eaefa611594$69
After the large cleanup patch ({D309}) every socket is now automatically connected to a constant, such that `getInputSocketReader` will never return a NULL pointer. This breaks the previous test method, which needs to be replaced by more explicit flags. Luckily this was done only for very few output nodes (Composite, Viewer, Output-File). These now use the regular SetValueOperation default in case "use alpha" is disabled, but set this to an explicit 1.0 value instead of mapping to the node socket.
Diffstat (limited to 'source/blender/compositor/nodes')
-rw-r--r-- | source/blender/compositor/nodes/COM_CompositorNode.cpp | 10 | ||||
-rw-r--r-- | source/blender/compositor/nodes/COM_OutputFileNode.cpp | 3 | ||||
-rw-r--r-- | source/blender/compositor/nodes/COM_ViewerNode.cpp | 10 |
3 files changed, 18 insertions, 5 deletions
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp index 868528ade81..3d79eb693ea 100644 --- a/source/blender/compositor/nodes/COM_CompositorNode.cpp +++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp @@ -34,6 +34,7 @@ void CompositorNode::convertToOperations(NodeConverter &converter, const Composi bNode *editorNode = this->getbNode(); bool is_active = (editorNode->flag & NODE_DO_OUTPUT_RECALC) || context.isRendering(); + bool ignore_alpha = editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA; NodeInput *imageSocket = this->getInputSocket(0); NodeInput *alphaSocket = this->getInputSocket(1); @@ -43,12 +44,17 @@ void CompositorNode::convertToOperations(NodeConverter &converter, const Composi compositorOperation->setSceneName(context.getScene()->id.name); compositorOperation->setRenderData(context.getRenderData()); compositorOperation->setbNodeTree(context.getbNodeTree()); - compositorOperation->setIgnoreAlpha(editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA); + /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */ + compositorOperation->setUseAlphaInput(ignore_alpha || alphaSocket->isLinked()); compositorOperation->setActive(is_active); converter.addOperation(compositorOperation); converter.mapInputSocket(imageSocket, compositorOperation->getInputSocket(0)); - converter.mapInputSocket(alphaSocket, compositorOperation->getInputSocket(1)); + /* only use alpha link if "use alpha" is enabled */ + if (ignore_alpha) + converter.addInputValue(compositorOperation->getInputSocket(1), 1.0f); + else + converter.mapInputSocket(alphaSocket, compositorOperation->getInputSocket(1)); converter.mapInputSocket(depthSocket, compositorOperation->getInputSocket(2)); converter.addNodeInputPreview(imageSocket); diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp index 83b138c1b07..92fa74b9a2e 100644 --- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp +++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp @@ -56,7 +56,8 @@ void OutputFileNode::convertToOperations(NodeConverter &converter, const Composi NodeInput *input = getInputSocket(i); NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage; - outputOperation->add_layer(sockdata->layer, input->getDataType()); + /* 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)); diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp index 5e37bf06dc2..09a3cea2da1 100644 --- a/source/blender/compositor/nodes/COM_ViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp @@ -36,6 +36,7 @@ void ViewerNode::convertToOperations(NodeConverter &converter, const CompositorC bNode *editorNode = this->getbNode(); bool is_active = (editorNode->flag & NODE_DO_OUTPUT_RECALC || context.isRendering()) && ((editorNode->flag & NODE_DO_OUTPUT) && this->isInActiveGroup()); + bool ignore_alpha = editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA; NodeInput *imageSocket = this->getInputSocket(0); NodeInput *alphaSocket = this->getInputSocket(1); @@ -50,7 +51,8 @@ void ViewerNode::convertToOperations(NodeConverter &converter, const CompositorC viewerOperation->setChunkOrder((OrderOfChunks)editorNode->custom1); viewerOperation->setCenterX(editorNode->custom3); viewerOperation->setCenterY(editorNode->custom4); - viewerOperation->setIgnoreAlpha(editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA); + /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */ + viewerOperation->setUseAlphaInput(ignore_alpha || alphaSocket->isLinked()); viewerOperation->setViewSettings(context.getViewSettings()); viewerOperation->setDisplaySettings(context.getDisplaySettings()); @@ -64,7 +66,11 @@ void ViewerNode::convertToOperations(NodeConverter &converter, const CompositorC converter.addOperation(viewerOperation); converter.mapInputSocket(imageSocket, viewerOperation->getInputSocket(0)); - converter.mapInputSocket(alphaSocket, viewerOperation->getInputSocket(1)); + /* only use alpha link if "use alpha" is enabled */ + if (ignore_alpha) + converter.addInputValue(viewerOperation->getInputSocket(1), 1.0f); + else + converter.mapInputSocket(alphaSocket, viewerOperation->getInputSocket(1)); converter.mapInputSocket(depthSocket, viewerOperation->getInputSocket(2)); converter.addNodeInputPreview(imageSocket); |