mask: add invert option
This commit is contained in:
@@ -27,12 +27,15 @@ namespace olive {
|
||||
#define super PolygonGenerator
|
||||
|
||||
const QString MaskDistortNode::kFeatherInput = QStringLiteral("feather_in");
|
||||
const QString MaskDistortNode::kInvertInput = QStringLiteral("invert_in");
|
||||
|
||||
MaskDistortNode::MaskDistortNode()
|
||||
{
|
||||
// Mask should always be (1.0, 1.0, 1.0) for multiply to work correctly
|
||||
SetInputFlags(kColorInput, InputFlags(GetInputFlags(kColorInput) | kInputFlagHidden));
|
||||
|
||||
AddInput(kInvertInput, NodeValue::kBoolean, false);
|
||||
|
||||
AddInput(kFeatherInput, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kFeatherInput, QStringLiteral("min"), 0.0);
|
||||
}
|
||||
@@ -43,6 +46,8 @@ ShaderCode MaskDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(QStringLiteral(":/shaders/multiply.frag")));
|
||||
} else if (request.id == QStringLiteral("feather")) {
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(QStringLiteral(":/shaders/blur.frag")));
|
||||
} else if (request.id == QStringLiteral("invert")) {
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(QStringLiteral(":/shaders/invertrgb.frag")));
|
||||
} else {
|
||||
return super::GetShaderCode(request);
|
||||
}
|
||||
@@ -53,12 +58,20 @@ void MaskDistortNode::Retranslate()
|
||||
super::Retranslate();
|
||||
|
||||
SetInputName(kBaseInput, tr("Texture"));
|
||||
SetInputName(kInvertInput, tr("Invert"));
|
||||
SetInputName(kFeatherInput, tr("Feather"));
|
||||
}
|
||||
|
||||
void MaskDistortNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job = GetGenerateJob(value);
|
||||
NodeValue job(NodeValue::kTexture, GetGenerateJob(value), this);
|
||||
|
||||
if (value[kInvertInput].toBool()) {
|
||||
ShaderJob invert;
|
||||
invert.SetShaderID(QStringLiteral("invert"));
|
||||
invert.Insert(QStringLiteral("tex_in"), job);
|
||||
job.set_value(invert);
|
||||
}
|
||||
|
||||
if (value[kBaseInput].toTexture()) {
|
||||
// Push as merge node
|
||||
@@ -72,7 +85,7 @@ void MaskDistortNode::Value(const NodeValueRow &value, const NodeGlobals &global
|
||||
ShaderJob feather;
|
||||
|
||||
feather.SetShaderID(QStringLiteral("feather"));
|
||||
feather.Insert(BlurFilterNode::kTextureInput, NodeValue(NodeValue::kTexture, job, this));
|
||||
feather.Insert(BlurFilterNode::kTextureInput, job);
|
||||
feather.Insert(BlurFilterNode::kMethodInput, NodeValue(NodeValue::kInt, int(BlurFilterNode::kGaussian), this));
|
||||
feather.Insert(BlurFilterNode::kHorizInput, NodeValue(NodeValue::kBoolean, true, this));
|
||||
feather.Insert(BlurFilterNode::kVertInput, NodeValue(NodeValue::kBoolean, true, this));
|
||||
@@ -83,10 +96,12 @@ void MaskDistortNode::Value(const NodeValueRow &value, const NodeGlobals &global
|
||||
|
||||
merge.Insert(QStringLiteral("tex_b"), NodeValue(NodeValue::kTexture, feather, this));
|
||||
} else {
|
||||
merge.Insert(QStringLiteral("tex_b"), NodeValue(NodeValue::kTexture, job, this));
|
||||
merge.Insert(QStringLiteral("tex_b"), job);
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kTexture, QVariant::fromValue(merge), this);
|
||||
table->Push(NodeValue::kTexture, merge, this);
|
||||
} else {
|
||||
table->Push(job);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ public:
|
||||
|
||||
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
|
||||
|
||||
static const QString kInvertInput;
|
||||
static const QString kFeatherInput;
|
||||
|
||||
};
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// Input texture
|
||||
uniform sampler2D tex_in;
|
||||
|
||||
// Input texture coordinate
|
||||
in vec2 ove_texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(tex_in, ove_texcoord);
|
||||
color.rgb = 1.0 - color.rgb;
|
||||
frag_color = color;
|
||||
}
|
||||
Reference in New Issue
Block a user