implemented drop shadow node

This commit is contained in:
itsmattkc
2022-05-15 11:06:23 -07:00
parent 8853665187
commit 7493395103
9 changed files with 312 additions and 23 deletions
+9 -6
View File
@@ -37,6 +37,10 @@
#include "distort/mask/mask.h"
#include "distort/transform/transformdistortnode.h"
#include "effect/opacity/opacityeffect.h"
#include "filter/blur/blur.h"
#include "filter/dropshadow/dropshadowfilter.h"
#include "filter/mosaic/mosaicfilternode.h"
#include "filter/stroke/stroke.h"
#include "generator/matrix/matrix.h"
#include "generator/noise/noise.h"
#include "generator/polygon/polygon.h"
@@ -45,17 +49,14 @@
#include "generator/text/textv1.h"
#include "generator/text/textv2.h"
#include "generator/text/textv3.h"
#include "filter/blur/blur.h"
#include "filter/mosaic/mosaicfilternode.h"
#include "filter/stroke/stroke.h"
#include "input/time/timeinput.h"
#include "input/value/valuenode.h"
#include "keying/chromakey/chromakey.h"
#include "keying/colordifferencekey/colordifferencekey.h"
#include "keying/despill/despill.h"
#include "math/math/math.h"
#include "math/merge/merge.h"
#include "math/trigonometry/trigonometry.h"
#include "keying/colordifferencekey/colordifferencekey.h"
#include "keying/despill/despill.h"
#include "keying/chromakey/chromakey.h"
#include "output/track/track.h"
#include "output/viewer/viewer.h"
#include "project/folder/folder.h"
@@ -288,6 +289,8 @@ Node *NodeFactory::CreateFromFactoryIndex(const NodeFactory::InternalID &id)
return new ChromaKeyNode();
case kMaskDistort:
return new MaskDistortNode();
case kDropShadowFilter:
return new DropShadowFilter();
case kInternalNodeCount:
break;
+1
View File
@@ -74,6 +74,7 @@ public:
kOCIOGradingTransformLinear,
kChromaKey,
kMaskDistort,
kDropShadowFilter,
// Count value
kInternalNodeCount
+1
View File
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
add_subdirectory(blur)
add_subdirectory(dropshadow)
add_subdirectory(mosaic)
add_subdirectory(stroke)
+8 -8
View File
@@ -119,15 +119,15 @@ ShaderCode BlurFilterNode::GetShaderCode(const ShaderRequest &request) const
void BlurFilterNode::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));
Method method = static_cast<Method>(job.Get(kMethodInput).toInt());
// If there's no texture, no need to run an operation
if (job.Get(kTextureInput).toTexture()) {
if (value[kTextureInput].toTexture()) {
ShaderJob job;
job.Insert(value);
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
Method method = static_cast<Method>(job.Get(kMethodInput).toInt());
bool can_push_job = true;
+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/filter/dropshadow/dropshadowfilter.h
node/filter/dropshadow/dropshadowfilter.cpp
PARENT_SCOPE
)
@@ -0,0 +1,98 @@
/***
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 "dropshadowfilter.h"
#include "widget/slider/floatslider.h"
namespace olive {
#define super Node
const QString DropShadowFilter::kTextureInput = QStringLiteral("tex_in");
const QString DropShadowFilter::kColorInput = QStringLiteral("color_in");
const QString DropShadowFilter::kDistanceInput = QStringLiteral("distance_in");
const QString DropShadowFilter::kAngleInput = QStringLiteral("angle_in");
const QString DropShadowFilter::kSoftnessInput = QStringLiteral("radius_in");
const QString DropShadowFilter::kOpacityInput = QStringLiteral("opacity_in");
const QString DropShadowFilter::kFastInput = QStringLiteral("fast_in");
DropShadowFilter::DropShadowFilter()
{
AddInput(kTextureInput, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
AddInput(kColorInput, NodeValue::kColor, QVariant::fromValue(Color(0.0, 0.0, 0.0)));
AddInput(kDistanceInput, NodeValue::kFloat, 10.0);
AddInput(kAngleInput, NodeValue::kFloat, 135.0);
AddInput(kSoftnessInput, NodeValue::kFloat, 10.0);
SetInputProperty(kSoftnessInput, QStringLiteral("min"), 0.0);
AddInput(kOpacityInput, NodeValue::kFloat, 1.0);
SetInputProperty(kOpacityInput, QStringLiteral("min"), 0.0);
SetInputProperty(kOpacityInput, QStringLiteral("view"), FloatSlider::kPercentage);
AddInput(kFastInput, NodeValue::kBoolean, false);
SetEffectInput(kTextureInput);
SetFlags(kVideoEffect);
}
void DropShadowFilter::Retranslate()
{
super::Retranslate();
SetInputName(kTextureInput, tr("Texture"));
SetInputName(kColorInput, tr("Color"));
SetInputName(kDistanceInput, tr("Distance"));
SetInputName(kAngleInput, tr("Angle"));
SetInputName(kSoftnessInput, tr("Softness"));
SetInputName(kOpacityInput, tr("Opacity"));
SetInputName(kFastInput, tr("Faster (Lower Quality)"));
}
ShaderCode DropShadowFilter::GetShaderCode(const ShaderRequest &request) const
{
Q_UNUSED(request)
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/dropshadow.frag"));
}
void DropShadowFilter::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
{
if (value[kTextureInput].toTexture()) {
ShaderJob job;
QString iterative = QStringLiteral("previous_iteration_in");
job.Insert(value);
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
job.Insert(iterative, value[kTextureInput]);
if (!qIsNull(value[kSoftnessInput].toDouble())) {
job.SetIterations(3, iterative);
}
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
}
}
}
@@ -0,0 +1,58 @@
/***
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 DROPSHADOWFILTER_H
#define DROPSHADOWFILTER_H
#include "node/node.h"
namespace olive {
class DropShadowFilter : public Node
{
Q_OBJECT
public:
DropShadowFilter();
NODE_DEFAULT_FUNCTIONS(DropShadowFilter)
virtual QString Name() const override { return tr("Drop Shadow"); }
virtual QString id() const override { return QStringLiteral("org.olivevideoeditor.Olive.dropshadow"); }
virtual QVector<CategoryID> Category() const override { return {kCategoryFilter}; }
virtual QString Description() const override { return tr("Adds a drop shadow to an image."); }
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 kColorInput;
static const QString kDistanceInput;
static const QString kAngleInput;
static const QString kSoftnessInput;
static const QString kOpacityInput;
static const QString kFastInput;
};
}
#endif // DROPSHADOWFILTER_H