[Bf-blender-cvs] [005dabb] master: Fix T39799: Backdrop (compositor) ignores alpha.
Lukas Tönne
noreply at git.blender.org
Fri Apr 25 12:17:53 CEST 2014
Commit: 005dabbd9ad51b75aef260168c81d5a826d4eb4f
Author: Lukas Tönne
Date: Fri Apr 25 12:00:35 2014 +0200
https://developer.blender.org/rB005dabbd9ad51b75aef260168c81d5a826d4eb4f
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 nod [...]
===================================================================
M source/blender/compositor/intern/COM_NodeConverter.cpp
M source/blender/compositor/intern/COM_NodeConverter.h
M source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
M source/blender/compositor/nodes/COM_CompositorNode.cpp
M source/blender/compositor/nodes/COM_OutputFileNode.cpp
M source/blender/compositor/nodes/COM_ViewerNode.cpp
M source/blender/compositor/operations/COM_CompositorOperation.cpp
M source/blender/compositor/operations/COM_CompositorOperation.h
M source/blender/compositor/operations/COM_OutputFileOperation.cpp
M source/blender/compositor/operations/COM_OutputFileOperation.h
M source/blender/compositor/operations/COM_ViewerOperation.cpp
M source/blender/compositor/operations/COM_ViewerOperation.h
===================================================================
diff --git a/source/blender/compositor/intern/COM_NodeConverter.cpp b/source/blender/compositor/intern/COM_NodeConverter.cpp
index 833fced..5965ead 100644
--- a/source/blender/compositor/intern/COM_NodeConverter.cpp
+++ b/source/blender/compositor/intern/COM_NodeConverter.cpp
@@ -103,6 +103,33 @@ NodeOperationInput *NodeConverter::addOutputProxy(NodeOutput *output)
return proxy->getInputSocket(0);
}
+void NodeConverter::addInputValue(NodeOperationInput *input, float value)
+{
+ SetValueOperation *operation = new SetValueOperation();
+ operation->setValue(value);
+
+ m_builder->addOperation(operation);
+ m_builder->addLink(operation->getOutputSocket(), input);
+}
+
+void NodeConverter::addInputColor(NodeOperationInput *input, const float value[4])
+{
+ SetColorOperation *operation = new SetColorOperation();
+ operation->setChannels(value);
+
+ m_builder->addOperation(operation);
+ m_builder->addLink(operation->getOutputSocket(), input);
+}
+
+void NodeConverter::addInputVector(NodeOperationInput *input, const float value[3])
+{
+ SetVectorOperation *operation = new SetVectorOperation();
+ operation->setVector(value);
+
+ m_builder->addOperation(operation);
+ m_builder->addLink(operation->getOutputSocket(), input);
+}
+
void NodeConverter::addOutputValue(NodeOutput *output, float value)
{
SetValueOperation *operation = new SetValueOperation();
diff --git a/source/blender/compositor/intern/COM_NodeConverter.h b/source/blender/compositor/intern/COM_NodeConverter.h
index a67dafd..cad8408 100644
--- a/source/blender/compositor/intern/COM_NodeConverter.h
+++ b/source/blender/compositor/intern/COM_NodeConverter.h
@@ -75,6 +75,13 @@ public:
*/
NodeOperationInput *addOutputProxy(NodeOutput *output);
+ /** Define a constant input value. */
+ void addInputValue(NodeOperationInput *input, float value);
+ /** Define a constant input color. */
+ void addInputColor(NodeOperationInput *input, const float value[4]);
+ /** Define a constant input vector. */
+ void addInputVector(NodeOperationInput *input, const float value[3]);
+
/** Define a constant output value. */
void addOutputValue(NodeOutput *output, float value);
/** Define a constant output color. */
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
index fdea320..a90bac8 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
@@ -85,7 +85,11 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
const OpInputs &op_to_list = find_operation_inputs(inverse_input_map, to);
if (!op_from || op_to_list.empty()) {
/* XXX allow this? error/debug message? */
- BLI_assert(false);
+ //BLI_assert(false);
+ /* XXX note: this can happen with certain nodes (e.g. OutputFile)
+ * which only generate operations in certain circumstances (rendering)
+ * just let this pass silently for now ...
+ */
continue;
}
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp
index 868528a..3d79eb6 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 83b138c..92fa74b 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 5e37bf0..09a3cea 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);
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp
index 14aba26..ef331a5 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cpp
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp
@@ -48,7 +48,7 @@ CompositorOperation::CompositorOperation() : NodeOperation()
this->m_alphaInput = NULL;
this->m_depthInput = NULL;
- this->m_ignoreAlpha = false;
+ this->m_useAlphaInput = false;
this->m_active = false;
this->m_sceneName[0] = '\0';
@@ -188,21 +188,14 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber)
int input_x = x + dx, input_y = y + dy;
this->m_imageInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
- if (this->m_ignoreAlpha) {
- color[3] = 1.0f;
- }
- else {
- if (this->m_alphaInput != NULL) {
- this->m_alphaInput->readSampled(&(color[3]), input_x, input_y, COM_PS_NEAREST);
- }
+ if (this->m_useAlphaInput) {
+ this->m_alphaInput->readSampled(&(color[3]), input_x, input_y, COM_PS_NEAREST);
}
copy_v4_v4(buffer + offset4, color);
- if (this->m_depthInput != NULL) {
- this->m_depthInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
- zbuffer[offset] = color[0];
- }
+ this->m_depthInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
+ zbuffer[offset] = color[0];
offset4 += COM_NUMBER_OF_CHANNELS;
offset++;
if (isBreaked()) {
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h
index d33e89e..771c32f 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.h
+++ b/source/blender/compositor/operations/COM_CompositorOperation.h
@@ -69,7 +69,7 @@ private:
/**
* @brief Ignore any alpha input
*/
- bool m_ignoreAlpha;
+ bool m_useAlphaInput;
/**
* @brief operation is active for calculating final compo result
@@ -86,7 +86,7 @@ public:
void deinitExecution();
const CompositorPriority getRenderPriority() const { return COM_PRIORITY_MEDIUM; }
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
- void setIgnoreAlpha(bool value) { this->m_ignoreAlpha = value; }
+ void setUseAlphaInput(bool value) { this->m_useAlphaInput = value; }
void setActive(bool a
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list