diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-02-15 14:43:14 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-02-15 14:43:14 +0300 |
commit | 473eff2df8eecaf4cddafbfce6c8d1386d4ec68a (patch) | |
tree | d5c9bf63fe18ac3af804144b362b7ba7383cd068 /source/blender/compositor/nodes/COM_TrackPositionNode.cpp | |
parent | 6371fccdbe34ac214f54a8843dc6d2c9f1e05d92 (diff) |
Compositor: Re-consider the way how track speed works
Based on an user feedback, previous implementation with providing
decoupled X and Y speeds didn't work in production at all: there
is no way to combine this speeds to an usable vector.
So now we're providing speed vector output instead, which provides
speed in an exactly the way Vector Blur node expects it to be:
first two components is a speed from the past, second two components
defines speed to the future.
Old behavior can be achieved by RGBA separating the speed output
and using first tow components.
Now this speed gives quite the same results as a speed pass, with
the only difference that track position speed uses "shutter" of
1 while pass uses shutter of 0.5 (and there's no way to affect on
that?).
Diffstat (limited to 'source/blender/compositor/nodes/COM_TrackPositionNode.cpp')
-rw-r--r-- | source/blender/compositor/nodes/COM_TrackPositionNode.cpp | 71 |
1 files changed, 44 insertions, 27 deletions
diff --git a/source/blender/compositor/nodes/COM_TrackPositionNode.cpp b/source/blender/compositor/nodes/COM_TrackPositionNode.cpp index 7f23798b768..490f72b4aa1 100644 --- a/source/blender/compositor/nodes/COM_TrackPositionNode.cpp +++ b/source/blender/compositor/nodes/COM_TrackPositionNode.cpp @@ -22,6 +22,8 @@ */ #include "COM_TrackPositionNode.h" + +#include "COM_ConvertOperation.h" #include "COM_ExecutionSystem.h" #include "COM_TrackPositionOperation.h" @@ -36,6 +38,26 @@ TrackPositionNode::TrackPositionNode(bNode *editorNode) : Node(editorNode) /* pass */ } +static TrackPositionOperation *create_motion_operation(NodeConverter &converter, + MovieClip *clip, + NodeTrackPosData *trackpos_data, + int axis, + int frame_number, + int delta) +{ + TrackPositionOperation *operation = new TrackPositionOperation(); + operation->setMovieClip(clip); + operation->setTrackingObject(trackpos_data->tracking_object); + operation->setTrackName(trackpos_data->track_name); + operation->setFramenumber(frame_number); + operation->setAxis(axis); + operation->setPosition(CMP_TRACKPOS_ABSOLUTE); + operation->setRelativeFrame(frame_number + delta); + operation->setSpeedOutput(true); + converter.addOperation(operation); + return operation; +} + void TrackPositionNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { bNode *editorNode = this->getbNode(); @@ -44,8 +66,7 @@ void TrackPositionNode::convertToOperations(NodeConverter &converter, const Comp NodeOutput *outputX = this->getOutputSocket(0); NodeOutput *outputY = this->getOutputSocket(1); - NodeOutput *outputSpeedX = this->getOutputSocket(2); - NodeOutput *outputSpeedY = this->getOutputSocket(3); + NodeOutput *outputSpeed = this->getOutputSocket(2); int frame_number; if (editorNode->custom1 == CMP_TRACKPOS_ABSOLUTE_FRAME) { @@ -64,6 +85,7 @@ void TrackPositionNode::convertToOperations(NodeConverter &converter, const Comp operationX->setPosition(editorNode->custom1); operationX->setRelativeFrame(editorNode->custom2); converter.addOperation(operationX); + converter.mapOutputSocket(outputX, operationX->getOutputSocket()); TrackPositionOperation *operationY = new TrackPositionOperation(); operationY->setMovieClip(clip); @@ -74,31 +96,26 @@ void TrackPositionNode::convertToOperations(NodeConverter &converter, const Comp operationY->setPosition(editorNode->custom1); operationY->setRelativeFrame(editorNode->custom2); converter.addOperation(operationY); + converter.mapOutputSocket(outputY, operationY->getOutputSocket()); - TrackPositionOperation *operationSpeedX = new TrackPositionOperation(); - operationSpeedX->setMovieClip(clip); - operationSpeedX->setTrackingObject(trackpos_data->tracking_object); - operationSpeedX->setTrackName(trackpos_data->track_name); - operationSpeedX->setFramenumber(frame_number); - operationSpeedX->setAxis(0); - operationSpeedX->setPosition(editorNode->custom1); - operationSpeedX->setRelativeFrame(editorNode->custom2); - operationSpeedX->setSpeedOutput(true); - converter.addOperation(operationSpeedX); - - TrackPositionOperation *operationSpeedY = new TrackPositionOperation(); - operationSpeedY->setMovieClip(clip); - operationSpeedY->setTrackingObject(trackpos_data->tracking_object); - operationSpeedY->setTrackName(trackpos_data->track_name); - operationSpeedY->setFramenumber(frame_number); - operationSpeedY->setAxis(1); - operationSpeedY->setPosition(editorNode->custom1); - operationSpeedY->setRelativeFrame(editorNode->custom2); - operationSpeedY->setSpeedOutput(true); - converter.addOperation(operationSpeedY); + TrackPositionOperation *operationMotionPreX = + create_motion_operation(converter, clip, trackpos_data, 0, frame_number, -1); + TrackPositionOperation *operationMotionPreY = + create_motion_operation(converter, clip, trackpos_data, 1, frame_number, -1); + TrackPositionOperation *operationMotionPostX = + create_motion_operation(converter, clip, trackpos_data, 0, frame_number, 1); + TrackPositionOperation *operationMotionPostY = + create_motion_operation(converter, clip, trackpos_data, 1, frame_number, 1); - converter.mapOutputSocket(outputX, operationX->getOutputSocket()); - converter.mapOutputSocket(outputY, operationY->getOutputSocket()); - converter.mapOutputSocket(outputSpeedX, operationSpeedX->getOutputSocket()); - converter.mapOutputSocket(outputSpeedY, operationSpeedY->getOutputSocket()); + CombineChannelsOperation *combine_operation = new CombineChannelsOperation(); + converter.addOperation(combine_operation); + converter.addLink(operationMotionPreX->getOutputSocket(), + combine_operation->getInputSocket(0)); + converter.addLink(operationMotionPreY->getOutputSocket(), + combine_operation->getInputSocket(1)); + converter.addLink(operationMotionPostX->getOutputSocket(), + combine_operation->getInputSocket(2)); + converter.addLink(operationMotionPostY->getOutputSocket(), + combine_operation->getInputSocket(3)); + converter.mapOutputSocket(outputSpeed, combine_operation->getOutputSocket()); } |