Skip to content
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

More general Math node #315

Open
RunDevelopment opened this issue May 22, 2022 · 4 comments
Open

More general Math node #315

RunDevelopment opened this issue May 22, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@RunDevelopment
Copy link
Member

Right now, the Math node is very limiting. It only supports a small selection of binary operations, and even simple formulas are difficult to implement.

Add a Math node with a variable number of inputs that produces one output.

The formula itself is input using a simple text field. The input numbers are simply labeled lowercase a-z. A formula could look like this: sqrt(a ** 2 + b ** 2) * c / 100

@joeyballentine
Copy link
Member

Variable number of inputs is something not possible right now. But yeah, something like this would be cool.

Though, I'm not really sure what use case it would be for. Really all the math node is needed for right now is taking fractions of an image's size and stuff like that

@RunDevelopment
Copy link
Member Author

Variable number of inputs is something not possible right now.

It's possible using a little trick. We don't actually need to support variable number of inputs, it just has to look like we do. We could just have a large-enough fixed number of inputs (e.g. 10) and hide all inputs except for the first one by default. If the user that "adds" new inputs, we just show them the next hidden one.

Hacky, yes, but functional.

Though, I'm not really sure what use case it would be for.

We have a bunch of nodes with number inputs, all of which can benefit from a powerful Math node.

Even the simplest Math node (one that just returns a constant number) is useful because it allows you to control multiple connected values at once.

@joeyballentine
Copy link
Member

That's actually a pretty genius hack. We could use that for all the variable input nodes, like image stack. Just do a [ImageInput(label=f"Image {i}") for i in range(100))] and then have configurable option for whether it's variable or not, which we'd set to true (and probably have a starting index option), and then it would handle that on the frontend.

@joeyballentine joeyballentine added the enhancement New feature or request label Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants