nodes: implemented more distortion nodes

This commit is contained in:
itsmattkc
2022-09-22 18:12:03 -07:00
parent f84cd8644d
commit b553d5afb7
20 changed files with 1051 additions and 3 deletions
+4
View File
@@ -18,7 +18,11 @@ 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}
+2 -3
View File
@@ -87,11 +87,10 @@ void FlipDistortNode::Value(const NodeValueRow &value, const NodeGlobals &global
if (job.Get(kHorizontalInput).toBool() || job.Get(kVerticalInput).toBool()) {
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
} else {
// If we're not flipping or flopping just push the texture
table->Push(job.Get(kTextureInput));
// If we're not flipping or flopping just push the texture
table->Push(job.Get(kTextureInput));
}
}
}
}
+22
View File
@@ -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,130 @@
/***
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/>.
***/
#include "rippledistortnode.h"
namespace olive {
const QString RippleDistortNode::kTextureInput = QStringLiteral("tex_in");
const QString RippleDistortNode::kEvolutionInput = QStringLiteral("evolution_in");
const QString RippleDistortNode::kIntensityInput = QStringLiteral("intensity_in");
const QString RippleDistortNode::kFrequencyInput = QStringLiteral("frequency_in");
const QString RippleDistortNode::kPositionInput = QStringLiteral("position_in");
const QString RippleDistortNode::kStretchInput = QStringLiteral("stretch_in");
#define super Node
RippleDistortNode::RippleDistortNode()
{
AddInput(kTextureInput, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
AddInput(kEvolutionInput, NodeValue::kFloat, 0);
AddInput(kIntensityInput, NodeValue::kFloat, 100);
AddInput(kFrequencyInput, NodeValue::kFloat, 1);
SetInputProperty(kFrequencyInput, QStringLiteral("base"), 0.01);
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0));
AddInput(kStretchInput, NodeValue::kBoolean, false);
SetFlags(kVideoEffect);
SetEffectInput(kTextureInput);
gizmo_ = AddDraggableGizmo<PointGizmo>({
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0),
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1),
});
gizmo_->SetShape(PointGizmo::kAnchorPoint);
}
QString RippleDistortNode::Name() const
{
return tr("Ripple");
}
QString RippleDistortNode::id() const
{
return QStringLiteral("org.oliveeditor.Olive.ripple");
}
QVector<Node::CategoryID> RippleDistortNode::Category() const
{
return {kCategoryDistort};
}
QString RippleDistortNode::Description() const
{
return tr("Distorts an image with a ripple effect.");
}
void RippleDistortNode::Retranslate()
{
super::Retranslate();
SetInputName(kTextureInput, tr("Input"));
SetInputName(kFrequencyInput, tr("Frequency"));
SetInputName(kIntensityInput, tr("Intensity"));
SetInputName(kEvolutionInput, tr("Evolution"));
SetInputName(kPositionInput, tr("Position"));
SetInputName(kStretchInput, tr("Stretch"));
}
ShaderCode RippleDistortNode::GetShaderCode(const ShaderRequest &request) const
{
Q_UNUSED(request)
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/ripple.frag"));
}
void RippleDistortNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
{
ShaderJob job;
job.Insert(value);
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
// If there's no texture, no need to run an operation
if (job.Get(kTextureInput).toTexture()) {
// Only run shader if at least one of flip or flop are selected
if (!qIsNull(job.Get(kIntensityInput).toDouble())) {
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
} else {
// If we're not flipping or flopping just push the texture
table->Push(job.Get(kTextureInput));
}
}
}
void RippleDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const NodeGlobals &globals)
{
QPointF half_res(globals.resolution_by_par().x()/2, globals.resolution_by_par().y()/2);
gizmo_->SetPoint(half_res + row[kPositionInput].toVec2().toPointF());
}
void RippleDistortNode::GizmoDragMove(double x, double y, const Qt::KeyboardModifiers &modifiers)
{
NodeInputDragger &x_drag = gizmo_->GetDraggers()[0];
NodeInputDragger &y_drag = gizmo_->GetDraggers()[1];
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
}
}
@@ -0,0 +1,66 @@
/***
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/>.
***/
#ifndef RIPPLEDISTORTNODE_H
#define 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 GetShaderCode(const ShaderRequest &request) const override;
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
virtual void UpdateGizmoPositions(const NodeValueRow &row, const NodeGlobals &globals) override;
static const QString kTextureInput;
static const QString kEvolutionInput;
static const QString kIntensityInput;
static const QString kFrequencyInput;
static const QString kPositionInput;
static const QString kStretchInput;
protected slots:
virtual void GizmoDragMove(double x, double y, const Qt::KeyboardModifiers &modifiers) override;
private:
PointGizmo *gizmo_;
};
}
#endif // RIPPLEDISTORTNODE_H
+22
View File
@@ -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
)
+125
View File
@@ -0,0 +1,125 @@
/***
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/>.
***/
#include "swirldistortnode.h"
namespace olive {
const QString SwirlDistortNode::kTextureInput = QStringLiteral("tex_in");
const QString SwirlDistortNode::kRadiusInput = QStringLiteral("radius_in");
const QString SwirlDistortNode::kAngleInput = QStringLiteral("angle_in");
const QString SwirlDistortNode::kPositionInput = QStringLiteral("pos_in");
#define super Node
SwirlDistortNode::SwirlDistortNode()
{
AddInput(kTextureInput, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
AddInput(kRadiusInput, NodeValue::kFloat, 200);
SetInputProperty(kRadiusInput, QStringLiteral("min"), 0);
AddInput(kAngleInput, NodeValue::kFloat, 10);
SetInputProperty(kAngleInput, QStringLiteral("base"), 0.1);
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0));
SetFlags(kVideoEffect);
SetEffectInput(kTextureInput);
gizmo_ = AddDraggableGizmo<PointGizmo>({
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0),
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1),
});
gizmo_->SetShape(PointGizmo::kAnchorPoint);
}
QString SwirlDistortNode::Name() const
{
return tr("Swirl");
}
QString SwirlDistortNode::id() const
{
return QStringLiteral("org.oliveeditor.Olive.swirl");
}
QVector<Node::CategoryID> SwirlDistortNode::Category() const
{
return {kCategoryDistort};
}
QString SwirlDistortNode::Description() const
{
return tr("Distorts an image along a sine wave.");
}
void SwirlDistortNode::Retranslate()
{
super::Retranslate();
SetInputName(kTextureInput, tr("Input"));
SetInputName(kRadiusInput, tr("Radius"));
SetInputName(kAngleInput, tr("Angle"));
SetInputName(kPositionInput, tr("Position"));
}
ShaderCode SwirlDistortNode::GetShaderCode(const ShaderRequest &request) const
{
Q_UNUSED(request)
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/swirl.frag"));
}
void SwirlDistortNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
{
ShaderJob job;
job.Insert(value);
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
// If there's no texture, no need to run an operation
if (job.Get(kTextureInput).toTexture()) {
// Only run shader if at least one of flip or flop are selected
if (!qIsNull(job.Get(kAngleInput).toDouble()) && !qIsNull(job.Get(kRadiusInput).toDouble())) {
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
} else {
// If we're not flipping or flopping just push the texture
table->Push(job.Get(kTextureInput));
}
}
}
void SwirlDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const NodeGlobals &globals)
{
QPointF half_res(globals.resolution_by_par().x()/2, globals.resolution_by_par().y()/2);
gizmo_->SetPoint(half_res + row[kPositionInput].toVec2().toPointF());
}
void SwirlDistortNode::GizmoDragMove(double x, double y, const Qt::KeyboardModifiers &modifiers)
{
NodeInputDragger &x_drag = gizmo_->GetDraggers()[0];
NodeInputDragger &y_drag = gizmo_->GetDraggers()[1];
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
}
}
+64
View File
@@ -0,0 +1,64 @@
/***
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/>.
***/
#ifndef SWIRLDISTORTNODE_H
#define 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 GetShaderCode(const ShaderRequest &request) const override;
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
virtual void UpdateGizmoPositions(const NodeValueRow &row, const NodeGlobals &globals) override;
static const QString kTextureInput;
static const QString kRadiusInput;
static const QString kAngleInput;
static const QString kPositionInput;
protected slots:
virtual void GizmoDragMove(double x, double y, const Qt::KeyboardModifiers &modifiers) override;
private:
PointGizmo *gizmo_;
};
}
#endif // SWIRLDISTORTNODE_H
+22
View File
@@ -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
)
+165
View File
@@ -0,0 +1,165 @@
/***
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/>.
***/
#include "tiledistortnode.h"
#include "widget/slider/floatslider.h"
namespace olive {
const QString TileDistortNode::kTextureInput = QStringLiteral("tex_in");
const QString TileDistortNode::kScaleInput = QStringLiteral("scale_in");
const QString TileDistortNode::kPositionInput = QStringLiteral("position_in");
const QString TileDistortNode::kAnchorInput = QStringLiteral("anchor_in");
const QString TileDistortNode::kMirrorXInput = QStringLiteral("mirrorx_in");
const QString TileDistortNode::kMirrorYInput = QStringLiteral("mirrory_in");
#define super Node
TileDistortNode::TileDistortNode()
{
AddInput(kTextureInput, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
AddInput(kScaleInput, NodeValue::kFloat, 0.5);
SetInputProperty(kScaleInput, QStringLiteral("min"), 0);
SetInputProperty(kScaleInput, QStringLiteral("view"), FloatSlider::kPercentage);
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0));
AddInput(kAnchorInput, NodeValue::kCombo, kMiddleCenter);
AddInput(kMirrorXInput, NodeValue::kBoolean, false);
AddInput(kMirrorYInput, NodeValue::kBoolean, false);
SetFlags(kVideoEffect);
SetEffectInput(kTextureInput);
gizmo_ = AddDraggableGizmo<PointGizmo>({
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0),
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1),
});
gizmo_->SetShape(PointGizmo::kAnchorPoint);
}
QString TileDistortNode::Name() const
{
return tr("Tile");
}
QString TileDistortNode::id() const
{
return QStringLiteral("org.oliveeditor.Olive.tile");
}
QVector<Node::CategoryID> TileDistortNode::Category() const
{
return {kCategoryDistort};
}
QString TileDistortNode::Description() const
{
return tr("Infinitely tile an image horizontally and vertically.");
}
void TileDistortNode::Retranslate()
{
super::Retranslate();
SetInputName(kTextureInput, tr("Input"));
SetInputName(kScaleInput, tr("Scale"));
SetInputName(kPositionInput, tr("Position"));
SetInputName(kMirrorXInput, tr("Mirror Horizontally"));
SetInputName(kMirrorYInput, tr("Mirror Vertically"));
SetInputName(kAnchorInput, tr("Anchor"));
SetComboBoxStrings(kAnchorInput, {
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::GetShaderCode(const ShaderRequest &request) const
{
Q_UNUSED(request)
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/tile.frag"));
}
void TileDistortNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
{
ShaderJob job;
job.Insert(value);
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
// If there's no texture, no need to run an operation
if (job.Get(kTextureInput).toTexture()) {
// Only run shader if at least one of flip or flop are selected
if (!qFuzzyCompare(job.Get(kScaleInput).toDouble(), 1.0)) {
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
} else {
// If we're not flipping or flopping just push the texture
table->Push(job.Get(kTextureInput));
}
}
}
void TileDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const NodeGlobals &globals)
{
QPointF res = globals.resolution_by_par().toPointF();
QPointF pos = row[kPositionInput].toVec2().toPointF();
qreal x = pos.x();
qreal y = pos.y();
Anchor a = static_cast<Anchor>(row[kAnchorInput].toInt());
if (a == kTopLeft || a == kTopCenter || a == kTopRight) {
// Do nothing
} else if (a == kMiddleLeft || a == kMiddleCenter || a == kMiddleRight) {
y += res.y()/2;
} else if (a == kBottomLeft || a == kBottomCenter || a == kBottomRight) {
y += res.y();
}
if (a == kTopLeft || a == kMiddleLeft || a == kBottomLeft) {
// Do nothing
} else if (a == kTopCenter || a == kMiddleCenter || a == kBottomCenter) {
x += res.x()/2;
} else if (a == kTopRight || a == kMiddleRight || a == kBottomRight) {
x += res.x();
}
gizmo_->SetPoint(QPointF(x, y));
}
void TileDistortNode::GizmoDragMove(double x, double y, const Qt::KeyboardModifiers &modifiers)
{
NodeInputDragger &x_drag = gizmo_->GetDraggers()[0];
NodeInputDragger &y_drag = gizmo_->GetDraggers()[1];
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
}
}
+78
View File
@@ -0,0 +1,78 @@
/***
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/>.
***/
#ifndef TILEDISTORTNODE_H
#define 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 GetShaderCode(const ShaderRequest &request) const override;
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
virtual void UpdateGizmoPositions(const NodeValueRow &row, const NodeGlobals &globals) override;
static const QString kTextureInput;
static const QString kScaleInput;
static const QString kPositionInput;
static const QString kAnchorInput;
static const QString kMirrorXInput;
static const QString kMirrorYInput;
protected slots:
virtual void GizmoDragMove(double x, double y, const Qt::KeyboardModifiers &modifiers) override;
private:
enum Anchor {
kTopLeft,
kTopCenter,
kTopRight,
kMiddleLeft,
kMiddleCenter,
kMiddleRight,
kBottomLeft,
kBottomCenter,
kBottomRight
};
PointGizmo *gizmo_;
};
}
#endif // TILEDISTORTNODE_H
+22
View File
@@ -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
)
+104
View File
@@ -0,0 +1,104 @@
/***
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/>.
***/
#include "wavedistortnode.h"
namespace olive {
const QString WaveDistortNode::kTextureInput = QStringLiteral("tex_in");
const QString WaveDistortNode::kFrequencyInput = QStringLiteral("frequency_in");
const QString WaveDistortNode::kIntensityInput = QStringLiteral("intensity_in");
const QString WaveDistortNode::kEvolutionInput = QStringLiteral("evolution_in");
const QString WaveDistortNode::kVerticalInput = QStringLiteral("vertical_in");
#define super Node
WaveDistortNode::WaveDistortNode()
{
AddInput(kTextureInput, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
AddInput(kFrequencyInput, NodeValue::kFloat, 10);
AddInput(kIntensityInput, NodeValue::kFloat, 10);
AddInput(kEvolutionInput, NodeValue::kFloat, 0);
AddInput(kVerticalInput, NodeValue::kCombo, false);
SetFlags(kVideoEffect);
SetEffectInput(kTextureInput);
}
QString WaveDistortNode::Name() const
{
return tr("Wave");
}
QString WaveDistortNode::id() const
{
return QStringLiteral("org.oliveeditor.Olive.wave");
}
QVector<Node::CategoryID> WaveDistortNode::Category() const
{
return {kCategoryDistort};
}
QString WaveDistortNode::Description() const
{
return tr("Distorts an image along a sine wave.");
}
void WaveDistortNode::Retranslate()
{
super::Retranslate();
SetInputName(kTextureInput, tr("Input"));
SetInputName(kFrequencyInput, tr("Frequency"));
SetInputName(kIntensityInput, tr("Intensity"));
SetInputName(kEvolutionInput, tr("Evolution"));
SetInputName(kVerticalInput, tr("Direction"));
SetComboBoxStrings(kVerticalInput, {tr("Horizontal"), tr("Vertical")});
}
ShaderCode WaveDistortNode::GetShaderCode(const ShaderRequest &request) const
{
Q_UNUSED(request)
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/wave.frag"));
}
void WaveDistortNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
{
ShaderJob job;
job.Insert(value);
// If there's no texture, no need to run an operation
if (job.Get(kTextureInput).toTexture()) {
// Only run shader if at least one of flip or flop are selected
if (!qIsNull(job.Get(kIntensityInput).toDouble())) {
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
} else {
// If we're not flipping or flopping just push the texture
table->Push(job.Get(kTextureInput));
}
}
}
}
+56
View File
@@ -0,0 +1,56 @@
/***
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/>.
***/
#ifndef WAVEDISTORTNODE_H
#define 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 GetShaderCode(const ShaderRequest &request) const override;
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
static const QString kTextureInput;
static const QString kFrequencyInput;
static const QString kIntensityInput;
static const QString kEvolutionInput;
static const QString kVerticalInput;
};
}
#endif // WAVEDISTORTNODE_H
+12
View File
@@ -35,7 +35,11 @@
#include "distort/crop/cropdistortnode.h"
#include "distort/flip/flipdistortnode.h"
#include "distort/mask/mask.h"
#include "distort/ripple/rippledistortnode.h"
#include "distort/swirl/swirldistortnode.h"
#include "distort/tile/tiledistortnode.h"
#include "distort/transform/transformdistortnode.h"
#include "distort/wave/wavedistortnode.h"
#include "effect/opacity/opacityeffect.h"
#include "filter/blur/blur.h"
#include "filter/dropshadow/dropshadowfilter.h"
@@ -294,6 +298,14 @@ Node *NodeFactory::CreateFromFactoryIndex(const NodeFactory::InternalID &id)
return new DropShadowFilter();
case kTimeFormat:
return new TimeFormatNode();
case kWaveDistort:
return new WaveDistortNode();
case kTileDistort:
return new TileDistortNode();
case kSwirlDistort:
return new SwirlDistortNode();
case kRippleDistort:
return new RippleDistortNode();
case kInternalNodeCount:
break;
+4
View File
@@ -76,6 +76,10 @@ public:
kMaskDistort,
kDropShadowFilter,
kTimeFormat,
kWaveDistort,
kRippleDistort,
kTileDistort,
kSwirlDistort,
// Count value
kInternalNodeCount