Is it possible to make an expression node? Sometimes it is so tedious hooking up nodes to do a simple expression. I realize it would be quite a bit of work to do a parser etc. but, how feasible is this idea? It wouldn’t have to replace anything, it would be more of an “advanced” node.
Last week I had a discussion with my former TD colleague Laszlo Sebo about the same idea. But what we were discussing was an expression parser that evaluates to a BlackOp. So you could say for example
Output = Position + Normal * 2.0
and it would wire a BLOP node containing a Position and a Normal inputChannel connected to an Add operator, with the Normal wired through a Multiply operator with Float InputValue with a value of 2.0.
What we don’t want to do is evaluate the expression at runtime, because it would be too slow. That’s why we don’t provide a full-fledged MAXScript node that could operate on channels, only one that can produce a value once per frame. We want to enter the expression as a shortcut to wiring, although if one would learn how to use the editor PROPERLY, he would be able to connect the flow faster than it takes to type the above
I am seriously considering this, but right now I feel that most users of MagmaFlow just don’t know how to use it right and believe typing an expression will save them time. The whole reason to use nodes is that it is easier to see what goes where. The original plan for Magma around 2007 was for it to be expression-based, and I am quite happy we decided to go the node route…
We also had a more advanced idea for creating custom nodes, but that’s on the future ToDo / Wishlist. We will see what will happen.
Why a BLOP? Seems like we’d want to type a string in (or for the meek, they can paste the string that their TD IM’d them) and have it make the nodes but not make the BLOP so we can A) see the result and verify that it’s what we want and B) add in other modulation parameters that we would need. Would be nice if you could SPECIFY a BLOP in the string, though. So you could say “SmoothStep(0.0, 10.0, abs(Position - $Teapot001))” and it would make the appropriate nodes.
I’d say 75% of the time I’m doing Magmaflow, I’m wishing I didn’t have to be using Magmaflow, but could just write a shader. It’s doing simple things like “min(x,y)” that make you notice how much clicking you do, or setting up polynomials. How much clicking is involved in making “saturate(xxx*(3x(2*x-5)+10))”? The node interface is good for debugging, but we aren’t using that, really, and it’s good for organizing experiments by allowing you to “comment out” certain sections.
I think Laszlo’s idea was to have the expression stored in its UI, and when you edit the expression, the content of the container changes to what you typed.
If you would type and it appears as nodes in the top level flow, you cannot change the expression because it isn’t stored anywhere.
A command line mode could evaluate an expression at the top level to create the flow you want.
I will leave it to Darcy to decide whether a “true” expression node is doable (one that parses the expression internally and never creates explicit nodes you can access/see/rewire with the node editor).
In fact, this is not even on the Wishlist yet, so we are discussing it in theory.
I’m pretty sure Darcy doesn’t want to work on a compiler. You’ll notice that Magmaflow doesn’t do optimizing on it’s own either.
But assuming there isn’t some low-hanging fruit here, what would be so bad about an expression node that WAS slower? If you can make the effect in 3 minutes vs 45 minutes, do you care if it takes 10 minutes longer to render? Something to consider.