nodes: allow two texture inputs in opacity

This commit is contained in:
itsmattkc
2022-10-23 20:23:48 -07:00
parent 93f88042d1
commit fc56058e8a
2 changed files with 37 additions and 3 deletions
+10 -3
View File
@@ -39,15 +39,22 @@ void OpacityEffect::Retranslate()
ShaderCode OpacityEffect::GetShaderCode(const ShaderRequest &request) const
{
Q_UNUSED(request)
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/opacity.frag"));
if (request.id == QStringLiteral("rgbmult")) {
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/opacity_rgb.frag"));
} else {
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/opacity.frag"));
}
}
void OpacityEffect::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
{
// If there's no texture, no need to run an operation
if (TexturePtr tex = value[kTextureInput].toTexture()) {
if (!qFuzzyCompare(value[kValueInput].toDouble(), 1.0)) {
if (TexturePtr opacity_tex = value[kValueInput].toTexture()) {
ShaderJob job(value);
job.SetShaderID(QStringLiteral("rgbmult"));
table->Push(NodeValue::kTexture, tex->toJob(job), this);
} else if (!qFuzzyCompare(value[kValueInput].toDouble(), 1.0)) {
table->Push(NodeValue::kTexture, tex->toJob(ShaderJob(value)), this);
} else {
// 1.0 float is a no-op, so just push the texture