build: split the engine into liboakengine.so; worker drops the UI entirely
Physical split: app/{audio,cli,codec,common,config,node,pluginSupport,
render,task,timeline,undo,tool,shaders} plus coreengine, version and
ui/icons+colorcoding move to a new top-level engine/ tree, built as
liboakengine.so (shared). The render backends (oakgl/oakvulkan) move
with it and link the engine library instead of embedding a static
render-core subset (libolive-rendercore is gone).
- oak-render-worker now links liboakengine instead of the whole
libolive-editor object set: 336MB -> 2.9MB, no Qt Widgets UI
- the editor links liboakengine for the engine and keeps only UI
objects in libolive-editor
- install/packaging: GNUInstallDirs libdir on Linux, bundle copy on
macOS, oakengine.dll staged for NSIS, AppImage validation entry
- fix backend lookup for the new layout: DynamicRenderer searched
../app but backends now live in engine/; a stale pre-split liboakgl
in the build tree got dlopened instead, re-initialized and later
destroyed the interposed engine statics (full-suite segfault at
DialogSequenceParameterTab, found via gdb watchpoint)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2022 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
add_subdirectory(cornerpin)
|
||||
add_subdirectory(crop)
|
||||
add_subdirectory(flip)
|
||||
add_subdirectory(mask)
|
||||
add_subdirectory(ripple)
|
||||
add_subdirectory(swirl)
|
||||
add_subdirectory(tile)
|
||||
add_subdirectory(transform)
|
||||
add_subdirectory(wave)
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2022 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/distort/cornerpin/cornerpindistortnode.cpp
|
||||
node/distort/cornerpin/cornerpindistortnode.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,222 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "cornerpindistortnode.h"
|
||||
|
||||
#include "common/lerp.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString CornerPinDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString CornerPinDistortNode::k_top_left_input =
|
||||
QStringLiteral("top_left_in");
|
||||
const QString CornerPinDistortNode::k_top_right_input =
|
||||
QStringLiteral("top_right_in");
|
||||
const QString CornerPinDistortNode::k_bottom_right_input =
|
||||
QStringLiteral("bottom_right_in");
|
||||
const QString CornerPinDistortNode::k_bottom_left_input =
|
||||
QStringLiteral("bottom_left_in");
|
||||
const QString CornerPinDistortNode::k_perspective_input =
|
||||
QStringLiteral("perspective_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
CornerPinDistortNode::CornerPinDistortNode()
|
||||
{
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
add_input(k_perspective_input, NodeValue::k_boolean, true);
|
||||
add_input(k_top_left_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_top_right_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_bottom_right_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_bottom_left_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
|
||||
// Initiate gizmos
|
||||
gizmo_whole_rect_ = add_draggable_gizmo<PolygonGizmo>();
|
||||
gizmo_resize_handle_[0] = add_draggable_gizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, k_top_left_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_top_left_input), 1) });
|
||||
gizmo_resize_handle_[1] = add_draggable_gizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, k_top_right_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_top_right_input), 1) });
|
||||
gizmo_resize_handle_[2] = add_draggable_gizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, k_bottom_right_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_bottom_right_input), 1) });
|
||||
gizmo_resize_handle_[3] = add_draggable_gizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, k_bottom_left_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_bottom_left_input), 1) });
|
||||
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::retranslate()
|
||||
{
|
||||
super::retranslate();
|
||||
|
||||
set_input_name(k_texture_input, tr("Texture"));
|
||||
set_input_name(k_perspective_input, tr("Perspective"));
|
||||
set_input_name(k_top_left_input, tr("Top Left"));
|
||||
set_input_name(k_top_right_input, tr("Top Right"));
|
||||
set_input_name(k_bottom_right_input, tr("Bottom Right"));
|
||||
set_input_name(k_bottom_left_input, tr("Bottom Left"));
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If no texture do nothing
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// In the special case that all sliders are in their default position just
|
||||
// push the texture.
|
||||
if (!(value[k_top_left_input].to_vec2().isNull() &&
|
||||
value[k_top_right_input].to_vec2().isNull() &&
|
||||
value[k_bottom_right_input].to_vec2().isNull() &&
|
||||
value[k_bottom_left_input].to_vec2().isNull())) {
|
||||
ShaderJob job(value);
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
|
||||
// Convert slider values to their pixel values and then convert to clip space (-1.0 ... 1.0) for overriding the
|
||||
// vertex coordinates.
|
||||
const QVector2D &resolution = tex->virtual_resolution();
|
||||
QVector2D half_resolution = resolution * 0.5;
|
||||
QVector2D top_left = QVector2D(value_to_pixel(0, value, resolution)) /
|
||||
half_resolution -
|
||||
QVector2D(1.0, 1.0);
|
||||
QVector2D top_right =
|
||||
QVector2D(value_to_pixel(1, value, resolution)) /
|
||||
half_resolution -
|
||||
QVector2D(1.0, 1.0);
|
||||
QVector2D bottom_right =
|
||||
QVector2D(value_to_pixel(2, value, resolution)) /
|
||||
half_resolution -
|
||||
QVector2D(1.0, 1.0);
|
||||
QVector2D bottom_left =
|
||||
QVector2D(value_to_pixel(3, value, resolution)) /
|
||||
half_resolution -
|
||||
QVector2D(1.0, 1.0);
|
||||
|
||||
// Override default vertex coordinates.
|
||||
QVector<float> adjusted_vertices = {
|
||||
top_left.x(), top_left.y(), 0.0f,
|
||||
top_right.x(), top_right.y(), 0.0f,
|
||||
bottom_right.x(), bottom_right.y(), 0.0f,
|
||||
|
||||
top_left.x(), top_left.y(), 0.0f,
|
||||
bottom_left.x(), bottom_left.y(), 0.0f,
|
||||
bottom_right.x(), bottom_right.y(), 0.0f
|
||||
};
|
||||
job.set_vertex_coordinates(adjusted_vertices);
|
||||
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else {
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShaderCode
|
||||
CornerPinDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
|
||||
return ShaderCode(FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/cornerpin.frag")),
|
||||
FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/cornerpin.vert")));
|
||||
}
|
||||
|
||||
QPointF CornerPinDistortNode::value_to_pixel(int value, const NodeValueRow &row,
|
||||
const QVector2D &resolution) const
|
||||
{
|
||||
Q_ASSERT(value >= 0 && value <= 3);
|
||||
|
||||
QVector2D v;
|
||||
|
||||
switch (value) {
|
||||
case 0: // Top left
|
||||
v = row[k_top_left_input].to_vec2();
|
||||
return QPointF(v.x(), v.y());
|
||||
case 1: // Top right
|
||||
v = row[k_top_right_input].to_vec2();
|
||||
return QPointF(resolution.x() + v.x(), v.y());
|
||||
case 2: // Bottom right
|
||||
v = row[k_bottom_right_input].to_vec2();
|
||||
return QPointF(resolution.x() + v.x(), resolution.y() + v.y());
|
||||
case 3: //Bottom left
|
||||
v = row[k_bottom_left_input].to_vec2();
|
||||
return QPointF(v.x(), v.y() + resolution.y());
|
||||
default: // We should never get here
|
||||
return QPointF();
|
||||
}
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
|
||||
if (gizmo != gizmo_whole_rect_) {
|
||||
gizmo->get_draggers()[0].drag(
|
||||
gizmo->get_draggers()[0].get_start_value().toDouble() + x);
|
||||
gizmo->get_draggers()[1].drag(
|
||||
gizmo->get_draggers()[1].get_start_value().toDouble() + y);
|
||||
}
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
if (TexturePtr tex = row[k_texture_input].to_texture()) {
|
||||
const QVector2D &resolution = tex->virtual_resolution();
|
||||
|
||||
QPointF top_left = value_to_pixel(0, row, resolution);
|
||||
QPointF top_right = value_to_pixel(1, row, resolution);
|
||||
QPointF bottom_right = value_to_pixel(2, row, resolution);
|
||||
QPointF bottom_left = value_to_pixel(3, row, resolution);
|
||||
|
||||
// Add the correct offset to each slider
|
||||
set_input_property(k_top_left_input, QStringLiteral("offset"),
|
||||
QVector2D(0.0, 0.0));
|
||||
set_input_property(k_top_right_input, QStringLiteral("offset"),
|
||||
QVector2D(resolution.x(), 0.0));
|
||||
set_input_property(k_bottom_right_input, QStringLiteral("offset"),
|
||||
resolution);
|
||||
set_input_property(k_bottom_left_input, QStringLiteral("offset"),
|
||||
QVector2D(0.0, resolution.y()));
|
||||
|
||||
// Draw bounding box
|
||||
gizmo_whole_rect_->set_polygon(QPolygonF(
|
||||
{ top_left, top_right, bottom_right, bottom_left, top_left }));
|
||||
|
||||
// Create handles
|
||||
gizmo_resize_handle_[0]->set_point(top_left);
|
||||
gizmo_resize_handle_[1]->set_point(top_right);
|
||||
gizmo_resize_handle_[2]->set_point(bottom_right);
|
||||
gizmo_resize_handle_[3]->set_point(bottom_left);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_CORNERPINDISTORTNODE_H
|
||||
#define OAK_CORNERPINDISTORTNODE_H
|
||||
|
||||
#include <QVector2D>
|
||||
|
||||
#include "node/gizmo/point.h"
|
||||
#include "node/gizmo/polygon.h"
|
||||
#include "node/inputdragger.h"
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
class CornerPinDistortNode : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CornerPinDistortNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(CornerPinDistortNode)
|
||||
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Corner Pin");
|
||||
}
|
||||
|
||||
virtual QString id() const override
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.cornerpin");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr("Distort the image by dragging the corners.");
|
||||
}
|
||||
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual ShaderCode
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
/**
|
||||
* @brief Convenience function - converts the 2D slider values from being
|
||||
* an offset to the actual pixel value.
|
||||
*/
|
||||
QPointF value_to_pixel(int value, const NodeValueRow &row,
|
||||
const QVector2D &resolution) const;
|
||||
|
||||
static const QString k_texture_input;
|
||||
static const QString k_perspective_input;
|
||||
static const QString k_top_left_input;
|
||||
static const QString k_top_right_input;
|
||||
static const QString k_bottom_right_input;
|
||||
static const QString k_bottom_left_input;
|
||||
|
||||
protected slots:
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
// Gizmo variables
|
||||
static const int k_gizmo_corner_count = 4;
|
||||
PointGizmo *gizmo_resize_handle_[k_gizmo_corner_count];
|
||||
PolygonGizmo *gizmo_whole_rect_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OAK_CORNERPINDISTORTNODE_H
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2022 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/distort/crop/cropdistortnode.cpp
|
||||
node/distort/crop/cropdistortnode.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,188 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "cropdistortnode.h"
|
||||
|
||||
#include "common/util.h"
|
||||
#include "node/sliderdisplaytype.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString CropDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString CropDistortNode::k_left_input = QStringLiteral("left_in");
|
||||
const QString CropDistortNode::k_top_input = QStringLiteral("top_in");
|
||||
const QString CropDistortNode::k_right_input = QStringLiteral("right_in");
|
||||
const QString CropDistortNode::k_bottom_input = QStringLiteral("bottom_in");
|
||||
const QString CropDistortNode::k_feather_input = QStringLiteral("feather_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
CropDistortNode::CropDistortNode()
|
||||
{
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
create_crop_side_input(k_left_input);
|
||||
create_crop_side_input(k_top_input);
|
||||
create_crop_side_input(k_right_input);
|
||||
create_crop_side_input(k_bottom_input);
|
||||
|
||||
add_input(k_feather_input, NodeValue::k_float, 0.0);
|
||||
set_input_property(k_feather_input, QStringLiteral("min"), 0.0);
|
||||
|
||||
// Initiate gizmos
|
||||
poly_gizmo_ = add_draggable_gizmo<PolygonGizmo>(
|
||||
{ k_left_input, k_top_input, k_right_input, k_bottom_input });
|
||||
|
||||
point_gizmo_[k_gizmo_scale_top_left] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_left_input, k_top_input });
|
||||
point_gizmo_[k_gizmo_scale_top_center] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_top_input });
|
||||
point_gizmo_[k_gizmo_scale_top_right] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_right_input, k_top_input });
|
||||
point_gizmo_[k_gizmo_scale_bottom_left] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_left_input, k_bottom_input });
|
||||
point_gizmo_[k_gizmo_scale_bottom_center] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_bottom_input });
|
||||
point_gizmo_[k_gizmo_scale_bottom_right] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_right_input, k_bottom_input });
|
||||
point_gizmo_[k_gizmo_scale_center_left] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_left_input });
|
||||
point_gizmo_[k_gizmo_scale_center_right] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_right_input });
|
||||
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
void CropDistortNode::retranslate()
|
||||
{
|
||||
super::retranslate();
|
||||
|
||||
set_input_name(k_texture_input, tr("Texture"));
|
||||
set_input_name(k_left_input, tr("Left"));
|
||||
set_input_name(k_top_input, tr("Top"));
|
||||
set_input_name(k_right_input, tr("Right"));
|
||||
set_input_name(k_bottom_input, tr("Bottom"));
|
||||
set_input_name(k_feather_input, tr("Feather"));
|
||||
}
|
||||
|
||||
void CropDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job;
|
||||
job.insert(value);
|
||||
|
||||
if (TexturePtr texture = job.get(k_texture_input).to_texture()) {
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2,
|
||||
QVector2D(texture->params().width(),
|
||||
texture->params().height()),
|
||||
this));
|
||||
|
||||
if (!qIsNull(job.get(k_left_input).to_double()) ||
|
||||
!qIsNull(job.get(k_right_input).to_double()) ||
|
||||
!qIsNull(job.get(k_top_input).to_double()) ||
|
||||
!qIsNull(job.get(k_bottom_input).to_double())) {
|
||||
table->push(NodeValue::k_texture, texture->to_job(job), this);
|
||||
} else {
|
||||
table->push(job.get(k_texture_input));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShaderCode CropDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(
|
||||
FileFunctions::read_file_as_string(QStringLiteral(":/shaders/crop.frag")));
|
||||
}
|
||||
|
||||
void CropDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
if (TexturePtr tex = row[k_texture_input].to_texture()) {
|
||||
const QVector2D &resolution = tex->virtual_resolution();
|
||||
temp_resolution_ = resolution;
|
||||
|
||||
double left_pt = resolution.x() * row[k_left_input].to_double();
|
||||
double top_pt = resolution.y() * row[k_top_input].to_double();
|
||||
double right_pt = resolution.x() * (1.0 - row[k_right_input].to_double());
|
||||
double bottom_pt =
|
||||
resolution.y() * (1.0 - row[k_bottom_input].to_double());
|
||||
double center_x_pt = mid(left_pt, right_pt);
|
||||
double center_y_pt = mid(top_pt, bottom_pt);
|
||||
|
||||
point_gizmo_[k_gizmo_scale_top_left]->set_point(QPointF(left_pt, top_pt));
|
||||
point_gizmo_[k_gizmo_scale_top_center]->set_point(
|
||||
QPointF(center_x_pt, top_pt));
|
||||
point_gizmo_[k_gizmo_scale_top_right]->set_point(QPointF(right_pt, top_pt));
|
||||
point_gizmo_[k_gizmo_scale_bottom_left]->set_point(
|
||||
QPointF(left_pt, bottom_pt));
|
||||
point_gizmo_[k_gizmo_scale_bottom_center]->set_point(
|
||||
QPointF(center_x_pt, bottom_pt));
|
||||
point_gizmo_[k_gizmo_scale_bottom_right]->set_point(
|
||||
QPointF(right_pt, bottom_pt));
|
||||
point_gizmo_[k_gizmo_scale_center_left]->set_point(
|
||||
QPointF(left_pt, center_y_pt));
|
||||
point_gizmo_[k_gizmo_scale_center_right]->set_point(
|
||||
QPointF(right_pt, center_y_pt));
|
||||
|
||||
poly_gizmo_->set_polygon(
|
||||
QRectF(left_pt, top_pt, right_pt - left_pt, bottom_pt - top_pt));
|
||||
}
|
||||
}
|
||||
|
||||
void CropDistortNode::gizmo_drag_move(double x_diff, double y_diff,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
|
||||
QVector2D res = temp_resolution_;
|
||||
x_diff /= res.x();
|
||||
y_diff /= res.y();
|
||||
|
||||
for (int j = 0; j < gizmo->get_draggers().size(); j++) {
|
||||
NodeInputDragger &i = gizmo->get_draggers()[j];
|
||||
double s = i.get_start_value().toDouble();
|
||||
if (i.get_input().input().input() == k_left_input) {
|
||||
i.drag(s + x_diff);
|
||||
} else if (i.get_input().input().input() == k_top_input) {
|
||||
i.drag(s + y_diff);
|
||||
} else if (i.get_input().input().input() == k_right_input) {
|
||||
i.drag(s - x_diff);
|
||||
} else if (i.get_input().input().input() == k_bottom_input) {
|
||||
i.drag(s - y_diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CropDistortNode::create_crop_side_input(const QString &id)
|
||||
{
|
||||
add_input(id, NodeValue::k_float, 0.0);
|
||||
set_input_property(id, QStringLiteral("min"), 0.0);
|
||||
set_input_property(id, QStringLiteral("max"), 1.0);
|
||||
set_input_property(id, QStringLiteral("view"), slider::k_percentage);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_CROPDISTORTNODE_H
|
||||
#define OAK_CROPDISTORTNODE_H
|
||||
|
||||
#include <QVector2D>
|
||||
|
||||
#include "node/gizmo/point.h"
|
||||
#include "node/gizmo/polygon.h"
|
||||
#include "node/inputdragger.h"
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
class CropDistortNode : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CropDistortNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(CropDistortNode)
|
||||
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Crop");
|
||||
}
|
||||
|
||||
virtual QString id() const override
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.crop");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr("Crop the edges of an image.");
|
||||
}
|
||||
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual ShaderCode
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
static const QString k_texture_input;
|
||||
static const QString k_left_input;
|
||||
static const QString k_top_input;
|
||||
static const QString k_right_input;
|
||||
static const QString k_bottom_input;
|
||||
static const QString k_feather_input;
|
||||
|
||||
protected slots:
|
||||
virtual void gizmo_drag_move(double delta_x, double delta_y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
void create_crop_side_input(const QString &id);
|
||||
|
||||
// Gizmo variables
|
||||
PointGizmo *point_gizmo_[k_gizmo_scale_count];
|
||||
PolygonGizmo *poly_gizmo_;
|
||||
QVector2D temp_resolution_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OAK_CROPDISTORTNODE_H
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2022 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/distort/flip/flipdistortnode.cpp
|
||||
node/distort/flip/flipdistortnode.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,99 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "flipdistortnode.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString FlipDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString FlipDistortNode::k_horizontal_input = QStringLiteral("horiz_in");
|
||||
const QString FlipDistortNode::k_vertical_input = QStringLiteral("vert_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
FlipDistortNode::FlipDistortNode()
|
||||
{
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
add_input(k_horizontal_input, NodeValue::k_boolean, false);
|
||||
|
||||
add_input(k_vertical_input, NodeValue::k_boolean, false);
|
||||
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
QString FlipDistortNode::name() const
|
||||
{
|
||||
return tr("Flip");
|
||||
}
|
||||
|
||||
QString FlipDistortNode::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.flip");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> FlipDistortNode::category() const
|
||||
{
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString FlipDistortNode::description() const
|
||||
{
|
||||
return tr("Flips an image horizontally or vertically");
|
||||
}
|
||||
|
||||
void FlipDistortNode::retranslate()
|
||||
{
|
||||
super::retranslate();
|
||||
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_horizontal_input, tr("Horizontal"));
|
||||
set_input_name(k_vertical_input, tr("Vertical"));
|
||||
}
|
||||
|
||||
ShaderCode FlipDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/flip.frag"));
|
||||
}
|
||||
|
||||
void FlipDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (value[k_horizontal_input].to_bool() ||
|
||||
value[k_vertical_input].to_bool()) {
|
||||
table->push(NodeValue::k_texture, tex->to_job(ShaderJob(value)),
|
||||
this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_FLIPDISTORTNODE_H
|
||||
#define OAK_FLIPDISTORTNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
class FlipDistortNode : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FlipDistortNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(FlipDistortNode)
|
||||
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString k_texture_input;
|
||||
static const QString k_horizontal_input;
|
||||
static const QString k_vertical_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OAK_FLIPDISTORTNODE_H
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2022 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/distort/mask/mask.cpp
|
||||
node/distort/mask/mask.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,133 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "mask.h"
|
||||
|
||||
#include "node/filter/blur/blur.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
#define super PolygonGenerator
|
||||
|
||||
const QString MaskDistortNode::k_feather_input = QStringLiteral("feather_in");
|
||||
const QString MaskDistortNode::k_invert_input = QStringLiteral("invert_in");
|
||||
|
||||
MaskDistortNode::MaskDistortNode()
|
||||
{
|
||||
// Mask should always be (1.0, 1.0, 1.0) for multiply to work correctly
|
||||
set_input_flag(k_color_input, k_input_flag_hidden);
|
||||
|
||||
add_input(k_invert_input, NodeValue::k_boolean, false);
|
||||
|
||||
add_input(k_feather_input, NodeValue::k_float, 0.0);
|
||||
set_input_property(k_feather_input, QStringLiteral("min"), 0.0);
|
||||
}
|
||||
|
||||
ShaderCode MaskDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
if (request.id == QStringLiteral("mrg")) {
|
||||
return ShaderCode(FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/multiply.frag")));
|
||||
} else if (request.id == QStringLiteral("feather")) {
|
||||
return ShaderCode(FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/blur.frag")));
|
||||
} else if (request.id == QStringLiteral("invert")) {
|
||||
return ShaderCode(FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/invertrgba.frag")));
|
||||
} else {
|
||||
return super::get_shader_code(request);
|
||||
}
|
||||
}
|
||||
|
||||
void MaskDistortNode::retranslate()
|
||||
{
|
||||
super::retranslate();
|
||||
|
||||
set_input_name(k_base_input, tr("Texture"));
|
||||
set_input_name(k_invert_input, tr("Invert"));
|
||||
set_input_name(k_feather_input, tr("Feather"));
|
||||
}
|
||||
|
||||
void MaskDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
TexturePtr texture = value[k_base_input].to_texture();
|
||||
|
||||
VideoParams job_params = texture ? texture->params() : globals.vparams();
|
||||
NodeValue job(NodeValue::k_texture,
|
||||
Texture::job(job_params, get_generate_job(value, job_params)),
|
||||
this);
|
||||
|
||||
if (value[k_invert_input].to_bool()) {
|
||||
ShaderJob invert;
|
||||
invert.set_shader_id(QStringLiteral("invert"));
|
||||
invert.insert(QStringLiteral("tex_in"), job);
|
||||
job.set_value(Texture::job(job_params, invert));
|
||||
}
|
||||
|
||||
if (texture) {
|
||||
// Push as merge node
|
||||
ShaderJob merge;
|
||||
|
||||
merge.set_shader_id(QStringLiteral("mrg"));
|
||||
merge.insert(QStringLiteral("tex_a"), value[k_base_input]);
|
||||
|
||||
if (value[k_feather_input].to_double() > 0.0) {
|
||||
// Nest a blur shader in there too
|
||||
ShaderJob feather;
|
||||
|
||||
feather.set_shader_id(QStringLiteral("feather"));
|
||||
feather.insert(BlurFilterNode::k_texture_input, job);
|
||||
feather.insert(BlurFilterNode::k_method_input,
|
||||
NodeValue(NodeValue::k_int,
|
||||
int(BlurFilterNode::k_gaussian), this));
|
||||
feather.insert(BlurFilterNode::k_horiz_input,
|
||||
NodeValue(NodeValue::k_boolean, true, this));
|
||||
feather.insert(BlurFilterNode::k_vert_input,
|
||||
NodeValue(NodeValue::k_boolean, true, this));
|
||||
feather.insert(BlurFilterNode::k_repeat_edge_pixels_input,
|
||||
NodeValue(NodeValue::k_boolean, true, this));
|
||||
feather.insert(BlurFilterNode::k_radius_input,
|
||||
NodeValue(NodeValue::k_float,
|
||||
value[k_feather_input].to_double(), this));
|
||||
feather.set_iterations(2, BlurFilterNode::k_texture_input);
|
||||
feather.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2,
|
||||
texture ? texture->virtual_resolution() :
|
||||
globals.square_resolution(),
|
||||
this));
|
||||
|
||||
merge.insert(QStringLiteral("tex_b"),
|
||||
NodeValue(NodeValue::k_texture,
|
||||
Texture::job(job_params, feather), this));
|
||||
} else {
|
||||
merge.insert(QStringLiteral("tex_b"), job);
|
||||
}
|
||||
|
||||
table->push(NodeValue::k_texture, Texture::job(job_params, merge), this);
|
||||
} else {
|
||||
table->push(job);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_MASKDISTORTNODE_H
|
||||
#define OAK_MASKDISTORTNODE_H
|
||||
|
||||
#include "node/generator/polygon/polygon.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
class MaskDistortNode : public PolygonGenerator {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MaskDistortNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(MaskDistortNode)
|
||||
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Mask");
|
||||
}
|
||||
|
||||
virtual QString id() const override
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.mask");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr("Apply a polygonal mask.");
|
||||
}
|
||||
|
||||
virtual ShaderCode
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString k_invert_input;
|
||||
static const QString k_feather_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OAK_MASKDISTORTNODE_H
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2022 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/distort/ripple/rippledistortnode.cpp
|
||||
node/distort/ripple/rippledistortnode.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,141 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "rippledistortnode.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString RippleDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString RippleDistortNode::k_evolution_input =
|
||||
QStringLiteral("evolution_in");
|
||||
const QString RippleDistortNode::k_intensity_input =
|
||||
QStringLiteral("intensity_in");
|
||||
const QString RippleDistortNode::k_frequency_input =
|
||||
QStringLiteral("frequency_in");
|
||||
const QString RippleDistortNode::k_position_input = QStringLiteral("position_in");
|
||||
const QString RippleDistortNode::k_stretch_input = QStringLiteral("stretch_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
RippleDistortNode::RippleDistortNode()
|
||||
{
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
add_input(k_evolution_input, NodeValue::k_float, 0);
|
||||
add_input(k_intensity_input, NodeValue::k_float, 100);
|
||||
|
||||
add_input(k_frequency_input, NodeValue::k_float, 1);
|
||||
set_input_property(k_frequency_input, QStringLiteral("base"), 0.01);
|
||||
|
||||
add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0));
|
||||
add_input(k_stretch_input, NodeValue::k_boolean, false);
|
||||
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
|
||||
gizmo_ = add_draggable_gizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1),
|
||||
});
|
||||
gizmo_->set_shape(PointGizmo::k_anchor_point);
|
||||
}
|
||||
|
||||
QString RippleDistortNode::name() const
|
||||
{
|
||||
return tr("Ripple");
|
||||
}
|
||||
|
||||
QString RippleDistortNode::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.ripple");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> RippleDistortNode::category() const
|
||||
{
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString RippleDistortNode::description() const
|
||||
{
|
||||
return tr("Distorts an image with a ripple effect.");
|
||||
}
|
||||
|
||||
void RippleDistortNode::retranslate()
|
||||
{
|
||||
super::retranslate();
|
||||
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_frequency_input, tr("Frequency"));
|
||||
set_input_name(k_intensity_input, tr("Intensity"));
|
||||
set_input_name(k_evolution_input, tr("Evolution"));
|
||||
set_input_name(k_position_input, tr("Position"));
|
||||
set_input_name(k_stretch_input, tr("Stretch"));
|
||||
}
|
||||
|
||||
ShaderCode RippleDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/ripple.frag"));
|
||||
}
|
||||
|
||||
void RippleDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qIsNull(value[k_intensity_input].to_double())) {
|
||||
ShaderJob job(value);
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RippleDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
if (TexturePtr tex = row[k_texture_input].to_texture()) {
|
||||
QPointF half_res(tex->virtual_resolution().x() / 2,
|
||||
tex->virtual_resolution().y() / 2);
|
||||
gizmo_->set_point(half_res + row[k_position_input].to_vec2().toPointF());
|
||||
}
|
||||
}
|
||||
|
||||
void RippleDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
NodeInputDragger &x_drag = gizmo_->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->get_draggers()[1];
|
||||
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_RIPPLEDISTORTNODE_H
|
||||
#define OAK_RIPPLEDISTORTNODE_H
|
||||
|
||||
#include "node/gizmo/point.h"
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
class RippleDistortNode : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RippleDistortNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(RippleDistortNode)
|
||||
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
static const QString k_texture_input;
|
||||
static const QString k_evolution_input;
|
||||
static const QString k_intensity_input;
|
||||
static const QString k_frequency_input;
|
||||
static const QString k_position_input;
|
||||
static const QString k_stretch_input;
|
||||
|
||||
protected slots:
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
PointGizmo *gizmo_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OAK_RIPPLEDISTORTNODE_H
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2022 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/distort/swirl/swirldistortnode.cpp
|
||||
node/distort/swirl/swirldistortnode.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,133 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "swirldistortnode.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString SwirlDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString SwirlDistortNode::k_radius_input = QStringLiteral("radius_in");
|
||||
const QString SwirlDistortNode::k_angle_input = QStringLiteral("angle_in");
|
||||
const QString SwirlDistortNode::k_position_input = QStringLiteral("pos_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
SwirlDistortNode::SwirlDistortNode()
|
||||
{
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
add_input(k_radius_input, NodeValue::k_float, 200);
|
||||
set_input_property(k_radius_input, QStringLiteral("min"), 0);
|
||||
|
||||
add_input(k_angle_input, NodeValue::k_float, 10);
|
||||
set_input_property(k_angle_input, QStringLiteral("base"), 0.1);
|
||||
|
||||
add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0));
|
||||
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
|
||||
gizmo_ = add_draggable_gizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1),
|
||||
});
|
||||
gizmo_->set_shape(PointGizmo::k_anchor_point);
|
||||
}
|
||||
|
||||
QString SwirlDistortNode::name() const
|
||||
{
|
||||
return tr("Swirl");
|
||||
}
|
||||
|
||||
QString SwirlDistortNode::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.swirl");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> SwirlDistortNode::category() const
|
||||
{
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString SwirlDistortNode::description() const
|
||||
{
|
||||
return tr("Distorts an image by swirling it around a center point.");
|
||||
}
|
||||
|
||||
void SwirlDistortNode::retranslate()
|
||||
{
|
||||
super::retranslate();
|
||||
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_radius_input, tr("Radius"));
|
||||
set_input_name(k_angle_input, tr("Angle"));
|
||||
set_input_name(k_position_input, tr("Position"));
|
||||
}
|
||||
|
||||
ShaderCode SwirlDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/swirl.frag"));
|
||||
}
|
||||
|
||||
void SwirlDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qIsNull(value[k_angle_input].to_double()) &&
|
||||
!qIsNull(value[k_radius_input].to_double())) {
|
||||
ShaderJob job(value);
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SwirlDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
QPointF half_res(globals.square_resolution().x() / 2,
|
||||
globals.square_resolution().y() / 2);
|
||||
|
||||
gizmo_->set_point(half_res + row[k_position_input].to_vec2().toPointF());
|
||||
}
|
||||
|
||||
void SwirlDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
NodeInputDragger &x_drag = gizmo_->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->get_draggers()[1];
|
||||
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_SWIRLDISTORTNODE_H
|
||||
#define OAK_SWIRLDISTORTNODE_H
|
||||
|
||||
#include "node/gizmo/point.h"
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
class SwirlDistortNode : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SwirlDistortNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(SwirlDistortNode)
|
||||
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
static const QString k_texture_input;
|
||||
static const QString k_radius_input;
|
||||
static const QString k_angle_input;
|
||||
static const QString k_position_input;
|
||||
|
||||
protected slots:
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
PointGizmo *gizmo_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OAK_SWIRLDISTORTNODE_H
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2022 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/distort/tile/tiledistortnode.cpp
|
||||
node/distort/tile/tiledistortnode.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,177 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "tiledistortnode.h"
|
||||
|
||||
#include "node/sliderdisplaytype.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString TileDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString TileDistortNode::k_scale_input = QStringLiteral("scale_in");
|
||||
const QString TileDistortNode::k_position_input = QStringLiteral("position_in");
|
||||
const QString TileDistortNode::k_anchor_input = QStringLiteral("anchor_in");
|
||||
const QString TileDistortNode::k_mirror_x_input = QStringLiteral("mirrorx_in");
|
||||
const QString TileDistortNode::k_mirror_y_input = QStringLiteral("mirrory_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
TileDistortNode::TileDistortNode()
|
||||
{
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
add_input(k_scale_input, NodeValue::k_float, 0.5);
|
||||
set_input_property(k_scale_input, QStringLiteral("min"), 0);
|
||||
set_input_property(k_scale_input, QStringLiteral("view"),
|
||||
slider::k_percentage);
|
||||
|
||||
add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0));
|
||||
|
||||
add_input(k_anchor_input, NodeValue::k_combo, k_middle_center);
|
||||
|
||||
add_input(k_mirror_x_input, NodeValue::k_boolean, false);
|
||||
add_input(k_mirror_y_input, NodeValue::k_boolean, false);
|
||||
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
|
||||
gizmo_ = add_draggable_gizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1),
|
||||
});
|
||||
gizmo_->set_shape(PointGizmo::k_anchor_point);
|
||||
}
|
||||
|
||||
QString TileDistortNode::name() const
|
||||
{
|
||||
return tr("Tile");
|
||||
}
|
||||
|
||||
QString TileDistortNode::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.tile");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> TileDistortNode::category() const
|
||||
{
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString TileDistortNode::description() const
|
||||
{
|
||||
return tr("Infinitely tile an image horizontally and vertically.");
|
||||
}
|
||||
|
||||
void TileDistortNode::retranslate()
|
||||
{
|
||||
super::retranslate();
|
||||
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_scale_input, tr("Scale"));
|
||||
set_input_name(k_position_input, tr("Position"));
|
||||
set_input_name(k_mirror_x_input, tr("Mirror Horizontally"));
|
||||
set_input_name(k_mirror_y_input, tr("Mirror Vertically"));
|
||||
|
||||
set_input_name(k_anchor_input, tr("Anchor"));
|
||||
set_combo_box_strings(k_anchor_input, {
|
||||
tr("Top-Left"),
|
||||
tr("Top-Center"),
|
||||
tr("Top-Right"),
|
||||
tr("Middle-Left"),
|
||||
tr("Middle-Center"),
|
||||
tr("Middle-Right"),
|
||||
tr("Bottom-Left"),
|
||||
tr("Bottom-Center"),
|
||||
tr("Bottom-Right"),
|
||||
});
|
||||
}
|
||||
|
||||
ShaderCode TileDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/tile.frag"));
|
||||
}
|
||||
|
||||
void TileDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qFuzzyCompare(value[k_scale_input].to_double(), 1.0)) {
|
||||
ShaderJob job(value);
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TileDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
if (TexturePtr tex = row[k_texture_input].to_texture()) {
|
||||
QPointF res = tex->virtual_resolution().toPointF();
|
||||
QPointF pos = row[k_position_input].to_vec2().toPointF();
|
||||
qreal x = pos.x();
|
||||
qreal y = pos.y();
|
||||
|
||||
Anchor a = static_cast<Anchor>(row[k_anchor_input].to_int());
|
||||
if (a == k_top_left || a == k_top_center || a == k_top_right) {
|
||||
// Do nothing
|
||||
} else if (a == k_middle_left || a == k_middle_center ||
|
||||
a == k_middle_right) {
|
||||
y += res.y() / 2;
|
||||
} else if (a == k_bottom_left || a == k_bottom_center ||
|
||||
a == k_bottom_right) {
|
||||
y += res.y();
|
||||
}
|
||||
if (a == k_top_left || a == k_middle_left || a == k_bottom_left) {
|
||||
// Do nothing
|
||||
} else if (a == k_top_center || a == k_middle_center ||
|
||||
a == k_bottom_center) {
|
||||
x += res.x() / 2;
|
||||
} else if (a == k_top_right || a == k_middle_right || a == k_bottom_right) {
|
||||
x += res.x();
|
||||
}
|
||||
|
||||
gizmo_->set_point(QPointF(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
void TileDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
NodeInputDragger &x_drag = gizmo_->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->get_draggers()[1];
|
||||
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_TILEDISTORTNODE_H
|
||||
#define OAK_TILEDISTORTNODE_H
|
||||
|
||||
#include "node/gizmo/point.h"
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
class TileDistortNode : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TileDistortNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(TileDistortNode)
|
||||
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
static const QString k_texture_input;
|
||||
static const QString k_scale_input;
|
||||
static const QString k_position_input;
|
||||
static const QString k_anchor_input;
|
||||
static const QString k_mirror_x_input;
|
||||
static const QString k_mirror_y_input;
|
||||
|
||||
protected slots:
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
enum Anchor {
|
||||
k_top_left,
|
||||
k_top_center,
|
||||
k_top_right,
|
||||
k_middle_left,
|
||||
k_middle_center,
|
||||
k_middle_right,
|
||||
k_bottom_left,
|
||||
k_bottom_center,
|
||||
k_bottom_right
|
||||
};
|
||||
|
||||
PointGizmo *gizmo_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OAK_TILEDISTORTNODE_H
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2022 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/distort/transform/transformdistortnode.cpp
|
||||
node/distort/transform/transformdistortnode.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,513 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "transformdistortnode.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString TransformDistortNode::k_parent_input = QStringLiteral("parent_in");
|
||||
const QString TransformDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString TransformDistortNode::k_autoscale_input =
|
||||
QStringLiteral("autoscale_in");
|
||||
const QString TransformDistortNode::k_interpolation_input =
|
||||
QStringLiteral("interpolation_in");
|
||||
|
||||
#define super MatrixGenerator
|
||||
|
||||
TransformDistortNode::TransformDistortNode()
|
||||
{
|
||||
add_input(k_parent_input, NodeValue::k_matrix);
|
||||
|
||||
add_input(k_autoscale_input, NodeValue::k_combo, 0);
|
||||
|
||||
add_input(k_interpolation_input, NodeValue::k_combo, 2);
|
||||
|
||||
prepend_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
// Initiate gizmos
|
||||
rotation_gizmo_ = add_draggable_gizmo<ScreenGizmo>();
|
||||
rotation_gizmo_->add_input(NodeInput(this, k_rotation_input));
|
||||
rotation_gizmo_->set_drag_value_behavior(ScreenGizmo::k_absolute);
|
||||
|
||||
poly_gizmo_ = add_draggable_gizmo<PolygonGizmo>();
|
||||
poly_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0));
|
||||
poly_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1));
|
||||
|
||||
anchor_gizmo_ = add_draggable_gizmo<PointGizmo>();
|
||||
anchor_gizmo_->set_shape(PointGizmo::k_anchor_point);
|
||||
anchor_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_anchor_input), 0));
|
||||
anchor_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_anchor_input), 1));
|
||||
anchor_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0));
|
||||
anchor_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1));
|
||||
|
||||
for (int i = 0; i < k_gizmo_scale_count; i++) {
|
||||
point_gizmo_[i] = add_draggable_gizmo<PointGizmo>();
|
||||
point_gizmo_[i]->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_scale_input), 0));
|
||||
point_gizmo_[i]->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_scale_input), 1));
|
||||
point_gizmo_[i]->set_drag_value_behavior(PointGizmo::k_absolute);
|
||||
}
|
||||
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
void TransformDistortNode::retranslate()
|
||||
{
|
||||
super::retranslate();
|
||||
|
||||
set_input_name(k_parent_input, tr("Parent"));
|
||||
set_input_name(k_autoscale_input, tr("Auto-Scale"));
|
||||
set_input_name(k_texture_input, tr("Texture"));
|
||||
set_input_name(k_interpolation_input, tr("Interpolation"));
|
||||
|
||||
set_combo_box_strings(k_autoscale_input,
|
||||
{ tr("None"), tr("Fit"), tr("Fill"), tr("Stretch") });
|
||||
set_combo_box_strings(k_interpolation_input,
|
||||
{ tr("Nearest Neighbor"), tr("Bilinear"),
|
||||
tr("Mipmapped Bilinear") });
|
||||
}
|
||||
|
||||
void TransformDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// Generate matrix
|
||||
QMatrix4x4 generated_matrix = generate_matrix(
|
||||
value, false, false, false, value[k_parent_input].to_matrix());
|
||||
|
||||
// Pop texture
|
||||
NodeValue texture_meta = value[k_texture_input];
|
||||
|
||||
TexturePtr job_to_push = nullptr;
|
||||
|
||||
// If we have a texture, generate a matrix and make it happen
|
||||
if (TexturePtr texture = texture_meta.to_texture()) {
|
||||
// Adjust our matrix by the resolutions involved
|
||||
QMatrix4x4 real_matrix = generate_auto_scaled_matrix(
|
||||
generated_matrix, value, globals, texture->params());
|
||||
|
||||
if (!real_matrix.isIdentity()) {
|
||||
// The matrix will transform things
|
||||
ShaderJob job;
|
||||
job.insert(QStringLiteral("ove_maintex"), texture_meta);
|
||||
job.insert(QStringLiteral("ove_mvpmat"),
|
||||
NodeValue(NodeValue::k_matrix, real_matrix, this));
|
||||
job.set_interpolation(QStringLiteral("ove_maintex"),
|
||||
static_cast<Texture::Interpolation>(
|
||||
value[k_interpolation_input].to_int()));
|
||||
|
||||
// Use global resolution rather than texture resolution because this may result in a size change
|
||||
job_to_push = Texture::job(globals.vparams(), job);
|
||||
}
|
||||
}
|
||||
|
||||
table->push(NodeValue::k_matrix, QVariant::fromValue(generated_matrix),
|
||||
this);
|
||||
|
||||
if (!job_to_push) {
|
||||
// Re-push whatever value we received
|
||||
table->push(texture_meta);
|
||||
} else {
|
||||
table->push(NodeValue::k_texture, job_to_push, this);
|
||||
}
|
||||
}
|
||||
|
||||
ShaderCode
|
||||
TransformDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request);
|
||||
|
||||
// Returns default frag and vert shader
|
||||
return ShaderCode();
|
||||
}
|
||||
|
||||
void TransformDistortNode::gizmo_drag_start(const NodeValueRow &row, double x,
|
||||
double y, const Rational &time)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
|
||||
if (gizmo == anchor_gizmo_) {
|
||||
gizmo_inverted_transform_ =
|
||||
generate_matrix(row, true, true, false, row[k_parent_input].to_matrix())
|
||||
.toTransform()
|
||||
.inverted();
|
||||
|
||||
} else if (is_a_scale_gizmo(gizmo)) {
|
||||
// Dragging scale handle
|
||||
TexturePtr tex = row[k_texture_input].to_texture();
|
||||
if (!tex) {
|
||||
return;
|
||||
}
|
||||
|
||||
gizmo_scale_uniform_ = row[k_uniform_scale_input].to_bool();
|
||||
gizmo_anchor_pt_ = (row[k_anchor_input].to_vec2() +
|
||||
gizmo->get_globals().nonsquare_resolution() / 2)
|
||||
.toPointF();
|
||||
|
||||
if (gizmo == point_gizmo_[k_gizmo_scale_top_left] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_top_right] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_left] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_right]) {
|
||||
gizmo_scale_axes_ = k_gizmo_scale_both;
|
||||
} else if (gizmo == point_gizmo_[k_gizmo_scale_center_left] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_center_right]) {
|
||||
gizmo_scale_axes_ = k_gizmo_scale_x_only;
|
||||
} else {
|
||||
gizmo_scale_axes_ = k_gizmo_scale_y_only;
|
||||
}
|
||||
|
||||
// Store texture size
|
||||
VideoParams texture_params = tex->params();
|
||||
QVector2D texture_sz(texture_params.square_pixel_width(),
|
||||
texture_params.height());
|
||||
gizmo_scale_anchor_ = row[k_anchor_input].to_vec2() + texture_sz / 2;
|
||||
|
||||
if (gizmo == point_gizmo_[k_gizmo_scale_top_right] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_right] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_center_right]) {
|
||||
// Right handles, flip X axis
|
||||
gizmo_scale_anchor_.setX(texture_sz.x() - gizmo_scale_anchor_.x());
|
||||
}
|
||||
|
||||
if (gizmo == point_gizmo_[k_gizmo_scale_bottom_left] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_right] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_center]) {
|
||||
// Bottom handles, flip Y axis
|
||||
gizmo_scale_anchor_.setY(texture_sz.y() - gizmo_scale_anchor_.y());
|
||||
}
|
||||
|
||||
// Store current matrix
|
||||
gizmo_inverted_transform_ =
|
||||
generate_matrix(row, true, true, true, row[k_parent_input].to_matrix())
|
||||
.toTransform()
|
||||
.inverted();
|
||||
|
||||
} else if (gizmo == rotation_gizmo_) {
|
||||
gizmo_anchor_pt_ = (row[k_anchor_input].to_vec2() +
|
||||
gizmo->get_globals().nonsquare_resolution() / 2)
|
||||
.toPointF();
|
||||
gizmo_start_angle_ =
|
||||
std::atan2(y - gizmo_anchor_pt_.y(), x - gizmo_anchor_pt_.x());
|
||||
gizmo_last_angle_ = gizmo_start_angle_;
|
||||
gizmo_last_alt_angle_ =
|
||||
std::atan2(x - gizmo_anchor_pt_.x(), y - gizmo_anchor_pt_.y());
|
||||
gizmo_rotate_wrap_ = 0;
|
||||
gizmo_rotate_last_dir_ = k_direction_none;
|
||||
}
|
||||
}
|
||||
|
||||
void TransformDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
|
||||
if (gizmo == poly_gizmo_) {
|
||||
NodeInputDragger &x_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->get_draggers()[1];
|
||||
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
|
||||
} else if (gizmo == anchor_gizmo_) {
|
||||
NodeInputDragger &x_anchor_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_anchor_drag = gizmo->get_draggers()[1];
|
||||
NodeInputDragger &x_pos_drag = gizmo->get_draggers()[2];
|
||||
NodeInputDragger &y_pos_drag = gizmo->get_draggers()[3];
|
||||
|
||||
QPointF inverted_movement(gizmo_inverted_transform_.map(QPointF(x, y)));
|
||||
|
||||
x_anchor_drag.drag(x_anchor_drag.get_start_value().toDouble() +
|
||||
inverted_movement.x());
|
||||
y_anchor_drag.drag(y_anchor_drag.get_start_value().toDouble() +
|
||||
inverted_movement.y());
|
||||
x_pos_drag.drag(x_pos_drag.get_start_value().toDouble() + x);
|
||||
y_pos_drag.drag(y_pos_drag.get_start_value().toDouble() + y);
|
||||
|
||||
} else if (gizmo == rotation_gizmo_) {
|
||||
double raw_angle =
|
||||
std::atan2(y - gizmo_anchor_pt_.y(), x - gizmo_anchor_pt_.x());
|
||||
double alt_angle =
|
||||
std::atan2(x - gizmo_anchor_pt_.x(), y - gizmo_anchor_pt_.y());
|
||||
|
||||
double current_angle = raw_angle;
|
||||
|
||||
// Detect rotation wrap around
|
||||
RotationDirection this_dir =
|
||||
get_direction_from_angles(gizmo_last_angle_, raw_angle);
|
||||
RotationDirection alt_dir =
|
||||
get_direction_from_angles(gizmo_last_alt_angle_, alt_angle);
|
||||
|
||||
if (gizmo_rotate_last_dir_ != k_direction_none &&
|
||||
this_dir != gizmo_rotate_last_dir_) {
|
||||
if (alt_dir == gizmo_rotate_last_alt_dir_) {
|
||||
if ((raw_angle - gizmo_last_angle_) < 0) {
|
||||
gizmo_rotate_wrap_++;
|
||||
} else {
|
||||
gizmo_rotate_wrap_--;
|
||||
}
|
||||
|
||||
this_dir = gizmo_rotate_last_dir_;
|
||||
alt_dir = gizmo_rotate_last_alt_dir_;
|
||||
}
|
||||
}
|
||||
|
||||
gizmo_rotate_last_dir_ = this_dir;
|
||||
gizmo_rotate_last_alt_dir_ = alt_dir;
|
||||
gizmo_last_angle_ = raw_angle;
|
||||
gizmo_last_alt_angle_ = alt_angle;
|
||||
|
||||
current_angle += M_PI * 2 * gizmo_rotate_wrap_;
|
||||
|
||||
// Convert radians to degrees
|
||||
double rotation_difference =
|
||||
(current_angle - gizmo_start_angle_) * 57.2958;
|
||||
|
||||
NodeInputDragger &d = gizmo->get_draggers()[0];
|
||||
d.drag(d.get_start_value().toDouble() + rotation_difference);
|
||||
|
||||
} else if (is_a_scale_gizmo(gizmo)) {
|
||||
QPointF mouse_relative =
|
||||
gizmo_inverted_transform_.map(QPointF(x, y) - gizmo_anchor_pt_);
|
||||
|
||||
double x_scaled_movement =
|
||||
qAbs(mouse_relative.x() / gizmo_scale_anchor_.x());
|
||||
double y_scaled_movement =
|
||||
qAbs(mouse_relative.y() / gizmo_scale_anchor_.y());
|
||||
|
||||
NodeInputDragger &x_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->get_draggers()[1];
|
||||
|
||||
switch (gizmo_scale_axes_) {
|
||||
case k_gizmo_scale_x_only:
|
||||
x_drag.drag(x_scaled_movement);
|
||||
break;
|
||||
case k_gizmo_scale_y_only:
|
||||
if (gizmo_scale_uniform_) {
|
||||
x_drag.drag(y_scaled_movement);
|
||||
} else {
|
||||
y_drag.drag(y_scaled_movement);
|
||||
}
|
||||
break;
|
||||
case k_gizmo_scale_both:
|
||||
if (gizmo_scale_uniform_) {
|
||||
double distance =
|
||||
std::hypot(mouse_relative.x(), mouse_relative.y());
|
||||
double texture_diag = std::hypot(gizmo_scale_anchor_.x(),
|
||||
gizmo_scale_anchor_.y());
|
||||
|
||||
x_drag.drag(qAbs(distance / texture_diag));
|
||||
} else {
|
||||
x_drag.drag(x_scaled_movement);
|
||||
y_drag.drag(y_scaled_movement);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QMatrix4x4 TransformDistortNode::adjust_matrix_by_resolutions(
|
||||
const QMatrix4x4 &mat, const QVector2D &sequence_res,
|
||||
const QVector2D &texture_res, const QVector2D &offset,
|
||||
AutoScaleType autoscale_type)
|
||||
{
|
||||
// First, create an identity matrix
|
||||
QMatrix4x4 adjusted_matrix;
|
||||
|
||||
// Scale it to a square based on the sequence's resolution
|
||||
adjusted_matrix.scale(2.0 / sequence_res.x(), 2.0 / sequence_res.y(), 1.0);
|
||||
|
||||
// Apply offset if applicable
|
||||
adjusted_matrix.translate(offset.x(), offset.y());
|
||||
|
||||
// Adjust by the matrix we generated earlier
|
||||
adjusted_matrix *= mat;
|
||||
|
||||
// Scale back out to texture size (adjusted by pixel aspect)
|
||||
adjusted_matrix.scale(texture_res.x() * 0.5, texture_res.y() * 0.5, 1.0);
|
||||
|
||||
// If auto-scale is enabled, fit the texture to the sequence (without cropping)
|
||||
if (autoscale_type != k_auto_scale_none) {
|
||||
if (autoscale_type == k_auto_scale_stretch) {
|
||||
adjusted_matrix.scale(sequence_res.x() / texture_res.x(),
|
||||
sequence_res.y() / texture_res.y(), 1.0);
|
||||
} else {
|
||||
double footage_real_ar = texture_res.x() / texture_res.y();
|
||||
double sequence_real_ar = sequence_res.x() / sequence_res.y();
|
||||
|
||||
double scale_by_x = sequence_res.x() / texture_res.x();
|
||||
double scale_by_y = sequence_res.y() / texture_res.y();
|
||||
double autoscale_val;
|
||||
|
||||
if ((autoscale_type == k_auto_scale_fit) ==
|
||||
(sequence_real_ar > footage_real_ar)) {
|
||||
// Scale by height. Either the sequence is wider than the footage or we're using fill and
|
||||
// cutting off the sides
|
||||
autoscale_val = scale_by_y;
|
||||
} else {
|
||||
// Scale by width. Either the footage is wider than the sequence or we're using fill and
|
||||
// cutting off the top and bottom
|
||||
autoscale_val = scale_by_x;
|
||||
}
|
||||
|
||||
adjusted_matrix.scale(autoscale_val, autoscale_val, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
return adjusted_matrix;
|
||||
}
|
||||
|
||||
void TransformDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
TexturePtr tex = row[k_texture_input].to_texture();
|
||||
if (!tex) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the sequence resolution
|
||||
const QVector2D &sequence_res = globals.nonsquare_resolution();
|
||||
QVector2D sequence_half_res = sequence_res * 0.5;
|
||||
QPointF sequence_half_res_pt = sequence_half_res.toPointF();
|
||||
|
||||
// GizmoTraverser just returns the sizes of the textures and no other data
|
||||
VideoParams tex_params = tex->params();
|
||||
QVector2D tex_sz(tex_params.square_pixel_width(), tex_params.height());
|
||||
QVector2D tex_offset = tex_params.offset();
|
||||
|
||||
// Retrieve autoscale value
|
||||
AutoScaleType autoscale =
|
||||
static_cast<AutoScaleType>(row[k_autoscale_input].to_int());
|
||||
|
||||
// Fold values into a matrix for the rectangle
|
||||
QMatrix4x4 rectangle_matrix;
|
||||
rectangle_matrix.scale(sequence_half_res.x(), sequence_half_res.y());
|
||||
rectangle_matrix *= adjust_matrix_by_resolutions(
|
||||
generate_matrix(row, false, false, false, row[k_parent_input].to_matrix()),
|
||||
sequence_res, tex_sz, tex_offset, autoscale);
|
||||
|
||||
// Create rect and transform it
|
||||
const QVector<QPointF> points = { QPointF(-1, -1), QPointF(1, -1),
|
||||
QPointF(1, 1), QPointF(-1, 1),
|
||||
QPointF(-1, -1) };
|
||||
QTransform rectangle_transform = rectangle_matrix.toTransform();
|
||||
QPolygonF r = rectangle_transform.map(points);
|
||||
r.translate(sequence_half_res_pt);
|
||||
poly_gizmo_->set_polygon(r);
|
||||
|
||||
// Draw anchor point
|
||||
QMatrix4x4 anchor_matrix;
|
||||
anchor_matrix.scale(sequence_half_res.x(), sequence_half_res.y());
|
||||
anchor_matrix *= adjust_matrix_by_resolutions(
|
||||
generate_matrix(row, true, false, false, row[k_parent_input].to_matrix()),
|
||||
sequence_res, tex_sz, tex_offset, autoscale);
|
||||
anchor_gizmo_->set_point(anchor_matrix.toTransform().map(QPointF(0, 0)) +
|
||||
sequence_half_res_pt);
|
||||
|
||||
// Draw scale handles
|
||||
point_gizmo_[k_gizmo_scale_top_left]->set_point(
|
||||
create_scale_point(-1, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_top_center]->set_point(
|
||||
create_scale_point(0, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_top_right]->set_point(
|
||||
create_scale_point(1, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_bottom_left]->set_point(
|
||||
create_scale_point(-1, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_bottom_center]->set_point(
|
||||
create_scale_point(0, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_bottom_right]->set_point(
|
||||
create_scale_point(1, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_center_left]->set_point(
|
||||
create_scale_point(-1, 0, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_center_right]->set_point(
|
||||
create_scale_point(1, 0, sequence_half_res_pt, rectangle_matrix));
|
||||
|
||||
// Use offsets to make the appearance of values that start in the top left, even though we
|
||||
// really anchor around the center
|
||||
set_input_property(k_position_input, QStringLiteral("offset"),
|
||||
sequence_half_res + tex_offset);
|
||||
set_input_property(k_anchor_input, QStringLiteral("offset"), tex_sz * 0.5);
|
||||
}
|
||||
|
||||
QTransform
|
||||
TransformDistortNode::gizmo_transformation(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) const
|
||||
{
|
||||
if (TexturePtr texture = row[k_texture_input].to_texture()) {
|
||||
//auto m = GenerateMatrix(row, false, false, false, row[kParentInput].toMatrix());
|
||||
auto m = generate_matrix(row, false, false, false, QMatrix4x4());
|
||||
return generate_auto_scaled_matrix(m, row, globals, texture->params())
|
||||
.toTransform();
|
||||
}
|
||||
return super::gizmo_transformation(row, globals);
|
||||
}
|
||||
|
||||
QPointF TransformDistortNode::create_scale_point(double x, double y,
|
||||
const QPointF &half_res,
|
||||
const QMatrix4x4 &mat)
|
||||
{
|
||||
return mat.map(QPointF(x, y)) + half_res;
|
||||
}
|
||||
|
||||
QMatrix4x4 TransformDistortNode::generate_auto_scaled_matrix(
|
||||
const QMatrix4x4 &generated_matrix, const NodeValueRow &value,
|
||||
const NodeGlobals &globals, const VideoParams &texture_params) const
|
||||
{
|
||||
const QVector2D &sequence_res = globals.nonsquare_resolution();
|
||||
QVector2D texture_res(texture_params.square_pixel_width(),
|
||||
texture_params.height());
|
||||
AutoScaleType autoscale =
|
||||
static_cast<AutoScaleType>(value[k_autoscale_input].to_int());
|
||||
|
||||
return adjust_matrix_by_resolutions(generated_matrix, sequence_res,
|
||||
texture_res, texture_params.offset(),
|
||||
autoscale);
|
||||
}
|
||||
|
||||
bool TransformDistortNode::is_a_scale_gizmo(NodeGizmo *g) const
|
||||
{
|
||||
for (int i = 0; i < k_gizmo_scale_count; i++) {
|
||||
if (point_gizmo_[i] == g) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
TransformDistortNode::RotationDirection
|
||||
TransformDistortNode::get_direction_from_angles(double last, double current)
|
||||
{
|
||||
return (current > last) ? k_direction_positive : k_direction_negative;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_TRANSFORMDISTORTNODE_H
|
||||
#define OAK_TRANSFORMDISTORTNODE_H
|
||||
|
||||
#include "node/generator/matrix/matrix.h"
|
||||
#include "node/gizmo/point.h"
|
||||
#include "node/gizmo/polygon.h"
|
||||
#include "node/gizmo/screen.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
class TransformDistortNode : public MatrixGenerator {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TransformDistortNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(TransformDistortNode)
|
||||
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Transform");
|
||||
}
|
||||
|
||||
virtual QString short_name() const override
|
||||
{
|
||||
// Override MatrixGenerator's short name "Ortho"
|
||||
return name();
|
||||
}
|
||||
|
||||
virtual QString id() const override
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.transform");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr(
|
||||
"Transform an image in 2D space. Equivalent to multiplying by an orthographic matrix.");
|
||||
}
|
||||
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual ShaderCode
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
enum AutoScaleType {
|
||||
k_auto_scale_none,
|
||||
k_auto_scale_fit,
|
||||
k_auto_scale_fill,
|
||||
k_auto_scale_stretch
|
||||
};
|
||||
|
||||
static QMatrix4x4 adjust_matrix_by_resolutions(
|
||||
const QMatrix4x4 &mat, const QVector2D &sequence_res,
|
||||
const QVector2D &texture_res, const QVector2D &offset,
|
||||
AutoScaleType autoscale_type = k_auto_scale_none);
|
||||
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
virtual QTransform
|
||||
gizmo_transformation(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) const override;
|
||||
|
||||
static const QString k_parent_input;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_autoscale_input;
|
||||
static const QString k_interpolation_input;
|
||||
|
||||
protected slots:
|
||||
virtual void gizmo_drag_start(const olive::NodeValueRow &row, double x,
|
||||
double y, const olive::Rational &time) override;
|
||||
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
static QPointF create_scale_point(double x, double y, const QPointF &half_res,
|
||||
const QMatrix4x4 &mat);
|
||||
|
||||
QMatrix4x4
|
||||
generate_auto_scaled_matrix(const QMatrix4x4 &generated_matrix,
|
||||
const NodeValueRow &db, const NodeGlobals &globals,
|
||||
const VideoParams &texture_params) const;
|
||||
|
||||
bool is_a_scale_gizmo(NodeGizmo *g) const;
|
||||
|
||||
// Gizmo variables
|
||||
double gizmo_start_angle_;
|
||||
QTransform gizmo_inverted_transform_;
|
||||
QPointF gizmo_anchor_pt_;
|
||||
bool gizmo_scale_uniform_;
|
||||
double gizmo_last_angle_;
|
||||
double gizmo_last_alt_angle_;
|
||||
int gizmo_rotate_wrap_;
|
||||
|
||||
enum RotationDirection {
|
||||
k_direction_none,
|
||||
k_direction_positive, // Clockwise
|
||||
k_direction_negative // Counter-clockwise
|
||||
};
|
||||
|
||||
static RotationDirection get_direction_from_angles(double last,
|
||||
double current);
|
||||
RotationDirection gizmo_rotate_last_dir_;
|
||||
RotationDirection gizmo_rotate_last_alt_dir_;
|
||||
|
||||
enum GizmoScaleType { k_gizmo_scale_x_only, k_gizmo_scale_y_only, k_gizmo_scale_both };
|
||||
|
||||
GizmoScaleType gizmo_scale_axes_;
|
||||
QVector2D gizmo_scale_anchor_;
|
||||
|
||||
// Gizmo on screen object storage
|
||||
PointGizmo *point_gizmo_[k_gizmo_scale_count];
|
||||
PointGizmo *anchor_gizmo_;
|
||||
PolygonGizmo *poly_gizmo_;
|
||||
ScreenGizmo *rotation_gizmo_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OAK_TRANSFORMDISTORTNODE_H
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2022 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/distort/wave/wavedistortnode.cpp
|
||||
node/distort/wave/wavedistortnode.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,106 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "wavedistortnode.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString WaveDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString WaveDistortNode::k_frequency_input = QStringLiteral("frequency_in");
|
||||
const QString WaveDistortNode::k_intensity_input = QStringLiteral("intensity_in");
|
||||
const QString WaveDistortNode::k_evolution_input = QStringLiteral("evolution_in");
|
||||
const QString WaveDistortNode::k_vertical_input = QStringLiteral("vertical_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
WaveDistortNode::WaveDistortNode()
|
||||
{
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
add_input(k_frequency_input, NodeValue::k_float, 10);
|
||||
add_input(k_intensity_input, NodeValue::k_float, 10);
|
||||
add_input(k_evolution_input, NodeValue::k_float, 0);
|
||||
|
||||
add_input(k_vertical_input, NodeValue::k_combo, false);
|
||||
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
QString WaveDistortNode::name() const
|
||||
{
|
||||
return tr("Wave");
|
||||
}
|
||||
|
||||
QString WaveDistortNode::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.wave");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> WaveDistortNode::category() const
|
||||
{
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString WaveDistortNode::description() const
|
||||
{
|
||||
return tr("Distorts an image along a sine wave.");
|
||||
}
|
||||
|
||||
void WaveDistortNode::retranslate()
|
||||
{
|
||||
super::retranslate();
|
||||
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_frequency_input, tr("Frequency"));
|
||||
set_input_name(k_intensity_input, tr("Intensity"));
|
||||
set_input_name(k_evolution_input, tr("Evolution"));
|
||||
set_input_name(k_vertical_input, tr("Direction"));
|
||||
set_combo_box_strings(k_vertical_input, { tr("Horizontal"), tr("Vertical") });
|
||||
}
|
||||
|
||||
ShaderCode WaveDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/wave.frag"));
|
||||
}
|
||||
|
||||
void WaveDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr texture = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qIsNull(value[k_intensity_input].to_double())) {
|
||||
table->push(NodeValue::k_texture,
|
||||
Texture::job(texture->params(), ShaderJob(value)),
|
||||
this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_WAVEDISTORTNODE_H
|
||||
#define OAK_WAVEDISTORTNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
class WaveDistortNode : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
WaveDistortNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(WaveDistortNode)
|
||||
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString k_texture_input;
|
||||
static const QString k_frequency_input;
|
||||
static const QString k_intensity_input;
|
||||
static const QString k_evolution_input;
|
||||
static const QString k_vertical_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OAK_WAVEDISTORTNODE_H
|
||||
Reference in New Issue
Block a user