Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Castilla <manzanillawork@gmail.com>2021-09-28 20:33:06 +0300
committerManuel Castilla <manzanillawork@gmail.com>2021-09-28 23:00:17 +0300
commitf84fb12f5d72433780a96c3cc4381399f153cf1a (patch)
tree62ca25765b3b5ccc2bc8ca35449ddd8f3999071a /source/blender/compositor/nodes
parent76377f0176b9561a7fc8f46b4ed704c631ddd90d (diff)
Compositor: Add support for canvas compositing
This commit adds functionality for operations that require pixel translation or resizing on "Full Frame" mode, allowing to adjust their canvas. It fixes most cropping issues in translate, scale, rotate and transform nodes by adjusting their canvas to the result, instead of the input canvas. Operations output buffer is still always on (0,0) position for easier image algorithm implementation, even when the canvas is not. Current limitations (will be addressed on bcon2): - Displayed translation in Viewer node is limited to 6000px. - When scaling up the canvas size is limited to the scene resolution size x 1.5 . From that point it crops. If none of these limitations are hit, the Viewer node displays the full input with any translation. Differential Revision: https://developer.blender.org/D12466
Diffstat (limited to 'source/blender/compositor/nodes')
-rw-r--r--source/blender/compositor/nodes/COM_BoxMaskNode.cc2
-rw-r--r--source/blender/compositor/nodes/COM_EllipseMaskNode.cc2
-rw-r--r--source/blender/compositor/nodes/COM_ScaleNode.cc6
-rw-r--r--source/blender/compositor/nodes/COM_Stabilize2dNode.cc59
-rw-r--r--source/blender/compositor/nodes/COM_TransformNode.cc37
-rw-r--r--source/blender/compositor/nodes/COM_TranslateNode.cc4
6 files changed, 85 insertions, 25 deletions
diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.cc b/source/blender/compositor/nodes/COM_BoxMaskNode.cc
index 14f42cc42f7..8017e063a69 100644
--- a/source/blender/compositor/nodes/COM_BoxMaskNode.cc
+++ b/source/blender/compositor/nodes/COM_BoxMaskNode.cc
@@ -62,7 +62,7 @@ void BoxMaskNode::convertToOperations(NodeConverter &converter,
scaleOperation->setOffset(0.0f, 0.0f);
scaleOperation->setNewWidth(rd->xsch * render_size_factor);
scaleOperation->setNewHeight(rd->ysch * render_size_factor);
- scaleOperation->getInputSocket(0)->setResizeMode(ResizeMode::None);
+ scaleOperation->getInputSocket(0)->setResizeMode(ResizeMode::Align);
converter.addOperation(scaleOperation);
converter.addLink(valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.cc b/source/blender/compositor/nodes/COM_EllipseMaskNode.cc
index 3b4f5ca8c94..752597ef937 100644
--- a/source/blender/compositor/nodes/COM_EllipseMaskNode.cc
+++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.cc
@@ -62,7 +62,7 @@ void EllipseMaskNode::convertToOperations(NodeConverter &converter,
scaleOperation->setOffset(0.0f, 0.0f);
scaleOperation->setNewWidth(rd->xsch * render_size_factor);
scaleOperation->setNewHeight(rd->ysch * render_size_factor);
- scaleOperation->getInputSocket(0)->setResizeMode(ResizeMode::None);
+ scaleOperation->getInputSocket(0)->setResizeMode(ResizeMode::Align);
converter.addOperation(scaleOperation);
converter.addLink(valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cc b/source/blender/compositor/nodes/COM_ScaleNode.cc
index 819d2e72f30..f1f41375eba 100644
--- a/source/blender/compositor/nodes/COM_ScaleNode.cc
+++ b/source/blender/compositor/nodes/COM_ScaleNode.cc
@@ -52,6 +52,8 @@ void ScaleNode::convertToOperations(NodeConverter &converter,
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
operation->setVariableSize(inputXSocket->isLinked() || inputYSocket->isLinked());
+ operation->set_scale_canvas_max_size(context.get_render_size() * 1.5f);
+
break;
}
case CMP_SCALE_SCENEPERCENT: {
@@ -68,6 +70,7 @@ void ScaleNode::convertToOperations(NodeConverter &converter,
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
operation->setVariableSize(inputXSocket->isLinked() || inputYSocket->isLinked());
+ operation->set_scale_canvas_max_size(context.get_render_size() * 1.5f);
break;
}
@@ -81,13 +84,13 @@ void ScaleNode::convertToOperations(NodeConverter &converter,
operation->setOffset(bnode->custom3, bnode->custom4);
operation->setNewWidth(rd->xsch * render_size_factor);
operation->setNewHeight(rd->ysch * render_size_factor);
- operation->getInputSocket(0)->setResizeMode(ResizeMode::None);
converter.addOperation(operation);
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
operation->setVariableSize(inputXSocket->isLinked() || inputYSocket->isLinked());
+ operation->set_scale_canvas_max_size(context.get_render_size() * 3.0f);
break;
}
@@ -102,6 +105,7 @@ void ScaleNode::convertToOperations(NodeConverter &converter,
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
operation->setVariableSize(inputXSocket->isLinked() || inputYSocket->isLinked());
+ operation->set_scale_canvas_max_size(context.get_render_size() * 1.5f);
break;
}
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cc b/source/blender/compositor/nodes/COM_Stabilize2dNode.cc
index 90f62c6d562..3d8f0bbda7e 100644
--- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cc
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cc
@@ -123,17 +123,54 @@ void Stabilize2dNode::convertToOperations(NodeConverter &converter,
break;
}
case eExecutionModel::FullFrame: {
- TransformOperation *transform_op = new TransformOperation();
- transform_op->set_sampler(sampler);
- transform_op->set_convert_rotate_degree_to_rad(false);
- transform_op->set_invert(invert);
- converter.addOperation(transform_op);
- converter.mapInputSocket(imageInput, transform_op->getInputSocket(0));
- converter.addLink(xAttribute->getOutputSocket(), transform_op->getInputSocket(1));
- converter.addLink(yAttribute->getOutputSocket(), transform_op->getInputSocket(2));
- converter.addLink(angleAttribute->getOutputSocket(), transform_op->getInputSocket(3));
- converter.addLink(scaleAttribute->getOutputSocket(), transform_op->getInputSocket(4));
- converter.mapOutputSocket(getOutputSocket(), transform_op->getOutputSocket());
+ ScaleRelativeOperation *scaleOperation = new ScaleRelativeOperation();
+ scaleOperation->setSampler(sampler);
+ RotateOperation *rotateOperation = new RotateOperation();
+ rotateOperation->setDoDegree2RadConversion(false);
+ rotateOperation->set_sampler(sampler);
+ TranslateOperation *translateOperation = new TranslateCanvasOperation();
+
+ converter.addOperation(scaleOperation);
+ converter.addOperation(translateOperation);
+ converter.addOperation(rotateOperation);
+
+ converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
+ converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
+
+ converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));
+
+ converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1));
+ converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2));
+
+ NodeOperationInput *stabilization_socket = nullptr;
+ if (invert) {
+ /* Translate -> Rotate -> Scale. */
+ stabilization_socket = translateOperation->getInputSocket(0);
+ converter.mapInputSocket(imageInput, translateOperation->getInputSocket(0));
+
+ converter.addLink(translateOperation->getOutputSocket(),
+ rotateOperation->getInputSocket(0));
+ converter.addLink(rotateOperation->getOutputSocket(), scaleOperation->getInputSocket(0));
+
+ converter.mapOutputSocket(getOutputSocket(), scaleOperation->getOutputSocket());
+ }
+ else {
+ /* Scale -> Rotate -> Translate. */
+ stabilization_socket = scaleOperation->getInputSocket(0);
+ converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0));
+
+ converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
+ converter.addLink(rotateOperation->getOutputSocket(),
+ translateOperation->getInputSocket(0));
+
+ converter.mapOutputSocket(getOutputSocket(), translateOperation->getOutputSocket());
+ }
+
+ xAttribute->set_socket_input_resolution_for_stabilization(stabilization_socket);
+ yAttribute->set_socket_input_resolution_for_stabilization(stabilization_socket);
+ scaleAttribute->set_socket_input_resolution_for_stabilization(stabilization_socket);
+ angleAttribute->set_socket_input_resolution_for_stabilization(stabilization_socket);
+ break;
}
}
}
diff --git a/source/blender/compositor/nodes/COM_TransformNode.cc b/source/blender/compositor/nodes/COM_TransformNode.cc
index d2fb7b54633..b38aad78d90 100644
--- a/source/blender/compositor/nodes/COM_TransformNode.cc
+++ b/source/blender/compositor/nodes/COM_TransformNode.cc
@@ -73,16 +73,33 @@ void TransformNode::convertToOperations(NodeConverter &converter,
break;
}
case eExecutionModel::FullFrame: {
- TransformOperation *op = new TransformOperation();
- op->set_sampler((PixelSampler)this->getbNode()->custom1);
- converter.addOperation(op);
-
- converter.mapInputSocket(imageInput, op->getInputSocket(0));
- converter.mapInputSocket(xInput, op->getInputSocket(1));
- converter.mapInputSocket(yInput, op->getInputSocket(2));
- converter.mapInputSocket(angleInput, op->getInputSocket(3));
- converter.mapInputSocket(scaleInput, op->getInputSocket(4));
- converter.mapOutputSocket(getOutputSocket(), op->getOutputSocket());
+ ScaleRelativeOperation *scaleOperation = new ScaleRelativeOperation();
+ converter.addOperation(scaleOperation);
+
+ RotateOperation *rotateOperation = new RotateOperation();
+ rotateOperation->setDoDegree2RadConversion(false);
+ converter.addOperation(rotateOperation);
+
+ TranslateOperation *translateOperation = new TranslateCanvasOperation();
+ converter.addOperation(translateOperation);
+
+ PixelSampler sampler = (PixelSampler)this->getbNode()->custom1;
+ scaleOperation->setSampler(sampler);
+ rotateOperation->set_sampler(sampler);
+ scaleOperation->set_scale_canvas_max_size(context.get_render_size());
+
+ converter.mapInputSocket(imageInput, 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());
break;
}
}
diff --git a/source/blender/compositor/nodes/COM_TranslateNode.cc b/source/blender/compositor/nodes/COM_TranslateNode.cc
index 3a3e98c3472..165a03baf41 100644
--- a/source/blender/compositor/nodes/COM_TranslateNode.cc
+++ b/source/blender/compositor/nodes/COM_TranslateNode.cc
@@ -41,7 +41,9 @@ void TranslateNode::convertToOperations(NodeConverter &converter,
NodeInput *inputYSocket = this->getInputSocket(2);
NodeOutput *outputSocket = this->getOutputSocket(0);
- TranslateOperation *operation = new TranslateOperation();
+ TranslateOperation *operation = context.get_execution_model() == eExecutionModel::Tiled ?
+ new TranslateOperation() :
+ new TranslateCanvasOperation();
operation->set_wrapping(data->wrap_axis);
if (data->relative) {
const RenderData *rd = context.getRenderData();