diff options
author | Manuel Castilla <manzanillawork@gmail.com> | 2021-09-28 20:33:06 +0300 |
---|---|---|
committer | Manuel Castilla <manzanillawork@gmail.com> | 2021-09-28 23:00:17 +0300 |
commit | f84fb12f5d72433780a96c3cc4381399f153cf1a (patch) | |
tree | 62ca25765b3b5ccc2bc8ca35449ddd8f3999071a /source/blender/compositor/nodes/COM_Stabilize2dNode.cc | |
parent | 76377f0176b9561a7fc8f46b4ed704c631ddd90d (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/COM_Stabilize2dNode.cc')
-rw-r--r-- | source/blender/compositor/nodes/COM_Stabilize2dNode.cc | 59 |
1 files changed, 48 insertions, 11 deletions
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; } } } |