implemented demonstrative dip to black transition
This commit is contained in:
@@ -1,10 +1,5 @@
|
|||||||
#include "crossdissolve.h"
|
#include "crossdissolve.h"
|
||||||
|
|
||||||
CrossDissolveTransition::CrossDissolveTransition()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Node *CrossDissolveTransition::copy() const
|
Node *CrossDissolveTransition::copy() const
|
||||||
{
|
{
|
||||||
CrossDissolveTransition* c = new CrossDissolveTransition();
|
CrossDissolveTransition* c = new CrossDissolveTransition();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
class CrossDissolveTransition : public TransitionBlock
|
class CrossDissolveTransition : public TransitionBlock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CrossDissolveTransition();
|
CrossDissolveTransition() = default;
|
||||||
|
|
||||||
virtual Node* copy() const override;
|
virtual Node* copy() const override;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,35 @@
|
|||||||
#include "diptoblack.h"
|
#include "diptoblack.h"
|
||||||
|
|
||||||
DipToBlackTransition::DipToBlackTransition()
|
Node *DipToBlackTransition::copy() const
|
||||||
{
|
{
|
||||||
|
DipToBlackTransition* c = new DipToBlackTransition();
|
||||||
|
|
||||||
|
CopyParameters(this, c);
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DipToBlackTransition::Name() const
|
||||||
|
{
|
||||||
|
return tr("Dip to Black");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DipToBlackTransition::id() const
|
||||||
|
{
|
||||||
|
return "org.olivevideoeditor.Olive.diptoblack";
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DipToBlackTransition::Description() const
|
||||||
|
{
|
||||||
|
return tr("A smooth dip to transparency and back into another clip.");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DipToBlackTransition::IsAccelerated() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DipToBlackTransition::CodeFragment() const
|
||||||
|
{
|
||||||
|
return ReadFileAsString(":/shaders/diptoblack.frag");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,16 @@
|
|||||||
class DipToBlackTransition : public TransitionBlock
|
class DipToBlackTransition : public TransitionBlock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DipToBlackTransition();
|
DipToBlackTransition() = default;
|
||||||
|
|
||||||
|
virtual Node* copy() const override;
|
||||||
|
|
||||||
|
virtual QString Name() const override;
|
||||||
|
virtual QString id() const override;
|
||||||
|
virtual QString Description() const override;
|
||||||
|
|
||||||
|
virtual bool IsAccelerated() const override;
|
||||||
|
virtual QString CodeFragment() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIPTOBLACKTRANSITION_H
|
#endif // DIPTOBLACKTRANSITION_H
|
||||||
|
|||||||
@@ -275,19 +275,28 @@ void OpenGLWorker::RunNodeAccelerated(const Node *node, const TimeRange &range,
|
|||||||
const TransitionBlock* transition_node = static_cast<const TransitionBlock*>(node);
|
const TransitionBlock* transition_node = static_cast<const TransitionBlock*>(node);
|
||||||
|
|
||||||
// Provide transition information
|
// Provide transition information
|
||||||
rational internal_time = range.in() - block_node->in();
|
double internal_time = (range.in() - block_node->in()).toDouble();
|
||||||
|
|
||||||
|
GLfloat all_prog = static_cast<GLfloat>(internal_time / block_node->length().toDouble());
|
||||||
|
GLfloat out_prog = 0;
|
||||||
|
GLfloat in_prog = 0;
|
||||||
|
|
||||||
|
if (transition_node->out_offset() != 0) {
|
||||||
|
out_prog = static_cast<GLfloat>(clamp(1.0 - (internal_time / transition_node->out_offset().toDouble()), 0.0, 1.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transition_node->in_offset() != 0) {
|
||||||
|
in_prog = static_cast<GLfloat>(clamp((internal_time - transition_node->out_offset().toDouble()) / transition_node->in_offset().toDouble(), 0.0, 1.0));
|
||||||
|
}
|
||||||
|
|
||||||
// Provides total transition progress from 0.0 (start) - 1.0 (end)
|
// Provides total transition progress from 0.0 (start) - 1.0 (end)
|
||||||
shader->setUniformValue("ove_tprog_all",
|
shader->setUniformValue("ove_tprog_all", all_prog);
|
||||||
static_cast<GLfloat>(internal_time.toDouble() / block_node->length().toDouble()));
|
|
||||||
|
|
||||||
// Provides progress of out section from 1.0 (start) - 0.0 (end)
|
// Provides progress of out section from 1.0 (start) - 0.0 (end)
|
||||||
shader->setUniformValue("ove_tprog_out",
|
shader->setUniformValue("ove_tprog_out", out_prog);
|
||||||
static_cast<GLfloat>(clamp(internal_time.toDouble() / transition_node->out_offset().toDouble(), 0.0, 1.0)));
|
|
||||||
|
|
||||||
// Provides progress of in section from 0.0 (start) - 1.0 (end)
|
// Provides progress of in section from 0.0 (start) - 1.0 (end)
|
||||||
shader->setUniformValue("ove_tprog_in",
|
shader->setUniformValue("ove_tprog_in", in_prog);
|
||||||
static_cast<GLfloat>(clamp((internal_time - transition_node->out_offset()).toDouble() / transition_node->in_offset().toDouble(), 0.0, 1.0)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,16 +10,14 @@ uniform bool in_block_in_enabled;
|
|||||||
uniform float ove_tprog_all;
|
uniform float ove_tprog_all;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 out_block_col = texture2D(out_block_in, ove_texcoord) * (1.0 - ove_tprog_all);
|
|
||||||
vec4 in_block_col = texture2D(in_block_in, ove_texcoord) * ove_tprog_all;
|
|
||||||
|
|
||||||
vec4 composite = vec4(0.0);
|
vec4 composite = vec4(0.0);
|
||||||
|
|
||||||
if (out_block_in_enabled) {
|
if (out_block_in_enabled) {
|
||||||
composite += out_block_col;
|
composite += texture2D(out_block_in, ove_texcoord) * (1.0 - ove_tprog_all);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_block_in_enabled) {
|
if (in_block_in_enabled) {
|
||||||
|
vec4 in_block_col = texture2D(in_block_in, ove_texcoord) * ove_tprog_all;
|
||||||
composite *= 1.0 - in_block_col.a;
|
composite *= 1.0 - in_block_col.a;
|
||||||
composite += in_block_col;
|
composite += in_block_col;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#version 110
|
||||||
|
|
||||||
|
varying vec2 ove_texcoord;
|
||||||
|
|
||||||
|
uniform sampler2D out_block_in;
|
||||||
|
uniform sampler2D in_block_in;
|
||||||
|
uniform bool out_block_in_enabled;
|
||||||
|
uniform bool in_block_in_enabled;
|
||||||
|
|
||||||
|
uniform float ove_tprog_out;
|
||||||
|
uniform float ove_tprog_in;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
vec4 out_block_col;
|
||||||
|
vec4 in_block_col;
|
||||||
|
|
||||||
|
if (out_block_in_enabled) {
|
||||||
|
out_block_col = texture2D(out_block_in, ove_texcoord) * pow(ove_tprog_out, 2.0);
|
||||||
|
} else {
|
||||||
|
out_block_col = vec4(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_block_in_enabled) {
|
||||||
|
in_block_col = texture2D(in_block_in, ove_texcoord) * pow(ove_tprog_in, 2.0);
|
||||||
|
} else {
|
||||||
|
in_block_col = vec4(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_FragColor = out_block_col + in_block_col;
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
<qresource prefix="/shaders">
|
<qresource prefix="/shaders">
|
||||||
<file>alphaover.frag</file>
|
<file>alphaover.frag</file>
|
||||||
<file>crossdissolve.frag</file>
|
<file>crossdissolve.frag</file>
|
||||||
|
<file>diptoblack.frag</file>
|
||||||
<file>opacity.frag</file>
|
<file>opacity.frag</file>
|
||||||
<file>solid.frag</file>
|
<file>solid.frag</file>
|
||||||
<file>videoinput.frag</file>
|
<file>videoinput.frag</file>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "widget/timelinewidget/timelinewidget.h"
|
#include "widget/timelinewidget/timelinewidget.h"
|
||||||
|
|
||||||
#include "node/block/transition/crossdissolve/crossdissolve.h"
|
#include "node/block/transition/crossdissolve/crossdissolve.h"
|
||||||
|
#include "node/block/transition/diptoblack/diptoblack.h"
|
||||||
#include "widget/nodeview/nodeviewundo.h"
|
#include "widget/nodeview/nodeviewundo.h"
|
||||||
|
|
||||||
TimelineWidget::TransitionTool::TransitionTool(TimelineWidget *parent) :
|
TimelineWidget::TransitionTool::TransitionTool(TimelineWidget *parent) :
|
||||||
@@ -88,17 +89,7 @@ void TimelineWidget::TransitionTool::MouseRelease(TimelineViewMouseEvent *event)
|
|||||||
|
|
||||||
if (ghost_) {
|
if (ghost_) {
|
||||||
if (!ghost_->AdjustedLength().isNull()) {
|
if (!ghost_->AdjustedLength().isNull()) {
|
||||||
Block* block_to_transition = Node::ValueToPtr<Block>(ghost_->data(TimelineViewGhostItem::kAttachedBlock));
|
|
||||||
CrossDissolveTransition* transition = new CrossDissolveTransition();
|
CrossDissolveTransition* transition = new CrossDissolveTransition();
|
||||||
NodeInput* transition_input_to_connect;
|
|
||||||
|
|
||||||
if (ghost_->mode() == olive::timeline::kTrimIn) {
|
|
||||||
transition->set_in_and_out_offset(ghost_->AdjustedLength(), 0);
|
|
||||||
transition_input_to_connect = transition->in_block_input();
|
|
||||||
} else {
|
|
||||||
transition->set_in_and_out_offset(0, ghost_->AdjustedLength());
|
|
||||||
transition_input_to_connect = transition->out_block_input();
|
|
||||||
}
|
|
||||||
|
|
||||||
QUndoCommand* command = new QUndoCommand();
|
QUndoCommand* command = new QUndoCommand();
|
||||||
|
|
||||||
@@ -109,19 +100,42 @@ void TimelineWidget::TransitionTool::MouseRelease(TimelineViewMouseEvent *event)
|
|||||||
ghost_->GetAdjustedIn(),
|
ghost_->GetAdjustedIn(),
|
||||||
command);
|
command);
|
||||||
|
|
||||||
// Connect block to transition
|
|
||||||
new NodeEdgeAddCommand(block_to_transition->output(),
|
|
||||||
transition_input_to_connect,
|
|
||||||
command);
|
|
||||||
|
|
||||||
// Connect other block to transition
|
|
||||||
if (dual_transition_) {
|
if (dual_transition_) {
|
||||||
Block* other_block = Node::ValueToPtr<Block>(ghost_->data(TimelineViewGhostItem::kReferenceBlock));
|
transition->set_in_and_out_offset(ghost_->AdjustedLength()/2, ghost_->AdjustedLength()/2);
|
||||||
NodeInput* alternate_transition_input = (transition_input_to_connect == transition->out_block_input())
|
|
||||||
? transition->in_block_input()
|
// Block mouse is hovering over
|
||||||
: transition->out_block_input();
|
Block* active_block = Node::ValueToPtr<Block>(ghost_->data(TimelineViewGhostItem::kAttachedBlock));
|
||||||
new NodeEdgeAddCommand(other_block->output(),
|
|
||||||
alternate_transition_input,
|
// Block mouse is next to
|
||||||
|
Block* friend_block = Node::ValueToPtr<Block>(ghost_->data(TimelineViewGhostItem::kReferenceBlock));
|
||||||
|
|
||||||
|
// Use ghost mode to determine which block is which
|
||||||
|
Block* out_block = (ghost_->mode() == olive::timeline::kTrimIn) ? friend_block : active_block;
|
||||||
|
Block* in_block = (ghost_->mode() == olive::timeline::kTrimIn) ? active_block : friend_block;
|
||||||
|
|
||||||
|
// Connect block to transition
|
||||||
|
new NodeEdgeAddCommand(out_block->output(),
|
||||||
|
transition->out_block_input(),
|
||||||
|
command);
|
||||||
|
|
||||||
|
new NodeEdgeAddCommand(in_block->output(),
|
||||||
|
transition->in_block_input(),
|
||||||
|
command);
|
||||||
|
} else {
|
||||||
|
Block* block_to_transition = Node::ValueToPtr<Block>(ghost_->data(TimelineViewGhostItem::kAttachedBlock));
|
||||||
|
NodeInput* transition_input_to_connect;
|
||||||
|
|
||||||
|
if (ghost_->mode() == olive::timeline::kTrimIn) {
|
||||||
|
transition->set_in_and_out_offset(ghost_->AdjustedLength(), 0);
|
||||||
|
transition_input_to_connect = transition->in_block_input();
|
||||||
|
} else {
|
||||||
|
transition->set_in_and_out_offset(0, ghost_->AdjustedLength());
|
||||||
|
transition_input_to_connect = transition->out_block_input();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect block to transition
|
||||||
|
new NodeEdgeAddCommand(block_to_transition->output(),
|
||||||
|
transition_input_to_connect,
|
||||||
command);
|
command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user