Adding The Missing Vector Math Node Operations

The set of operations the Vector Math node supports is only a subset of those the scalar Math node supports.
This means that if for many component wise operations that aren’t supported by the Vector Math we have to separate the vector into it’s x,y and z components, then do the operations on each component separately, then recombine them again, which is way too much of an hassle to do just some component wise math.

I therefore plan to make the missing operations available for vector math as well.
For that there seem to be 2 possible sensible solutions to me:

  1. Add the missing operations directly to the Vector Math node.
    This is the obvious solution and is also easy to implement.
    The main drawback of that solution is that it could lead to visual clutter as the Vector Math node would then support all scalar component wise operations on top of those that are exclusive to the Vector Math node like e.g. Cross Product.

  2. Alternatively the scalar Math node could be made to also support vector inputs like what the Mix node does. The component wise vector math would then only be supported by the scalar Math node with the Vector Math node only doing actual exclusive vector math operations.
    UI wise this is probably the more elegant solution, but is harder to implement.
    The main issue is that for backward compatibility we’d need to somehow make Blender convert the Vector Math nodes with component wise math operations into the scalar Math node with the corresponding component wise math operation.

Personally I prefer the 2nd solution, but I’d probably need some input to make the backward compatibility work.

On a side note I also plan to add a Vector Math node to the compositor, which makes the 2nd solution even better as it would take care of that as well.

2 Likes

@brecht @jacqueslucke @OmarEmaraDev I’ll probably have you three review the corresponding PR again, so any feedback would be highly appreciated.

In the nodes and physics module we’ve been talking about making these math nodes type agnostic, and possibly separating operations to separate nodes.

After that, there would still be vector-only nodes, but they would just do things like dot products and cross products that you can’t do with scalar values.

We haven’t had the time to work on this yet, but I do think it’s the best way forward.

2 Likes

So you say there is no need to do what I plan?

Are there any dates on when you’d start that change?

I would show you the task, but now it is at the stage when it needs to be thought up and written down :sweat_smile:

There are no dates, it mainly depends on how it relates to other priorities, and also design questions like whether we need automatic type deduction first (I’d say no, currently).

If you’re interested in working on something like that, that would be awesome!

I’d love to do that… If I had the knowledge required for that.

The thing is if there aren’t any concrete plans to do anything it may not be such a bad idea to add the operations now. As opposed to wait until the math nodes are made type agnostic, as that may be months, or possibly years away from happening.

Isn’t Jacques also in the nodes and physics module? Let’s see what he has to say to this…

Part of the process is making the plans concrete. The reason we haven’t done that is that we wouldn’t have time to work on it yet anyway. We have avoided adding nodes like “Integer Math” in the past for the same reason.

I understand that, but I’m not sure what to do with this information. From my experience if a Blender proposal isn’t turned into something concrete within the first 3 months it takes a veeery long time for it to be implemented if at all.
I remember seeing something like what you’ve described more than half a year ago (though I can’t find it right now), without ever having heard from it again, which is the main reason I’m skeptical about the possibility of an agnostic math node coming anytime soon.

But now knowing that there are at least plans to replace the current math nodes, I’d probably just add a few fundamental operations like power or floor as temporary solution and call it a day.

Actually I had a look at it again, I’d say the only operations that are really missing are power and logarithm, so I’ll just add those and hope that the aforementioned long term plans actually get implemented.

2 Likes

In the original attributes math node that was made before fields, the attribute math node did scalar math ops on vector data. This is also how the compositor math node works.

My opinion is there is no major downside to add these functions now because any design to replace this in a nice way across all node systems is going to take some time to materialize. Having 40 ops or 45 ops in the math node is not going to make too much difference to replace.

Regarding time, my original patch for Integer Math was Jan 2022, which highlights the time already passed without a solid proposal or design.

Anyway, I don’t want to come across too negative or moany, I’ve provided patches and hope that the team reconsider adding these nodes again.

Can this energy be channeled in the right direction?
Make a plan-table, split all operations according to the types available to them. Group them into maximally solid nodes. And submit for consideration.
Table of mathematical types and their operations for unification

At least that’s how I see the solution.

2 Likes

@HooglyBoogly So with

In the nodes and physics module we’ve been talking about making these math nodes type agnostic, and possibly separating operations to separate nodes.

Do you mean that just for geometry nodes or for shader and compositor nodes as well?

We would change all node systems. This sort of node should be exactly the same between them to facilitate reusing node groups between node editors.

Update: I have decided to abandon this proposal for now in favor of working on Merging the Musgrave Texture and Noise Texture nodes.

Since the nodes and physics module team already has plans to make the math nodes agnostic any changes I make would only be temporary anyways.

This is not to say that I’ll definitely not come back to it if they take too long. But for the time being I won’t be making any changes to the vector math node.