Math Expression Node for Shader Editor and Other Node Systems
Math is everywhere in procedural shaders or geometries. The ability to write compound expressions with symbols will save 90% of display space and most of the time increases readability.
Math is everywhere in procedural shaders or geometries. The ability to write compound expressions with symbols will save 90% of display space and most of the time increases readability.
12 Comments
consider it done blenderartists.org/t/nodebooster-extra-nodes-and-functionalities-for-nodeeditors/1580883
So useful ...I would be using this on a daily basis.
This is a must have.
Similar proposal : blender.community/c/rightclickselect/wKnM
@rajeshjadvani started a task for a geometry nodes version of this! developer.blender.org/D11465
I was tinkering with Sverchok lately and found its Formula Node being even much more powerful than what I proposed. It can read lists and retrieve object data. It has preserved keywords for common functions and supports conditionals. Maybe some of these features would be irrelevant for Shader Editor, but it is definitely a good reference.
A good idea. Unreal's expression node for instance simply take its name as an expression, filters all letters as variables out and automatically create inputs. Under the hood it's a script creating a corresponding node group with basic default nodes, inputs and one outputs out of the expression. Blender could do the same.
So what you are saying, is that in node form, every time a variable is made ( n, x ,y ), a corresponding socket is made. In this case, it should be able to output these same variables.
* @zorro.weaver * This can be either simple or complex. If we go the easy way, keeping it an atomic piece of math function, then all variables will be parsed as inputs and the node yields a single output.
* @zorro.weaver * I'm still not sure if it is good to make this math expression node into a full-fledged python node, multi-line, multi-purpose, and of course multi-output. Looks like it's just becoming the old Script node. But I get it that Script is only for writing OSL, which is CPU only. I really meant that we should have a non-OSL, still-nodes-under-the-hood convenient node.
* @wmysilly * So this would work something like: result =x-y/a
Another way to do this would be to make everything on the left side of the equal sign is used as an input, and everything on the right side is used as an output.
* @zorro.weaver * I have started trying to code this. My design is to take up to 3 variables A, B, and C via sockets, which could then be used in the Math Expression. You could probably also use other output variables previously defined. I'll figure it out as I make progress.
My attempt is as an Attribute Math Expression node for Geometry nodes, but once implemented should be easy to extend to other node trees.
I was just going to propose this last week but I was too busy. The fact that two people thought of this in parallel means that it is probably a good idea.