groups: improved functionality
Various improvements and fixes to groups
This commit is contained in:
@@ -5,7 +5,10 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
#define super NodeGroup
|
||||
#define super Node
|
||||
|
||||
const QString OpacityEffect::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString OpacityEffect::kValueInput = QStringLiteral("opacity_in");
|
||||
|
||||
OpacityEffect::OpacityEffect()
|
||||
{
|
||||
@@ -15,24 +18,44 @@ OpacityEffect::OpacityEffect()
|
||||
|
||||
SetNodePositionInContext(math, QPointF(0, 0));
|
||||
|
||||
tex_in_pass_ = AddInputPassthrough(NodeInput(math, MathNode::kParamAIn), InputFlags(kInputFlagNotKeyframable));
|
||||
SetInputDataType(tex_in_pass_, NodeValue::kTexture);
|
||||
AddInput(kTextureInput, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
|
||||
|
||||
value_in_pass_ = AddInputPassthrough(NodeInput(math, MathNode::kParamBIn));
|
||||
SetInputProperty(value_in_pass_, QStringLiteral("view"), FloatSlider::kPercentage);
|
||||
SetInputProperty(value_in_pass_, QStringLiteral("min"), 0.0);
|
||||
SetInputProperty(value_in_pass_, QStringLiteral("max"), 1.0);
|
||||
math->SetStandardValue(MathNode::kParamBIn, 1.0);
|
||||
|
||||
SetOutputPassthrough(math);
|
||||
AddInput(kValueInput, NodeValue::kFloat, 1.0);
|
||||
SetInputProperty(kValueInput, QStringLiteral("view"), FloatSlider::kPercentage);
|
||||
SetInputProperty(kValueInput, QStringLiteral("min"), 0.0);
|
||||
SetInputProperty(kValueInput, QStringLiteral("max"), 1.0);
|
||||
}
|
||||
|
||||
void OpacityEffect::Retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
|
||||
SetInputName(tex_in_pass_, tr("Texture"));
|
||||
SetInputName(value_in_pass_, tr("Opacity"));
|
||||
SetInputName(kTextureInput, tr("Texture"));
|
||||
SetInputName(kValueInput, tr("Opacity"));
|
||||
}
|
||||
|
||||
ShaderCode OpacityEffect::GetShaderCode(const QString &shader_id) const
|
||||
{
|
||||
Q_UNUSED(shader_id)
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/opacity.frag"));
|
||||
}
|
||||
|
||||
void OpacityEffect::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job;
|
||||
|
||||
job.InsertValue(value);
|
||||
|
||||
// If there's no texture, no need to run an operation
|
||||
if (!job.GetValue(kTextureInput).data().isNull()) {
|
||||
if (!qFuzzyCompare(job.GetValue(kValueInput).data().toDouble(), 1.0)) {
|
||||
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
|
||||
table->Push(NodeValue::kShaderJob, QVariant::fromValue(job), this);
|
||||
} else {
|
||||
// 1.0 float is a no-op, so just push the texture
|
||||
table->Push(job.GetValue(kTextureInput));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user