forked from bartvdbraak/blender
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?).
This commit is contained in:
parent
6371fccdbe
commit
473eff2df8
@ -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);
|
||||
|
||||
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);
|
||||
|
||||
converter.mapOutputSocket(outputX, operationX->getOutputSocket());
|
||||
converter.mapOutputSocket(outputY, operationY->getOutputSocket());
|
||||
converter.mapOutputSocket(outputSpeedX, operationSpeedX->getOutputSocket());
|
||||
converter.mapOutputSocket(outputSpeedY, operationSpeedY->getOutputSocket());
|
||||
|
||||
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);
|
||||
|
||||
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());
|
||||
}
|
||||
|
@ -80,13 +80,22 @@ void TrackPositionOperation::initExecution()
|
||||
copy_v2_v2(this->m_markerPos, marker->pos);
|
||||
|
||||
if (this->m_speed_output) {
|
||||
marker = BKE_tracking_marker_get(track, clip_framenr - 1);
|
||||
if ((marker->flag & MARKER_DISABLED) == 0) {
|
||||
int relative_clip_framenr =
|
||||
BKE_movieclip_remap_scene_to_clip_frame(
|
||||
this->m_movieClip,
|
||||
this->m_relativeFrame);
|
||||
|
||||
marker = BKE_tracking_marker_get_exact(track,
|
||||
relative_clip_framenr);
|
||||
if (marker != NULL && (marker->flag & MARKER_DISABLED) == 0) {
|
||||
copy_v2_v2(this->m_relativePos, marker->pos);
|
||||
}
|
||||
else {
|
||||
copy_v2_v2(this->m_relativePos, this->m_markerPos);
|
||||
}
|
||||
if (this->m_relativeFrame < this->m_framenumber) {
|
||||
swap_v2_v2(this->m_relativePos, this->m_markerPos);
|
||||
}
|
||||
}
|
||||
else if (this->m_position == CMP_TRACKPOS_RELATIVE_START) {
|
||||
int i;
|
||||
|
@ -36,8 +36,7 @@
|
||||
static bNodeSocketTemplate cmp_node_trackpos_out[] = {
|
||||
{ SOCK_FLOAT, 0, N_("X")},
|
||||
{ SOCK_FLOAT, 0, N_("Y")},
|
||||
{ SOCK_FLOAT, 0, N_("Speed X")},
|
||||
{ SOCK_FLOAT, 0, N_("Speed Y")},
|
||||
{ SOCK_VECTOR, 0, N_("Speed"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_VELOCITY},
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user