-
Notifications
You must be signed in to change notification settings - Fork 196
SG-41316: Add Dissolve blend composite mode to stackIPNode with UI controls #940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,8 @@ namespace IPCore | |
|
|
||
| IntProperty* autoSizeProperty() const { return m_autoSize; } | ||
|
|
||
| // float dissolveAmount() const { return m_dissolveAmount->front(); } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Detail: Please remove if not used: we prefer not to leave any deadcode if possible unless you think it might be useful. |
||
|
|
||
| virtual void propagateFlushToInputs(const FlushContext&); | ||
|
|
||
| void invalidate(); | ||
|
|
@@ -112,6 +114,7 @@ namespace IPCore | |
| IntProperty* m_autoSize; | ||
| IntProperty* m_interactiveSize; | ||
| IntProperty* m_supportReversedOrderBlending; | ||
| FloatProperty* m_dissolveAmount; | ||
|
|
||
| private: | ||
| static std::string m_defaultCompType; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| #include <IPCore/ShaderFunction.h> | ||
| #include <IPCore/ShaderSymbol.h> | ||
| #include <IPCore/IPImage.h> | ||
| #include <IPBaseNodes/StackIPNode.h> | ||
| #include <TwkGLF/GL.h> | ||
| #include <TwkFB/Operations.h> | ||
| #include <TwkMath/MatrixColor.h> | ||
|
|
@@ -142,6 +143,7 @@ extern const char* Difference4_glsl; | |
| extern const char* ReverseDifference2_glsl; | ||
| extern const char* ReverseDifference3_glsl; | ||
| extern const char* ReverseDifference4_glsl; | ||
| extern const char* Dissolve2_glsl; | ||
| extern const char* InlineDissolve2_glsl; | ||
| extern const char* BoxFilter_glsl; | ||
| extern const char* ConstantBG_glsl; | ||
|
|
@@ -844,6 +846,30 @@ namespace IPCore | |
| funcName, shaderCode, Shader::Function::Color, params, globals); | ||
| } | ||
|
|
||
| Function* dissolveBlend(int no, const char* funcName, const char* shaderCode) | ||
| { | ||
| assert(no >= 2); | ||
| assert(no <= MAX_TEXTURE_PER_SHADER); | ||
|
|
||
| SymbolVector params, globals; | ||
|
|
||
| // Add input texture parameters (i0, i1, i2, i3) | ||
| for (int i = 0; i < no; ++i) | ||
| { | ||
| ostringstream str; | ||
| str << "i" << i; | ||
| params.push_back(new Symbol(Symbol::ParameterConstIn, str.str(), | ||
| Symbol::Vec4fType)); | ||
| } | ||
|
|
||
| // Add dissolve amount parameter | ||
| params.push_back(new Symbol(Symbol::ParameterConstIn, "dissolveAmount", | ||
| Symbol::FloatType)); | ||
|
|
||
| return new Shader::Function( | ||
| funcName, shaderCode, Shader::Function::Color, params, globals); | ||
| } | ||
|
|
||
| Function* colorQuantize() | ||
| { | ||
| if (!Shader_ColorQuantize) | ||
|
|
@@ -3036,6 +3062,7 @@ namespace IPCore | |
| const char* reverseDifferenceShaders[] = {ReverseDifference2_glsl, | ||
| ReverseDifference3_glsl, | ||
| ReverseDifference4_glsl}; | ||
| const char* dissolveShaders[] = {Dissolve2_glsl}; | ||
|
|
||
| // generate a blend expr of a certain mode | ||
| // with the input Expressions as input to the blend shaders (over, add, | ||
|
|
@@ -3080,7 +3107,6 @@ namespace IPCore | |
| F = blend(size, name, | ||
| overShaders[size - 2]); //*2_glsl is at position 0 | ||
| break; | ||
| // TODO: dissolve | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you @nigelsumner for adding the dissolve ! |
||
| } | ||
|
|
||
| ArgumentVector args(F->parameters().size()); | ||
|
|
@@ -3093,6 +3119,37 @@ namespace IPCore | |
| return new Expression(F, args, image); | ||
| } | ||
|
|
||
| // Dissolve blend function for exactly 2 inputs with dissolveAmount parameter | ||
| Expression* newDissolveBlend(const IPImage* image, | ||
| const vector<Expression*>& FA1, | ||
| const IPImage::BlendMode mode, | ||
| float dissolveAmount) | ||
| { | ||
| if (mode == IPImage::Dissolve) | ||
| { | ||
| int size = FA1.size(); | ||
| assert(size == 2); // Dissolve only works with exactly 2 inputs | ||
|
|
||
| // Create dissolve blend function for 2 inputs | ||
| Function* F = dissolveBlend(2, "main", dissolveShaders[0]); | ||
| ArgumentVector args(F->parameters().size()); | ||
|
|
||
| // Bind the 2 input expressions | ||
| args[0] = new BoundExpression(F->parameters()[0], FA1[0]); | ||
| args[1] = new BoundExpression(F->parameters()[1], FA1[1]); | ||
|
|
||
| // Bind the dissolveAmount parameter | ||
| args[2] = new BoundFloat(F->parameters()[2], dissolveAmount); | ||
|
|
||
| return new Expression(F, args, image); | ||
| } | ||
| else | ||
| { | ||
| // For non-dissolve modes, use the original function | ||
| return newBlend(image, FA1, mode); | ||
| } | ||
| } | ||
|
|
||
| Expression* newHistogram(const IPImage* image, | ||
| const std::vector<Expression*>& FA1) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // | ||
| // Copyright (C) 2023 Autodesk, Inc. All Rights Reserved. | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
| // Dissolve blend between two inputs with configurable amount | ||
|
|
||
| vec4 main(const in vec4 i0, const in vec4 i1, const in float dissolveAmount) | ||
| { | ||
| // Blend RGB channels using dissolveAmount (0.0 = all i1, 1.0 = all i0) | ||
| vec3 rgb = mix(i1.rgb, i0.rgb, dissolveAmount); | ||
|
|
||
| // Ignore input alpha channels and output solid alpha of 1.0 | ||
| float alpha = 1.0; | ||
|
|
||
| return vec4(clamp(rgb.r, 0.0, 1.0), | ||
| clamp(rgb.g, 0.0, 1.0), | ||
| clamp(rgb.b, 0.0, 1.0), | ||
| alpha); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there is a newline missing after rvnuke_mode.mu and before composite_ui.py.
Also: where are those *_ui.py files coming from ?