transitions: extended transition logic

General code and functionality improvements. Moved more code out of the
OpenGL backend for portability. Implemented audio transitions.
Implemented basic transition animation curve settings.
This commit is contained in:
itsmattkc
2020-07-16 00:36:21 +10:00
parent de74adeb5e
commit 662d66ad10
10 changed files with 224 additions and 52 deletions
+10 -20
View File
@@ -279,18 +279,21 @@ QVariant OpenGLProxy::RunNodeAccelerated(const Node *node,
NodeValueMap::const_iterator it;
for (it=job.GetValues().constBegin(); it!=job.GetValues().constEnd(); it++) {
// See if the shader has takes this parameter as an input
int variable_location = shader->uniformLocation(it.key()->id());
int variable_location = shader->uniformLocation(it.key());
if (variable_location == -1) {
continue;
}
// See if this value corresponds to an input (NOTE: it may not and this may be null)
NodeInput* corresponding_input = node->GetInputWithID(it.key());
// This variable is used in the shader, let's set it
const QVariant& value = it.value().data();
NodeParam::DataType data_type = (it.value().type() != NodeParam::kNone)
? it.value().type()
: it.key()->data_type();
: corresponding_input->data_type();
switch (data_type) {
case NodeInput::kInt:
@@ -300,7 +303,7 @@ QVariant OpenGLProxy::RunNodeAccelerated(const Node *node,
shader->setUniformValue(variable_location, value.toFloat());
break;
case NodeInput::kVec2:
if (it.key()->IsArray()) {
if (corresponding_input && corresponding_input->IsArray()) {
QVector<NodeValue> nv = value.value< QVector<NodeValue> >();
QVector<QVector2D> a(nv.size());
@@ -310,7 +313,7 @@ QVariant OpenGLProxy::RunNodeAccelerated(const Node *node,
shader->setUniformValueArray(variable_location, a.constData(), a.size());
int count_location = shader->uniformLocation(QStringLiteral("%1_count").arg(it.key()->id()));
int count_location = shader->uniformLocation(QStringLiteral("%1_count").arg(it.key()));
if (count_location > -1) {
shader->setUniformValue(count_location, a.size());
}
@@ -355,7 +358,7 @@ QVariant OpenGLProxy::RunNodeAccelerated(const Node *node,
shader->setUniformValue(variable_location, textures_to_bind.size());
// If this texture binding is the iterative input, set it here
if (it.key() == job.GetIterativeInput()) {
if (corresponding_input && corresponding_input == job.GetIterativeInput()) {
iterative_input = textures_to_bind.size();
}
@@ -363,7 +366,7 @@ QVariant OpenGLProxy::RunNodeAccelerated(const Node *node,
textures_to_bind.append(tex_id);
// Set enable flag if shader wants it
int enable_param_location = shader->uniformLocation(QStringLiteral("%1_enabled").arg(it.key()->id()));
int enable_param_location = shader->uniformLocation(QStringLiteral("%1_enabled").arg(it.key()));
if (enable_param_location > -1) {
shader->setUniformValue(enable_param_location,
tex_id > 0);
@@ -371,7 +374,7 @@ QVariant OpenGLProxy::RunNodeAccelerated(const Node *node,
if (tex_id > 0) {
// Set texture resolution if shader wants it
int res_param_location = shader->uniformLocation(QStringLiteral("%1_resolution").arg(it.key()->id()));
int res_param_location = shader->uniformLocation(QStringLiteral("%1_resolution").arg(it.key()));
if (res_param_location > -1) {
shader->setUniformValue(res_param_location,
static_cast<GLfloat>(texture->texture()->width() * texture->texture()->divider()),
@@ -404,19 +407,6 @@ QVariant OpenGLProxy::RunNodeAccelerated(const Node *node,
static_cast<GLfloat>(params.width()),
static_cast<GLfloat>(params.height()));
if (node->IsBlock() && static_cast<const Block*>(node)->type() == Block::kTransition) {
const TransitionBlock* transition_node = static_cast<const TransitionBlock*>(node);
// Provides total transition progress from 0.0 (start) - 1.0 (end)
shader->setUniformValue("ove_tprog_all", static_cast<GLfloat>(transition_node->GetTotalProgress(range.in())));
// Provides progress of out section from 1.0 (start) - 0.0 (end)
shader->setUniformValue("ove_tprog_out", static_cast<GLfloat>(transition_node->GetOutProgress(range.in())));
// Provides progress of in section from 0.0 (start) - 1.0 (end)
shader->setUniformValue("ove_tprog_in", static_cast<GLfloat>(transition_node->GetInProgress(range.in())));
}
shader->release();
// Create the output textures
+12 -1
View File
@@ -230,9 +230,20 @@ QVariant RenderWorker::ProcessSamples(const Node *node, const TimeRange &range,
// Update all non-sample and non-footage inputs
NodeValueMap::const_iterator j;
for (j=job.GetValues().constBegin(); j!=job.GetValues().constEnd(); j++) {
value_db.Insert(j.key(), ProcessInput(j.key(), TimeRange(this_sample_time, this_sample_time)));
NodeValueTable value;
NodeInput* corresponding_input = node->GetInputWithID(j.key());
if (corresponding_input) {
value = ProcessInput(corresponding_input, TimeRange(this_sample_time, this_sample_time));
} else {
value.Push(j.value());
}
value_db.Insert(j.key(), value);
}
AddGlobalsToDatabase(value_db, TimeRange(this_sample_time, this_sample_time));
node->ProcessSamples(value_db,
job.samples(),
output_buffer,
+14 -4
View File
@@ -8,13 +8,18 @@
OLIVE_NAMESPACE_ENTER
using NodeValueMap = QHash<NodeInput*, NodeValue>;
using NodeValueMap = QHash<QString, NodeValue>;
class AcceleratedJob {
public:
AcceleratedJob() = default;
NodeValue GetValue(NodeInput* input) const
{
return value_map_.value(input->id());
}
NodeValue GetValue(const QString& input) const
{
return value_map_.value(input);
}
@@ -31,15 +36,20 @@ public:
values[j] = value[subparam].TakeWithMeta(subparam->data_type());
}
value_map_.insert(input, NodeValue(NodeParam::kVec2, QVariant::fromValue(values), input->parentNode()));
InsertValue(input->id(), NodeValue(NodeParam::kVec2, QVariant::fromValue(values), input->parentNode()));
} else {
value_map_.insert(input, value[input].TakeWithMeta(input->data_type()));
InsertValue(input->id(), value[input].TakeWithMeta(input->data_type()));
}
}
void InsertValue(const QString& input, const NodeValue& value)
{
value_map_.insert(input, value);
}
void InsertValue(NodeInput* input, const NodeValue& value)
{
value_map_.insert(input, value);
value_map_.insert(input->id(), value);
}
const NodeValueMap &GetValues() const