From fb625cb76ecb919674f71f02c44a722f80b320e7 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 6 May 2020 15:06:37 +1000 Subject: [PATCH] nodes: removed XML infrastructure --- app/codec/oiio/oiiodecoder.cpp | 7 +- app/node/CMakeLists.txt | 5 +- app/node/block/transition/CMakeLists.txt | 2 - .../block/transition/externaltransition.cpp | 93 ---- app/node/external.cpp | 95 ----- app/node/factory.cpp | 21 +- app/node/factory.h | 4 + app/node/filter/CMakeLists.txt | 23 + app/node/filter/blur/CMakeLists.txt | 22 + app/node/filter/blur/blur.cpp | 104 +++++ .../blur/blur.h} | 30 +- app/node/filter/stroke/CMakeLists.txt | 22 + app/node/filter/stroke/stroke.cpp | 95 +++++ .../{external.h => filter/stroke/stroke.h} | 33 +- app/node/generator/CMakeLists.txt | 1 + app/node/generator/solid/CMakeLists.txt | 22 + app/node/generator/solid/solid.cpp | 76 ++++ app/node/generator/solid/solid.h | 52 +++ app/node/math/CMakeLists.txt | 1 + app/node/math/merge/CMakeLists.txt | 22 + app/node/math/merge/merge.cpp | 85 ++++ app/node/math/merge/merge.h | 57 +++ app/node/metareader.cpp | 398 ------------------ app/node/metareader.h | 92 ---- app/node/output/track/tracklist.cpp | 7 +- app/shaders/CMakeLists.txt | 10 +- app/shaders/alphaover.xml | 24 -- app/shaders/blur.xml | 70 --- app/shaders/crossdissolve.xml | 16 - app/shaders/diptoblack.xml | 16 - app/shaders/dropshadow.frag | 62 --- app/shaders/dropshadow.xml | 64 --- app/shaders/shaders.qrc | 22 - app/shaders/shaders.qrc.in | 5 + app/shaders/solid.xml | 31 -- app/shaders/stroke.frag | 7 +- app/shaders/stroke.xml | 55 --- 37 files changed, 661 insertions(+), 1090 deletions(-) delete mode 100644 app/node/block/transition/externaltransition.cpp delete mode 100644 app/node/external.cpp create mode 100644 app/node/filter/CMakeLists.txt create mode 100644 app/node/filter/blur/CMakeLists.txt create mode 100644 app/node/filter/blur/blur.cpp rename app/node/{block/transition/externaltransition.h => filter/blur/blur.h} (76%) create mode 100644 app/node/filter/stroke/CMakeLists.txt create mode 100644 app/node/filter/stroke/stroke.cpp rename app/node/{external.h => filter/stroke/stroke.h} (68%) create mode 100644 app/node/generator/solid/CMakeLists.txt create mode 100644 app/node/generator/solid/solid.cpp create mode 100644 app/node/generator/solid/solid.h create mode 100644 app/node/math/merge/CMakeLists.txt create mode 100644 app/node/math/merge/merge.cpp create mode 100644 app/node/math/merge/merge.h delete mode 100644 app/node/metareader.cpp delete mode 100644 app/node/metareader.h delete mode 100644 app/shaders/alphaover.xml delete mode 100644 app/shaders/blur.xml delete mode 100644 app/shaders/crossdissolve.xml delete mode 100644 app/shaders/diptoblack.xml delete mode 100644 app/shaders/dropshadow.frag delete mode 100644 app/shaders/dropshadow.xml delete mode 100644 app/shaders/shaders.qrc create mode 100644 app/shaders/shaders.qrc.in delete mode 100644 app/shaders/solid.xml delete mode 100644 app/shaders/stroke.xml diff --git a/app/codec/oiio/oiiodecoder.cpp b/app/codec/oiio/oiiodecoder.cpp index 27e02991f..1f2b136b3 100644 --- a/app/codec/oiio/oiiodecoder.cpp +++ b/app/codec/oiio/oiiodecoder.cpp @@ -174,9 +174,10 @@ FramePtr OIIODecoder::RetrieveVideo(const rational &timecode, const int& divider FramePtr frame = Frame::Create(); - frame->set_video_params(VideoRenderingParams(buffer_->spec().width / divider, - buffer_->spec().height / divider, - pix_fmt_)); + frame->set_video_params(VideoRenderingParams(buffer_->spec().width, + buffer_->spec().height, + pix_fmt_, + divider)); frame->allocate(); if (divider == 1) { diff --git a/app/node/CMakeLists.txt b/app/node/CMakeLists.txt index 965982241..8930b3979 100644 --- a/app/node/CMakeLists.txt +++ b/app/node/CMakeLists.txt @@ -16,6 +16,7 @@ add_subdirectory(audio) add_subdirectory(block) +add_subdirectory(filter) add_subdirectory(generator) add_subdirectory(input) add_subdirectory(math) @@ -27,8 +28,6 @@ set(OLIVE_SOURCES node/dependency.cpp node/edge.h node/edge.cpp - node/external.h - node/external.cpp node/factory.h node/factory.cpp node/graph.h @@ -39,8 +38,6 @@ set(OLIVE_SOURCES node/inputarray.cpp node/keyframe.h node/keyframe.cpp - node/metareader.h - node/metareader.cpp node/node.h node/node.cpp node/output.h diff --git a/app/node/block/transition/CMakeLists.txt b/app/node/block/transition/CMakeLists.txt index 0ca1160b9..65f672588 100644 --- a/app/node/block/transition/CMakeLists.txt +++ b/app/node/block/transition/CMakeLists.txt @@ -16,8 +16,6 @@ set(OLIVE_SOURCES ${OLIVE_SOURCES} - node/block/transition/externaltransition.h - node/block/transition/externaltransition.cpp node/block/transition/transition.h node/block/transition/transition.cpp PARENT_SCOPE diff --git a/app/node/block/transition/externaltransition.cpp b/app/node/block/transition/externaltransition.cpp deleted file mode 100644 index 798ae5b74..000000000 --- a/app/node/block/transition/externaltransition.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2019 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 "externaltransition.h" - -OLIVE_NAMESPACE_ENTER - -ExternalTransition::ExternalTransition(const QString &xml_meta_filename) : - meta_(xml_meta_filename) -{ - foreach (NodeInput* input, meta_.inputs()) { - AddInput(input); - } -} - -Node *ExternalTransition::copy() const -{ - return new ExternalTransition(meta_.filename()); -} - -QString ExternalTransition::Name() const -{ - return meta_.Name(); -} - -QString ExternalTransition::ShortName() const -{ - return meta_.ShortName(); -} - -QString ExternalTransition::id() const -{ - return meta_.id(); -} - -QList ExternalTransition::Category() const -{ - return meta_.Category(); -} - -QString ExternalTransition::Description() const -{ - return meta_.Description(); -} - -void ExternalTransition::Retranslate() -{ - meta_.Retranslate(); -} - -Node::Capabilities ExternalTransition::GetCapabilities(const NodeValueDatabase &) const -{ - return kShader; -} - -QString ExternalTransition::ShaderVertexCode(const NodeValueDatabase &) const -{ - return meta_.vert_code(); -} - -QString ExternalTransition::ShaderFragmentCode(const NodeValueDatabase&) const -{ - return meta_.frag_code(); -} - -int ExternalTransition::ShaderIterations() const -{ - return meta_.iterations(); -} - -NodeInput *ExternalTransition::ShaderIterativeInput() const -{ - return meta_.iteration_input(); -} - -OLIVE_NAMESPACE_EXIT diff --git a/app/node/external.cpp b/app/node/external.cpp deleted file mode 100644 index eddcf43be..000000000 --- a/app/node/external.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2019 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 "external.h" - -#include - -OLIVE_NAMESPACE_ENTER - -ExternalNode::ExternalNode(const QString &xml_meta_filename) : - meta_(xml_meta_filename) -{ - foreach (NodeInput* input, meta_.inputs()) { - AddInput(input); - } -} - -Node *ExternalNode::copy() const -{ - return new ExternalNode(meta_.filename()); -} - -QString ExternalNode::Name() const -{ - return meta_.Name(); -} - -QString ExternalNode::ShortName() const -{ - return meta_.ShortName(); -} - -QString ExternalNode::id() const -{ - return meta_.id(); -} - -QList ExternalNode::Category() const -{ - return meta_.Category(); -} - -QString ExternalNode::Description() const -{ - return meta_.Description(); -} - -void ExternalNode::Retranslate() -{ - meta_.Retranslate(); -} - -Node::Capabilities ExternalNode::GetCapabilities(const NodeValueDatabase &) const -{ - return kShader; -} - -QString ExternalNode::ShaderVertexCode(const NodeValueDatabase&) const -{ - return meta_.vert_code(); -} - -QString ExternalNode::ShaderFragmentCode(const NodeValueDatabase&) const -{ - return meta_.frag_code(); -} - -int ExternalNode::ShaderIterations() const -{ - return meta_.iterations(); -} - -NodeInput *ExternalNode::ShaderIterativeInput() const -{ - return meta_.iteration_input(); -} - -OLIVE_NAMESPACE_EXIT diff --git a/app/node/factory.cpp b/app/node/factory.cpp index fe7361389..32846849a 100644 --- a/app/node/factory.cpp +++ b/app/node/factory.cpp @@ -24,16 +24,18 @@ #include "audio/volume/volume.h" #include "block/clip/clip.h" #include "block/gap/gap.h" -#include "block/transition/externaltransition.h" #include "generator/matrix/matrix.h" +#include "generator/solid/solid.h" +#include "filter/blur/blur.h" +#include "filter/stroke/stroke.h" #include "input/media/video/video.h" #include "input/media/audio/audio.h" #include "input/time/timeinput.h" #include "math/math/math.h" +#include "math/merge/merge.h" #include "math/trigonometry/trigonometry.h" #include "output/track/track.h" #include "output/viewer/viewer.h" -#include "external.h" OLIVE_NAMESPACE_ENTER QList NodeFactory::library_; @@ -47,13 +49,10 @@ void NodeFactory::Initialize() library_.append(CreateInternal(static_cast(i))); } - library_.append(new ExternalNode(":/shaders/blur.xml")); - library_.append(new ExternalNode(":/shaders/solid.xml")); - library_.append(new ExternalNode(":/shaders/stroke.xml")); - library_.append(new ExternalNode(":/shaders/alphaover.xml")); - library_.append(new ExternalNode(":/shaders/dropshadow.xml")); + /* library_.append(new ExternalTransition(":/shaders/crossdissolve.xml")); library_.append(new ExternalTransition(":/shaders/diptoblack.xml")); + */ } void NodeFactory::Destroy() @@ -152,6 +151,14 @@ Node *NodeFactory::CreateInternal(const NodeFactory::InternalID &id) return new TrigonometryNode(); case kTime: return new TimeInput(); + case kBlurFilter: + return new BlurFilterNode(); + case kSolidGenerator: + return new SolidGenerator(); + case kMerge: + return new MergeNode(); + case kStrokeFilter: + return new StrokeFilterNode(); case kInternalNodeCount: break; diff --git a/app/node/factory.h b/app/node/factory.h index c6329de7e..1068d103c 100644 --- a/app/node/factory.h +++ b/app/node/factory.h @@ -44,6 +44,10 @@ public: kMath, kTime, kTrigonometry, + kBlurFilter, + kSolidGenerator, + kMerge, + kStrokeFilter, // Count value kInternalNodeCount diff --git a/app/node/filter/CMakeLists.txt b/app/node/filter/CMakeLists.txt new file mode 100644 index 000000000..4d7db901d --- /dev/null +++ b/app/node/filter/CMakeLists.txt @@ -0,0 +1,23 @@ +# Olive - Non-Linear Video Editor +# Copyright (C) 2019 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 . + +add_subdirectory(blur) +add_subdirectory(stroke) + +set(OLIVE_SOURCES + ${OLIVE_SOURCES} + PARENT_SCOPE +) diff --git a/app/node/filter/blur/CMakeLists.txt b/app/node/filter/blur/CMakeLists.txt new file mode 100644 index 000000000..50bd90ad5 --- /dev/null +++ b/app/node/filter/blur/CMakeLists.txt @@ -0,0 +1,22 @@ +# Olive - Non-Linear Video Editor +# Copyright (C) 2019 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/filter/blur/blur.h + node/filter/blur/blur.cpp + PARENT_SCOPE +) diff --git a/app/node/filter/blur/blur.cpp b/app/node/filter/blur/blur.cpp new file mode 100644 index 000000000..64d634d0c --- /dev/null +++ b/app/node/filter/blur/blur.cpp @@ -0,0 +1,104 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 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 "blur.h" + +OLIVE_NAMESPACE_ENTER + +BlurFilterNode::BlurFilterNode() +{ + texture_input_ = new NodeInput("tex_in", NodeParam::kTexture); + AddInput(texture_input_); + + method_input_ = new NodeInput("method_in", NodeParam::kCombo, 0); + AddInput(method_input_); + + radius_input_ = new NodeInput("radius_in", NodeParam::kFloat, 10.0f); + radius_input_->set_property(QStringLiteral("min"), 0.0f); + AddInput(radius_input_); + + horiz_input_ = new NodeInput("horiz_in", NodeParam::kBoolean, true); + AddInput(horiz_input_); + + vert_input_ = new NodeInput("vert_in", NodeParam::kBoolean, true); + AddInput(vert_input_); + + repeat_edge_pixels_input_ = new NodeInput("repeat_edge_pixels_in", NodeParam::kBoolean, false); + AddInput(repeat_edge_pixels_input_); +} + +Node *BlurFilterNode::copy() const +{ + return new BlurFilterNode(); +} + +QString BlurFilterNode::Name() const +{ + return tr("Blur"); +} + +QString BlurFilterNode::id() const +{ + return QStringLiteral("org.olivevideoeditor.Olive.blur"); +} + +QList BlurFilterNode::Category() const +{ + return {kCategoryFilter}; +} + +QString BlurFilterNode::Description() const +{ + return tr("Blurs an image."); +} + +void BlurFilterNode::Retranslate() +{ + texture_input_->set_name(tr("Input")); + method_input_->set_name(tr("Method")); + method_input_->set_combobox_strings({ tr("Box"), tr("Gaussian") }); + radius_input_->set_name(tr("Radius")); + horiz_input_->set_name(tr("Horizontal")); + vert_input_->set_name(tr("Vertical")); + repeat_edge_pixels_input_->set_name(tr("Repeat Edge Pixels")); +} + +Node::Capabilities BlurFilterNode::GetCapabilities(const NodeValueDatabase &) const +{ + return kShader; +} + +QString BlurFilterNode::ShaderFragmentCode(const NodeValueDatabase &) const +{ + return ReadFileAsString(":/shaders/blur.frag"); +} + +int BlurFilterNode::ShaderIterations() const +{ + // FIXME: Optimize if horiz_in or vert_in is disabled + return 2; +} + +NodeInput *BlurFilterNode::ShaderIterativeInput() const +{ + return texture_input_; +} + +OLIVE_NAMESPACE_EXIT diff --git a/app/node/block/transition/externaltransition.h b/app/node/filter/blur/blur.h similarity index 76% rename from app/node/block/transition/externaltransition.h rename to app/node/filter/blur/blur.h index 5962ecf9d..142f03985 100644 --- a/app/node/block/transition/externaltransition.h +++ b/app/node/filter/blur/blur.h @@ -18,24 +18,21 @@ ***/ -#ifndef EXTERNALTRANSITION_H -#define EXTERNALTRANSITION_H +#ifndef BLURFILTERNODE_H +#define BLURFILTERNODE_H -#include "transition.h" - -#include "node/metareader.h" +#include "node/node.h" OLIVE_NAMESPACE_ENTER -class ExternalTransition : public TransitionBlock +class BlurFilterNode : public Node { public: - ExternalTransition(const QString& xml_meta_filename); + BlurFilterNode(); virtual Node* copy() const override; virtual QString Name() const override; - virtual QString ShortName() const override; virtual QString id() const override; virtual QList Category() const override; virtual QString Description() const override; @@ -43,15 +40,26 @@ public: virtual void Retranslate() override; virtual Capabilities GetCapabilities(const NodeValueDatabase&) const override; - virtual QString ShaderVertexCode(const NodeValueDatabase&) const override; virtual QString ShaderFragmentCode(const NodeValueDatabase&) const override; + virtual int ShaderIterations() const override; virtual NodeInput* ShaderIterativeInput() const override; private: - NodeMetaReader meta_; + NodeInput* texture_input_; + + NodeInput* method_input_; + + NodeInput* radius_input_; + + NodeInput* horiz_input_; + + NodeInput* vert_input_; + + NodeInput* repeat_edge_pixels_input_; + }; OLIVE_NAMESPACE_EXIT -#endif // EXTERNALTRANSITION_H +#endif // BLURFILTERNODE_H diff --git a/app/node/filter/stroke/CMakeLists.txt b/app/node/filter/stroke/CMakeLists.txt new file mode 100644 index 000000000..212f3bfe2 --- /dev/null +++ b/app/node/filter/stroke/CMakeLists.txt @@ -0,0 +1,22 @@ +# Olive - Non-Linear Video Editor +# Copyright (C) 2019 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/filter/stroke/stroke.h + node/filter/stroke/stroke.cpp + PARENT_SCOPE +) diff --git a/app/node/filter/stroke/stroke.cpp b/app/node/filter/stroke/stroke.cpp new file mode 100644 index 000000000..e87449db2 --- /dev/null +++ b/app/node/filter/stroke/stroke.cpp @@ -0,0 +1,95 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 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 "stroke.h" + +#include "render/color.h" + +OLIVE_NAMESPACE_ENTER + +StrokeFilterNode::StrokeFilterNode() +{ + tex_input_ = new NodeInput("tex_in", NodeParam::kTexture); + AddInput(tex_input_); + + color_input_ = new NodeInput("color_in", + NodeParam::kColor, + QVariant::fromValue(Color(1.0f, 1.0f, 1.0f, 1.0f))); + AddInput(color_input_); + + radius_input_ = new NodeInput("radius_in", NodeParam::kFloat, 10.0f); + radius_input_->set_property("min", 0.0f); + AddInput(radius_input_); + + opacity_input_ = new NodeInput("opacity_in", NodeParam::kFloat, 1.0f); + opacity_input_->set_property("view", "percent"); + opacity_input_->set_property("min", 0.0f); + opacity_input_->set_property("max", 1.0f); + AddInput(opacity_input_); + + inner_input_ = new NodeInput("inner_in", NodeParam::kBoolean, false); + AddInput(inner_input_); +} + +Node *StrokeFilterNode::copy() const +{ + return new StrokeFilterNode(); +} + +QString StrokeFilterNode::Name() const +{ + return tr("Stroke"); +} + +QString StrokeFilterNode::id() const +{ + return QStringLiteral("org.olivevideoeditor.Olive.stroke"); +} + +QList StrokeFilterNode::Category() const +{ + return {kCategoryFilter}; +} + +QString StrokeFilterNode::Description() const +{ + return tr("Creates a stroke outline around an image."); +} + +void StrokeFilterNode::Retranslate() +{ + tex_input_->set_name(tr("Input")); + color_input_->set_name(tr("Color")); + radius_input_->set_name(tr("Radius")); + opacity_input_->set_name(tr("Opacity")); + inner_input_->set_name(tr("Inner")); +} + +Node::Capabilities StrokeFilterNode::GetCapabilities(const NodeValueDatabase &) const +{ + return kShader; +} + +QString StrokeFilterNode::ShaderFragmentCode(const NodeValueDatabase &) const +{ + return ReadFileAsString(":/shaders/stroke.frag"); +} + +OLIVE_NAMESPACE_EXIT diff --git a/app/node/external.h b/app/node/filter/stroke/stroke.h similarity index 68% rename from app/node/external.h rename to app/node/filter/stroke/stroke.h index 046539534..06eb97f64 100644 --- a/app/node/external.h +++ b/app/node/filter/stroke/stroke.h @@ -18,28 +18,21 @@ ***/ -#ifndef EXTERNALNODE_H -#define EXTERNALNODE_H +#ifndef STROKEFILTERNODE_H +#define STROKEFILTERNODE_H -#include - -#include "node.h" -#include "metareader.h" +#include "node/node.h" OLIVE_NAMESPACE_ENTER -/** - * @brief A node generated from an external XML metadata file - */ -class ExternalNode : public Node +class StrokeFilterNode : public Node { public: - ExternalNode(const QString& xml_meta_filename); + StrokeFilterNode(); virtual Node* copy() const override; virtual QString Name() const override; - virtual QString ShortName() const override; virtual QString id() const override; virtual QList Category() const override; virtual QString Description() const override; @@ -47,15 +40,21 @@ public: virtual void Retranslate() override; virtual Capabilities GetCapabilities(const NodeValueDatabase&) const override; - virtual QString ShaderVertexCode(const NodeValueDatabase&) const override; virtual QString ShaderFragmentCode(const NodeValueDatabase&) const override; - virtual int ShaderIterations() const override; - virtual NodeInput* ShaderIterativeInput() const override; private: - NodeMetaReader meta_; + NodeInput* tex_input_; + + NodeInput* color_input_; + + NodeInput* radius_input_; + + NodeInput* opacity_input_; + + NodeInput* inner_input_; + }; OLIVE_NAMESPACE_EXIT -#endif // EXTERNALNODE_H +#endif // STROKEFILTERNODE_H diff --git a/app/node/generator/CMakeLists.txt b/app/node/generator/CMakeLists.txt index 9e8d25261..21566cbeb 100644 --- a/app/node/generator/CMakeLists.txt +++ b/app/node/generator/CMakeLists.txt @@ -15,6 +15,7 @@ # along with this program. If not, see . add_subdirectory(matrix) +add_subdirectory(solid) set(OLIVE_SOURCES ${OLIVE_SOURCES} diff --git a/app/node/generator/solid/CMakeLists.txt b/app/node/generator/solid/CMakeLists.txt new file mode 100644 index 000000000..df388a97d --- /dev/null +++ b/app/node/generator/solid/CMakeLists.txt @@ -0,0 +1,22 @@ +# Olive - Non-Linear Video Editor +# Copyright (C) 2019 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/generator/solid/solid.h + node/generator/solid/solid.cpp + PARENT_SCOPE +) diff --git a/app/node/generator/solid/solid.cpp b/app/node/generator/solid/solid.cpp new file mode 100644 index 000000000..d2ef7fd74 --- /dev/null +++ b/app/node/generator/solid/solid.cpp @@ -0,0 +1,76 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 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 "solid.h" + +#include "render/color.h" + +OLIVE_NAMESPACE_ENTER + +SolidGenerator::SolidGenerator() +{ + // Default to a color that isn't black + color_input_ = new NodeInput("color_in", + NodeInput::kColor, + QVariant::fromValue(Color(1.0f, 0.0f, 0.0f, 1.0f))); + AddInput(color_input_); +} + +Node *SolidGenerator::copy() const +{ + return new SolidGenerator(); +} + +QString SolidGenerator::Name() const +{ + return tr("Solid"); +} + +QString SolidGenerator::id() const +{ + return QStringLiteral("org.olivevideoeditor.Olive.solidgenerator"); +} + +QList SolidGenerator::Category() const +{ + return {kCategoryGenerator}; +} + +QString SolidGenerator::Description() const +{ + return tr("Generate a solid color."); +} + +void SolidGenerator::Retranslate() +{ + color_input_->set_name(tr("Color")); +} + +Node::Capabilities SolidGenerator::GetCapabilities(const NodeValueDatabase &) const +{ + return kShader; +} + +QString SolidGenerator::ShaderFragmentCode(const NodeValueDatabase &) const +{ + return ReadFileAsString(":/shaders/solid.frag"); +} + +OLIVE_NAMESPACE_EXIT diff --git a/app/node/generator/solid/solid.h b/app/node/generator/solid/solid.h new file mode 100644 index 000000000..8e5433e69 --- /dev/null +++ b/app/node/generator/solid/solid.h @@ -0,0 +1,52 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 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 SOLIDGENERATOR_H +#define SOLIDGENERATOR_H + +#include "node/node.h" + +OLIVE_NAMESPACE_ENTER + +class SolidGenerator : public Node +{ +public: + SolidGenerator(); + + virtual Node* copy() const override; + + virtual QString Name() const override; + virtual QString id() const override; + virtual QList Category() const override; + virtual QString Description() const override; + + virtual void Retranslate() override; + + virtual Capabilities GetCapabilities(const NodeValueDatabase&) const override; + virtual QString ShaderFragmentCode(const NodeValueDatabase&) const override; + +private: + NodeInput* color_input_; + +}; + +OLIVE_NAMESPACE_EXIT + +#endif // SOLIDGENERATOR_H diff --git a/app/node/math/CMakeLists.txt b/app/node/math/CMakeLists.txt index 1ae06847e..32ad7e923 100644 --- a/app/node/math/CMakeLists.txt +++ b/app/node/math/CMakeLists.txt @@ -15,6 +15,7 @@ # along with this program. If not, see . add_subdirectory(math) +add_subdirectory(merge) add_subdirectory(trigonometry) set(OLIVE_SOURCES diff --git a/app/node/math/merge/CMakeLists.txt b/app/node/math/merge/CMakeLists.txt new file mode 100644 index 000000000..a7472ded0 --- /dev/null +++ b/app/node/math/merge/CMakeLists.txt @@ -0,0 +1,22 @@ +# Olive - Non-Linear Video Editor +# Copyright (C) 2019 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/math/merge/merge.h + node/math/merge/merge.cpp + PARENT_SCOPE +) diff --git a/app/node/math/merge/merge.cpp b/app/node/math/merge/merge.cpp new file mode 100644 index 000000000..d154aa8b2 --- /dev/null +++ b/app/node/math/merge/merge.cpp @@ -0,0 +1,85 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 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 "merge.h" + +OLIVE_NAMESPACE_ENTER + +MergeNode::MergeNode() +{ + base_in_ = new NodeInput("base_in", NodeParam::kTexture); + AddInput(base_in_); + + blend_in_ = new NodeInput("blend_in", NodeParam::kTexture); + AddInput(blend_in_); +} + +Node *MergeNode::copy() const +{ + return new MergeNode(); +} + +QString MergeNode::Name() const +{ + return tr("Merge"); +} + +QString MergeNode::id() const +{ + return QStringLiteral("org.olivevideoeditor.Olive.merge"); +} + +QList MergeNode::Category() const +{ + return {kCategoryMath}; +} + +QString MergeNode::Description() const +{ + return tr("Merge two textures together."); +} + +void MergeNode::Retranslate() +{ + base_in_->set_name(tr("Base")); + blend_in_->set_name(tr("Blend")); +} + +Node::Capabilities MergeNode::GetCapabilities(const NodeValueDatabase &) const +{ + return kShader; +} + +QString MergeNode::ShaderFragmentCode(const NodeValueDatabase &) const +{ + return ReadFileAsString(":/shaders/alphaover.frag"); +} + +NodeInput *MergeNode::base_in() const +{ + return base_in_; +} + +NodeInput *MergeNode::blend_in() const +{ + return blend_in_; +} + +OLIVE_NAMESPACE_EXIT diff --git a/app/node/math/merge/merge.h b/app/node/math/merge/merge.h new file mode 100644 index 000000000..fda931a8e --- /dev/null +++ b/app/node/math/merge/merge.h @@ -0,0 +1,57 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 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 MERGENODE_H +#define MERGENODE_H + +#include "node/node.h" + +OLIVE_NAMESPACE_ENTER + +class MergeNode : public Node +{ +public: + MergeNode(); + + virtual Node* copy() const override; + + virtual QString Name() const override; + virtual QString id() const override; + virtual QList Category() const override; + virtual QString Description() const override; + + virtual void Retranslate() override; + + virtual Capabilities GetCapabilities(const NodeValueDatabase&) const override; + virtual QString ShaderFragmentCode(const NodeValueDatabase&) const override; + + NodeInput* base_in() const; + NodeInput* blend_in() const; + +private: + NodeInput* base_in_; + + NodeInput* blend_in_; + +}; + +OLIVE_NAMESPACE_EXIT + +#endif // MERGENODE_H diff --git a/app/node/metareader.cpp b/app/node/metareader.cpp deleted file mode 100644 index e09386df4..000000000 --- a/app/node/metareader.cpp +++ /dev/null @@ -1,398 +0,0 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2019 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 "metareader.h" - -#include - -#include "common/xmlutils.h" -#include "config/config.h" -#include "node.h" - -OLIVE_NAMESPACE_ENTER - -NodeMetaReader::NodeMetaReader(const QString &xml_meta_filename) : - xml_filename_(xml_meta_filename), - iterations_(1), - iteration_input_(nullptr) -{ - QFile metadata_file(xml_filename_); - - if (metadata_file.open(QFile::ReadOnly)) { - QXmlStreamReader reader(&metadata_file); - - while (XMLReadNextStartElement(&reader)) { - if (reader.name() == QStringLiteral("effect")) { - XMLReadEffect(&reader); - } else { - reader.skipCurrentElement(); - } - } - - metadata_file.close(); - } else { - qWarning() << "Failed to load node metadata file" << xml_filename_; - } -} - -QString NodeMetaReader::Name() const -{ - return GetStringForCurrentLanguage(&names_); -} - -QString NodeMetaReader::ShortName() const -{ - if (short_names_.isEmpty()) { - return Name(); - } else { - return GetStringForCurrentLanguage(&short_names_); - } -} - -const QString &NodeMetaReader::id() const -{ - return id_; -} - -QList NodeMetaReader::Category() const -{ - return categories_; -} - -QString NodeMetaReader::Description() const -{ - return GetStringForCurrentLanguage(&descriptions_); -} - -const QString &NodeMetaReader::filename() const -{ - return xml_filename_; -} - -const QString &NodeMetaReader::frag_code() const -{ - return frag_code_; -} - -const QString &NodeMetaReader::vert_code() const -{ - return vert_code_; -} - -const int &NodeMetaReader::iterations() const -{ - return iterations_; -} - -NodeInput *NodeMetaReader::iteration_input() const -{ - return iteration_input_; -} - -const QList &NodeMetaReader::inputs() const -{ - return inputs_; -} - -void NodeMetaReader::Retranslate() -{ - { - // Re-translate every parameter name - QMap::const_iterator iterator; - - // Iterate through parameter language tables that we have - for (iterator=param_names_.begin();iterator!=param_names_.end();iterator++) { - NodeInput* this_input = GetInputWithID(iterator.key()); - this_input->set_name(GetStringForCurrentLanguage(&iterator.value())); - } - } - - { - // Re-translate any combobox items - QMap >::const_iterator param_it; - - for (param_it=combo_names_.begin(); param_it!=combo_names_.end(); param_it++) { - NodeInput* input = GetInputWithID(param_it.key()); - - QStringList combo_items; - - foreach (const LanguageMap& lang_map, param_it.value()) { - combo_items.append(GetStringForCurrentLanguage(&lang_map)); - } - - input->set_combobox_strings(combo_items); - } - } -} - -void NodeMetaReader::XMLReadLanguageString(QXmlStreamReader* reader, LanguageMap* map) -{ - QString lang; - - // Traverse through name attributes for its language - XMLAttributeLoop(reader, attr) { - if (attr.name() == QStringLiteral("lang")) { - lang = attr.value().toString(); - - // We don't recognize any other "name" attributes at this time - break; - } - } - - // Insert name with language into map - map->insert(lang, reader->readElementText().trimmed()); -} - -void NodeMetaReader::XMLReadEffect(QXmlStreamReader* reader) -{ - // Traverse through effect attributes for an ID - XMLAttributeLoop(reader, attr) { - if (attr.name() == QStringLiteral("id")) { - id_ = attr.value().toString(); - - // We don't recognize any other "effect" attributes at this time - break; - } - } - - if (id_.isEmpty()) { - qWarning() << "Effect metadata" << xml_filename_ << "has no ID"; - return; - } - - // Continue reading for other metadata - while (XMLReadNextStartElement(reader)) { - if (reader->name() == QStringLiteral("name")) { - // Pick up name - XMLReadLanguageString(reader, &names_); - } else if (reader->name() == QStringLiteral("shortnames")) { - // Pick up short name - XMLReadLanguageString(reader, &short_names_); - } else if (reader->name() == QStringLiteral("category")) { - // Pick up category - QStringList category_ids = reader->readElementText().split(':'); - - foreach (const QString& id, category_ids) { - bool ok; - - int try_parse = id.toInt(&ok); - - if (!ok || try_parse < 0 || try_parse >= Node::kCategoryCount) { - continue; - } - - categories_.append(static_cast(try_parse)); - } - } else if (reader->name() == QStringLiteral("description")) { - // Pick up description - XMLReadLanguageString(reader, &descriptions_); - } else if (reader->name() == QStringLiteral("iterations")) { - // Pick up iterations - XMLReadIterations(reader); - } else if (reader->name() == QStringLiteral("fragment")) { - // Pick up fragment shader code - XMLReadShader(reader, frag_code_); - } else if (reader->name() == QStringLiteral("vertex")) { - // Pick up vertex shader code - XMLReadShader(reader, vert_code_); - } else if (reader->name() == QStringLiteral("param")) { - // Pick up a parameter - XMLReadParam(reader); - } else { - reader->skipCurrentElement(); - } - } -} - -void NodeMetaReader::XMLReadIterations(QXmlStreamReader* reader) -{ - int iteration_pickup = reader->readElementText().toInt(); - - if (iterations_ > 0) { - iterations_ = iteration_pickup; - } else { - // If the iteration value is invalid, don't set it, print an error instead - qWarning() << "Invalid iteration number in" << xml_filename_ << "- setting to default (1)"; - } -} - -void NodeMetaReader::XMLReadParam(QXmlStreamReader *reader) -{ - QString param_id; - NodeParam::DataType param_type = NodeParam::kAny; - bool is_iterative = false; - - // Traverse through parameter attributes for an ID - XMLAttributeLoop(reader, attr) { - if (attr.name() == QStringLiteral("id")) { - param_id = attr.value().toString(); - } else if (attr.name() == QStringLiteral("type")) { - param_type = NodeParam::StringToDataType(attr.value().toString()); - } else if (attr.name() == QStringLiteral("iterative_input")) { - is_iterative = true; - } - } - - if (param_id.isEmpty()) { - qWarning() << "Effect metadata" << xml_filename_ << "contains a parameter with no ID - parameter was not added"; - return; - } - - QVector default_val; - QHash properties; - LanguageMap param_names; - QList combo_names; - QList combo_descriptions; - - // Traverse through param contents for more data - while (XMLReadNextStartElement(reader)) { - // NOTE: readElementText() returns a string, but for number types (which min and max apply to), QVariant will - // convert them automatically - if (reader->name() == QStringLiteral("name")) { - - // Insert language into map - XMLReadLanguageString(reader, ¶m_names); - - } else if (reader->name() == QStringLiteral("default")) { - - // Reads the default value - while (XMLReadNextStartElement(reader)) { - if (reader->name() == QStringLiteral("value")) { - default_val.append(NodeInput::StringToValue(param_type, reader->readElementText())); - } else { - reader->skipCurrentElement(); - } - } - - } else if (reader->name() == QStringLiteral("option")) { - - // Read names and descriptions - LanguageMap names; - LanguageMap descriptions; - - while (XMLReadNextStartElement(reader)) { - if (reader->name() == QStringLiteral("name")) { - XMLReadLanguageString(reader, &names); - } else if (reader->name() == QStringLiteral("description")) { - XMLReadLanguageString(reader, &descriptions); - } else { - reader->skipCurrentElement(); - } - } - - combo_names.append(names); - combo_descriptions.append(descriptions); - - } else { - properties.insert(reader->name().toString(), reader->readElementText()); - } - } - - param_names_.insert(param_id, param_names); - - // Insert combo options if they exist - if (!combo_names.isEmpty()) { - combo_names_.insert(param_id, combo_names); - combo_descriptions_.insert(param_id, combo_descriptions); - } - - NodeInput* input = new NodeInput(param_id, param_type, default_val); - - QHash::const_iterator iterator; - - for (iterator=properties.begin();iterator!=properties.end();iterator++) { - input->set_property(iterator.key(), iterator.value()); - } - - if (is_iterative) { - iteration_input_ = input; - } - - inputs_.append(input); -} - -void NodeMetaReader::XMLReadShader(QXmlStreamReader *reader, QString &destination) -{ - QString code_url; - - // Traverse through parameter attributes for an ID - XMLAttributeLoop(reader, attr) { - if (attr.name() == QStringLiteral("url")) { - code_url = attr.value().toString(); - - // We don't recognize any other "shader" attributes at this time - break; - } - } - - // Add code in file from URL - if (!code_url.isEmpty()) { - destination.append(Node::ReadFileAsString(code_url)); - } - - // Add any code that's inline in the XML - QString element_text = reader->readElementText().trimmed(); - if (!element_text.isEmpty()) { - destination.append(element_text); - } -} - -QString NodeMetaReader::GetStringForCurrentLanguage(const LanguageMap *language_map) -{ - if (language_map->isEmpty()) { - // There are no entries for this map, this must be an empty string - return QString(); - } - - // Get current language config - QString language = Config::Current()[QStringLiteral("Language")].toString(); - - // See if our map has an exact language match - QString str_for_lang = language_map->value(language); - if (!str_for_lang.isEmpty()) { - return str_for_lang; - } - - // If not, try to find a match with the same language but not the same derivation - QString base_lang = language.split('_').first(); - QList available_languages = language_map->keys(); - foreach (const QString& l, available_languages) { - if (l.startsWith(base_lang)) { - // This is the same language, so we can return this - return language_map->value(l); - } - } - - // We couldn't find an exact or close match, just return the first in the list - // (assume a string in the wrong language is better than no string at all) - return language_map->first(); -} - -NodeInput *NodeMetaReader::GetInputWithID(const QString &id) const -{ - foreach (NodeInput* input, inputs_) { - if (input->id() == id) { - return input; - } - } - return nullptr; -} - -OLIVE_NAMESPACE_EXIT diff --git a/app/node/metareader.h b/app/node/metareader.h deleted file mode 100644 index 9efb6441d..000000000 --- a/app/node/metareader.h +++ /dev/null @@ -1,92 +0,0 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2019 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 NODEMETAREADER_H -#define NODEMETAREADER_H - -#include -#include -#include - -#include "input.h" -#include "node/node.h" - -OLIVE_NAMESPACE_ENTER - -class NodeMetaReader -{ -public: - NodeMetaReader(const QString& xml_meta_filename); - - QString Name() const; - QString ShortName() const; - const QString& id() const; - QList Category() const; - QString Description() const; - - const QString& filename() const; - - const QString& frag_code() const; - const QString& vert_code() const; - - const int& iterations() const; - NodeInput* iteration_input() const; - - const QList& inputs() const; - - void Retranslate(); - -private: - using LanguageMap = QMap; - - void XMLReadLanguageString(QXmlStreamReader* reader, LanguageMap *map); - void XMLReadEffect(QXmlStreamReader *reader); - void XMLReadIterations(QXmlStreamReader* reader); - void XMLReadParam(QXmlStreamReader* reader); - void XMLReadShader(QXmlStreamReader* reader, QString& destination); - - static QString GetStringForCurrentLanguage(const LanguageMap *language_map); - - NodeInput* GetInputWithID(const QString& id) const; - - QString xml_filename_; - - LanguageMap names_; - LanguageMap short_names_; - LanguageMap descriptions_; - QList categories_; - QMap param_names_; - QMap > combo_names_; - QMap > combo_descriptions_; - - QString id_; - - QString frag_code_; - QString vert_code_; - - int iterations_; - NodeInput* iteration_input_; - - QList inputs_; -}; - -OLIVE_NAMESPACE_EXIT - -#endif // NODEMETAREADER_H diff --git a/app/node/output/track/tracklist.cpp b/app/node/output/track/tracklist.cpp index 07b7678c0..6165c11fb 100644 --- a/app/node/output/track/tracklist.cpp +++ b/app/node/output/track/tracklist.cpp @@ -22,6 +22,7 @@ #include "node/factory.h" #include "node/math/math/math.h" +#include "node/math/merge/merge.h" #include "node/output/viewer/viewer.h" OLIVE_NAMESPACE_ENTER @@ -104,11 +105,11 @@ TrackOutput* TrackList::AddTrack() switch (type_) { case Timeline::kTrackTypeVideo: { - Node* blend = NodeFactory::CreateFromID(QStringLiteral("org.olivevideoeditor.Olive.alphaoverblend")); + MergeNode* blend = new MergeNode(); GetParentGraph()->AddNode(blend); - NodeParam::ConnectEdge(track->output(), static_cast(blend->GetInputWithID("blend_in"))); - NodeParam::ConnectEdge(last_track->output(), static_cast(blend->GetInputWithID("base_in"))); + NodeParam::ConnectEdge(track->output(), blend->blend_in()); + NodeParam::ConnectEdge(last_track->output(), blend->base_in()); NodeParam::ConnectEdge(blend->output(), edge->input()); break; } diff --git a/app/shaders/CMakeLists.txt b/app/shaders/CMakeLists.txt index 762945e1b..a9ad28c12 100644 --- a/app/shaders/CMakeLists.txt +++ b/app/shaders/CMakeLists.txt @@ -14,8 +14,16 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +file(GLOB_RECURSE SHADER_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.frag *.vert) +set(QRC_BODY "") +foreach(SHADER_FILE ${SHADER_RESOURCES}) + string(APPEND QRC_BODY "${SHADER_FILE}\n") + configure_file(${SHADER_FILE} ${SHADER_FILE} COPYONLY) +endforeach() +configure_file(shaders.qrc.in shaders.qrc @ONLY) + set(OLIVE_RESOURCES ${OLIVE_RESOURCES} - shaders/shaders.qrc + ${CMAKE_CURRENT_BINARY_DIR}/shaders.qrc PARENT_SCOPE ) diff --git a/app/shaders/alphaover.xml b/app/shaders/alphaover.xml deleted file mode 100644 index 0f98ea7f0..000000000 --- a/app/shaders/alphaover.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - Alpha Over - - - 3 - - - - A blending node that composites one texture over another using its alpha channel. - - - - - Base - - - Blend - - - - - diff --git a/app/shaders/blur.xml b/app/shaders/blur.xml deleted file mode 100644 index 6942d8749..000000000 --- a/app/shaders/blur.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - Blur - - - 4 - - - - Blurs an image. - - - - - Input - - - - - Method - - - - - - - Radius - 0 - - 10 - - - - - - Horizontal - - 1 - - - - - - Vertical - - 1 - - - - - - Repeat Edge Pixels - - 0 - - - - - - - - 2 - diff --git a/app/shaders/crossdissolve.xml b/app/shaders/crossdissolve.xml deleted file mode 100644 index 3338f6e86..000000000 --- a/app/shaders/crossdissolve.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - Cross Dissolve - - - - - - - A smooth fade transition from one video clip to another. - - - - - diff --git a/app/shaders/diptoblack.xml b/app/shaders/diptoblack.xml deleted file mode 100644 index 1bca1af4e..000000000 --- a/app/shaders/diptoblack.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - Dip to Black - - - - - - - A smooth dip to transparency and back into another clip. - - - - - diff --git a/app/shaders/dropshadow.frag b/app/shaders/dropshadow.frag deleted file mode 100644 index 0a35c7517..000000000 --- a/app/shaders/dropshadow.frag +++ /dev/null @@ -1,62 +0,0 @@ -#version 150 - -#define M_PI 3.1415926535897932384626433832795 - -uniform sampler2D tex_in; -uniform vec3 color_in; -uniform float softness_in; -uniform float opacity_in; -uniform float distance_in; -uniform float direction_in; - -uniform vec2 ove_resolution; - -in vec2 ove_texcoord; - -out vec4 fragColor; - -void main(void) { - // Use pythagoras with the distance (hypotenuse) to find the shadow offset - float direction_radians = direction_in * (M_PI / 180.0); - - float opposite = sin(direction_radians) * distance_in; - float adjacent = cos(direction_radians) * distance_in; - - vec2 angle = vec2(adjacent, opposite); - - // Convert distance from pixels to 0.0 - 1.0 texture coordinates - angle /= ove_resolution; - - float shadow_alpha; - - // For a soft shadow, we use a box blur-like formula - if (softness_in > 0.0) { - float radius = ceil(softness_in); - float divider = 1.0 / pow(softness_in, 2.0); - shadow_alpha = 0.0; - - for (float x = -radius + 0.5; x <= radius; x += 2.0) { - for (float y = -radius + 0.5; y <= radius; y += 2.0) { - vec2 pixel_coord = ove_texcoord - angle; - pixel_coord.x += x / ove_resolution.x; - pixel_coord.y += y / ove_resolution.y; - vec4 pixel_color = texture(tex_in, pixel_coord); - - shadow_alpha += pixel_color.a * divider; - } - } - } else { - // Perfectly hard shadow - vec4 src_color = texture(tex_in, ove_texcoord - angle); - shadow_alpha = src_color.a; - } - - vec4 shadow_px = vec4(color_in, shadow_alpha * opacity_in * 0.01); - - // Get current pixel and perform an alpha over for it over the shadow we've made - vec4 dst_color = texture(tex_in, ove_texcoord); - shadow_px *= (1.0 - dst_color.a); - shadow_px += dst_color; - - fragColor = shadow_px; -} diff --git a/app/shaders/dropshadow.xml b/app/shaders/dropshadow.xml deleted file mode 100644 index 20e77fb84..000000000 --- a/app/shaders/dropshadow.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - Drop Shadow - - - Stylize - Stylise - - - - Generate a drop shadow of a clip. - - - - - Input - - - - - Color - Colour - - - - - Softness - 0 - - 10 - - - - - - Opacity - 0 - - 80 - - 100 - - - - - Distance - 0 - - 10 - - - - - - Direction - - 45 - - - - - - diff --git a/app/shaders/shaders.qrc b/app/shaders/shaders.qrc deleted file mode 100644 index 7e6f4876c..000000000 --- a/app/shaders/shaders.qrc +++ /dev/null @@ -1,22 +0,0 @@ - - - alphaover.frag - alphaover.xml - blur.frag - blur.xml - colorgradient.frag - colorwheel.frag - crossdissolve.frag - crossdissolve.xml - dropshadow.frag - dropshadow.xml - diptoblack.frag - diptoblack.xml - rgbwaveform.frag - solid.frag - solid.xml - stroke.frag - stroke.xml - matrix.vert - - diff --git a/app/shaders/shaders.qrc.in b/app/shaders/shaders.qrc.in new file mode 100644 index 000000000..e1366f006 --- /dev/null +++ b/app/shaders/shaders.qrc.in @@ -0,0 +1,5 @@ + + + @QRC_BODY@ + + diff --git a/app/shaders/solid.xml b/app/shaders/solid.xml deleted file mode 100644 index d45fef56f..000000000 --- a/app/shaders/solid.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - Solid - - - Generator - - - - Generate a solid color. - - - Generate a solid colour. - - - - - Color - Colour - - 1.0 - 0.0 - 0.0 - 1.0 - - - - - - diff --git a/app/shaders/stroke.frag b/app/shaders/stroke.frag index 8d43b34ea..bdd7d2691 100644 --- a/app/shaders/stroke.frag +++ b/app/shaders/stroke.frag @@ -2,7 +2,7 @@ // Node parameter inputs uniform sampler2D tex_in; -uniform vec3 color_in; +uniform vec4 color_in; uniform float radius_in; uniform float opacity_in; uniform bool inner_in; @@ -61,15 +61,14 @@ void main(void) { } } - stroke_weight *= opacity_in * 0.01; + stroke_weight *= opacity_in; if (inner_in) { stroke_weight *= pixel_here.a; } // Make RGBA color - vec4 stroke_col = vec4(vec3(1.0) * stroke_weight, stroke_weight); - //vec4 stroke_col = vec4(color_in * stroke_weight, stroke_weight); + vec4 stroke_col = color_in * stroke_weight; if (inner_in) { // Alpha over the stroke over the texture diff --git a/app/shaders/stroke.xml b/app/shaders/stroke.xml deleted file mode 100644 index 1f562eef0..000000000 --- a/app/shaders/stroke.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - Stroke - - - Stylize - Stylise - - - - Creates a stroke outline around an image. - - - - - Input - - - - - Color - Colour - - - - - Radius - 0 - - 10 - - - - - - Opacity - 0 - - 100 - - 100 - - - - - Inner - - false - - - - - -