Noise node (#1848)
* Add a noise generator node * Cleanup * Correctly name CMakeLists.txt * Typo
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "distort/transform/transformdistortnode.h"
|
||||
#include "effect/opacity/opacityeffect.h"
|
||||
#include "generator/matrix/matrix.h"
|
||||
#include "generator/noise/noise.h"
|
||||
#include "generator/polygon/polygon.h"
|
||||
#include "generator/shape/shapenode.h"
|
||||
#include "generator/solid/solid.h"
|
||||
@@ -255,6 +256,8 @@ Node *NodeFactory::CreateFromFactoryIndex(const NodeFactory::InternalID &id)
|
||||
return new NodeGroup();
|
||||
case kOpacityEffect:
|
||||
return new OpacityEffect();
|
||||
case kNoiseGenerator:
|
||||
return new NoiseGeneratorNode();
|
||||
|
||||
case kInternalNodeCount:
|
||||
break;
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
kShapeGenerator,
|
||||
kGroupNode,
|
||||
kOpacityEffect,
|
||||
kNoiseGenerator,
|
||||
|
||||
// Count value
|
||||
kInternalNodeCount
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
add_subdirectory(matrix)
|
||||
add_subdirectory(noise)
|
||||
add_subdirectory(polygon)
|
||||
add_subdirectory(shape)
|
||||
add_subdirectory(solid)
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/generator/noise/noise.h
|
||||
node/generator/noise/noise.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,82 @@
|
||||
/***
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "noise.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
const QString NoiseGeneratorNode::kColorInput = QStringLiteral("color_in");
|
||||
const QString NoiseGeneratorNode::kStrengthInput = QStringLiteral("strength_in");
|
||||
|
||||
NoiseGeneratorNode::NoiseGeneratorNode()
|
||||
{
|
||||
AddInput(kStrengthInput, NodeValue::kFloat, 20);
|
||||
|
||||
AddInput(kColorInput, NodeValue::kBoolean, false);
|
||||
}
|
||||
|
||||
Node* NoiseGeneratorNode::copy() const
|
||||
{
|
||||
return new NoiseGeneratorNode();
|
||||
}
|
||||
|
||||
QString NoiseGeneratorNode::Name() const
|
||||
{
|
||||
return tr("Noise");
|
||||
}
|
||||
|
||||
QString NoiseGeneratorNode::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.noise");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> NoiseGeneratorNode::Category() const
|
||||
{
|
||||
return {kCategoryGenerator};
|
||||
}
|
||||
|
||||
QString NoiseGeneratorNode::Description() const
|
||||
{
|
||||
return tr("Generates noise patterns");
|
||||
}
|
||||
|
||||
void NoiseGeneratorNode::Retranslate()
|
||||
{
|
||||
SetInputName(kStrengthInput, tr("Strength"));
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
}
|
||||
|
||||
ShaderCode NoiseGeneratorNode::GetShaderCode(const QString& shader_id) const {
|
||||
Q_UNUSED(shader_id)
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/noise.frag"));
|
||||
}
|
||||
|
||||
void NoiseGeneratorNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job;
|
||||
|
||||
job.InsertValue(value);
|
||||
job.InsertValue(QStringLiteral("time_in"), NodeValue(NodeValue::kFloat, globals.time().in().toDouble(), this));
|
||||
|
||||
|
||||
table->Push(NodeValue::kShaderJob, QVariant::fromValue(job), this);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/***
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NOISEGENERATORNODE_H
|
||||
#define NOISEGENERATORNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class NoiseGeneratorNode : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
NoiseGeneratorNode();
|
||||
|
||||
NODE_DEFAULT_DESTRUCTOR(NoiseGeneratorNode)
|
||||
|
||||
virtual Node *copy() const override;
|
||||
|
||||
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 QString &shader_id) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override;
|
||||
|
||||
static const QString kColorInput;
|
||||
static const QString kStrengthInput;
|
||||
};
|
||||
|
||||
} // namespace olive
|
||||
|
||||
#endif // NOISEGENERATORNODE_H
|
||||
Reference in New Issue
Block a user