diff --git a/app/node/distort/CMakeLists.txt b/app/node/distort/CMakeLists.txt
index e3b0a5b2b..2962e21ca 100644
--- a/app/node/distort/CMakeLists.txt
+++ b/app/node/distort/CMakeLists.txt
@@ -15,6 +15,7 @@
# along with this program. If not, see .
add_subdirectory(crop)
+add_subdirectory(flip)
add_subdirectory(transform)
set(OLIVE_SOURCES
diff --git a/app/node/distort/flip/CMakeLists.txt b/app/node/distort/flip/CMakeLists.txt
new file mode 100644
index 000000000..9e9a2c02b
--- /dev/null
+++ b/app/node/distort/flip/CMakeLists.txt
@@ -0,0 +1,22 @@
+# Olive - Non-Linear Video Editor
+# Copyright (C) 2021 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 .
+
+set(OLIVE_SOURCES
+ ${OLIVE_SOURCES}
+ node/distort/flip/flipdistortnode.cpp
+ node/distort/flip/flipdistortnode.h
+ PARENT_SCOPE
+)
diff --git a/app/node/distort/flip/flipdistortnode.cpp b/app/node/distort/flip/flipdistortnode.cpp
new file mode 100644
index 000000000..577437fe5
--- /dev/null
+++ b/app/node/distort/flip/flipdistortnode.cpp
@@ -0,0 +1,95 @@
+/***
+
+ Olive - Non-Linear Video Editor
+ Copyright (C) 2021 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 .
+
+***/
+
+#include "flipdistortnode.h"
+
+namespace olive {
+
+const QString FlipDistortNode::kTextureInput = QStringLiteral("tex_in");
+const QString FlipDistortNode::kHorizontalInput = QStringLiteral("horiz_in");
+const QString FlipDistortNode::kVerticalInput = QStringLiteral("vert_in");
+
+FlipDistortNode::FlipDistortNode()
+{
+ AddInput(kTextureInput, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
+
+ AddInput(kHorizontalInput, NodeValue::kBoolean, false);
+
+ AddInput(kVerticalInput, NodeValue::kBoolean, false);
+}
+
+Node* FlipDistortNode::copy() const
+{
+ return new FlipDistortNode();
+}
+
+QString FlipDistortNode::Name() const
+{
+ return tr("Flip");
+}
+
+QString FlipDistortNode::id() const
+{
+ return QStringLiteral("org.oliveeditor.Olive.flip");
+}
+
+QVector FlipDistortNode::Category() const
+{
+ return {kCategoryDistort};
+}
+
+QString FlipDistortNode::Description() const
+{
+ return tr("Flips an image horizontally or vertically");
+}
+
+void FlipDistortNode::Retranslate()
+{
+ SetInputName(kTextureInput, tr("Input"));
+ SetInputName(kHorizontalInput, tr("Horizontal"));
+ SetInputName(kVerticalInput, tr("Vertical"));
+}
+
+ShaderCode FlipDistortNode::GetShaderCode(const QString& shader_id) const
+{
+ Q_UNUSED(shader_id)
+ return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/flip.frag"));
+}
+
+void FlipDistortNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
+{
+ ShaderJob job;
+
+ job.InsertValue(value);
+
+ // If there's no texture, no need to run an operation
+ if (!job.GetValue(kTextureInput).data().isNull()) {
+ // Only run shader if at least one of flip or flop are selected
+ if (job.GetValue(kHorizontalInput).data().toBool() || job.GetValue(kVerticalInput).data().toBool()) {
+ table->Push(NodeValue::kShaderJob, QVariant::fromValue(job), this);
+ } else {
+ // If we're not flipping or flopping just push the texture
+ table->Push(job.GetValue(kTextureInput));
+ }
+ }
+
+}
+
+}
diff --git a/app/node/distort/flip/flipdistortnode.h b/app/node/distort/flip/flipdistortnode.h
new file mode 100644
index 000000000..ba78023f1
--- /dev/null
+++ b/app/node/distort/flip/flipdistortnode.h
@@ -0,0 +1,56 @@
+/***
+
+ Olive - Non-Linear Video Editor
+ Copyright (C) 2021 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 .
+
+***/
+
+#ifndef FLIPDISTORTNODE_H
+#define FLIPDISTORTNODE_H
+
+#include "node/node.h"
+
+namespace olive {
+
+class FlipDistortNode : public Node
+{
+ Q_OBJECT
+public:
+ FlipDistortNode();
+
+ NODE_DEFAULT_DESTRUCTOR(FlipDistortNode)
+
+ virtual Node* copy() const override;
+
+ virtual QString Name() const override;
+ virtual QString id() const override;
+ virtual QVector Category() const override;
+ virtual QString Description() const override;
+
+ virtual void Retranslate() override;
+
+ virtual ShaderCode GetShaderCode(const QString &shader_id) const override;
+ virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
+
+ static const QString kTextureInput;
+ static const QString kHorizontalInput;
+ static const QString kVerticalInput;
+
+};
+
+}
+
+#endif // FLIPDISTORTNODE_H
diff --git a/app/node/factory.cpp b/app/node/factory.cpp
index ed2f15c78..ed4645a60 100644
--- a/app/node/factory.cpp
+++ b/app/node/factory.cpp
@@ -30,6 +30,7 @@
#include "block/transition/crossdissolve/crossdissolvetransition.h"
#include "block/transition/diptocolor/diptocolortransition.h"
#include "distort/crop/cropdistortnode.h"
+#include "distort/flip/flipdistortnode.h"
#include "distort/transform/transformdistortnode.h"
#include "effect/opacity/opacityeffect.h"
#include "generator/matrix/matrix.h"
@@ -256,6 +257,8 @@ Node *NodeFactory::CreateFromFactoryIndex(const NodeFactory::InternalID &id)
return new NodeGroup();
case kOpacityEffect:
return new OpacityEffect();
+ case kFlipDistort:
+ return new FlipDistortNode();
case kNoiseGenerator:
return new NoiseGeneratorNode();
diff --git a/app/node/factory.h b/app/node/factory.h
index 24da96373..c91895ff3 100644
--- a/app/node/factory.h
+++ b/app/node/factory.h
@@ -63,6 +63,7 @@ public:
kShapeGenerator,
kGroupNode,
kOpacityEffect,
+ kFlipDistort,
kNoiseGenerator,
// Count value
diff --git a/app/shaders/flip.frag b/app/shaders/flip.frag
new file mode 100644
index 000000000..efc4fcf1d
--- /dev/null
+++ b/app/shaders/flip.frag
@@ -0,0 +1,19 @@
+uniform sampler2D tex_in;
+uniform bool horiz_in;
+uniform bool vert_in;
+
+varying vec2 ove_texcoord;
+
+void main(void) {
+ if (!horiz_in && !vert_in) {
+ gl_FragColor = texture2D(tex_in, ove_texcoord);
+ return;
+ }
+
+ vec2 new_coord = ove_texcoord;
+
+ if (horiz_in) new_coord.x = 1.0 - new_coord.x;
+ if (vert_in) new_coord.y = 1.0 - new_coord.y;
+
+ gl_FragColor = texture2D(tex_in, new_coord);
+}