Swizzle Node

Hi All

I’ve created a patch for a Swizzle node. This is for GN and Shader node editors.

I’d be interested to get some feedback from the community.

Patch: Blender Archive - developer.blender.org

Patch builds: Blender Builds - blender.org
(Usual warning about test and alpha builds.)

This provides the ability to switch and keyframe xyzw/rgba channels.

The node is in the Utilities/Converter menu.

Color and Vector modes.

Since GN supports RGBA data, the Alpha input is not used.

Dynamic labels (not on current build)
image

12 Likes

does this works as a shuffle in nuke switching info among channels?

(Ximput) “toY” “toZ” “toW”
“toX” “Yimput” “toZ” “toW”
etc
etc
etc

Is it different from separate XYZ > combine XYZ? besides being faster to setup

never mind just read the commit in developer.blender.org :stuck_out_tongue: i should started reading there

You could use it to shuffle I guess, I’m not familiar with that functionality.
It is like a joined separate combine node but you can also keyframe the channels.

1 Like

I have no prior knowledge of this kind of thing, so bear in mind. But two questions.

  1. Can there be a button to make positive values to negative (and vice versa)? Is it out of scope for this function? Will it make the node unwieldy? Yes, I’m asking this because of OpenGL/DX normal thing.
  2. How about compositor nodes?

Hoover your mouse over the field with values and simply press the “-” key.
This changes positive to negative values and vice versa.

3 Likes

Added option for Negate and Invert channels. (Not in builds yet)
image

Compositor nodes is a possibility but let’s see where this goes first. It may not be accepted.

7 Likes

I’d love to have an actual matrix dot product, not only for GN and Shader nodes, but also for Compositing. Do you know if there’s a proposal for it? And maybe even a type for holding matrices

I know it’s been discussed but no one has worked on it afaik.
There is a related task here for rotations. ⚓ T92967 Add rotation attributes and node sockets

1 Like

In my eyes, doing any sort of arithmetic operation on the components is no longer swizzling and out of scope of the node. IMHO doing arithmetic on components should be in it’s own node. E.g. a vector math node with checkboxes for each component or something like that.

5 Likes

The ops are limited to what’s useful when manipulating vector/color channels. This was based on the comment for flipping and swizzling normals etc. I’d agree that anything more than this is out of scope.

For me most useful case is euler rotation reverse.
It includes not only swizzle and reflection, but reverse order rotation too (ZYX).
So it will be awesome to implement swizzle inside euler rotation too.

Now we only have XYZ or this:

Sometimes I need to swap channels when I painted masks to wrong vertex colors. For example blush to blue and shades to red. But it is easier to read blush as red and shades as blue.

1 Like

As much as I think the swizzle node is amazing, it can be easily replicated. I made this setup in 2 mins and in a way it’s even more powerful since you can multiply every axis, although UI wise it’s not as clean.

2 Likes

Lots of nodes can be replicated. The point is that you do not have to create a node group to have that functionality. (Plus a cleaner UI too)

6 Likes

Yeah of course no doubt, it’s just that the user lacks some options to customize their node trees and create drop down menus or radio buttons (such as the swizzle node offer). I heard that Blender plans to implement some built-in node groups in their future updates so maybe this should get tackled in a smarter way IMHO :smile:

2 Likes

So this means that all arithmetic operations must conform upon only one idiom in order to have cohesive design. Which is good in terms of architecture to avoid confusion.

So in order to redefine what this node does is not about swizzling, but is more of a “converter”. As for example currently you might have implicit conversions at some given cases, such as RGB can be easily interpreted as XYZ in many cases since they have both have values ranging from 0…1.

This is a one-to-one conversion where the RGB sequence is the same as XYZ.

However in order to recapture the point of what the node of @Charlie does, is more like a more advanced converter, that allows lots of manual and explicit customization.

As @costavojik said, that you can create various node setups, but in some cases where you need to cut down the amount of setups, you would actually go for a very multifunctional and advanced converter node.

As for example supporting swizzling (123 -> 321), ranges (0..1 -> 0..255), or custom patterns with text input (ABC --> AA BB CC || AA AB AC BA BB BC CA CB CC || ...).

Let us see how this goes and we will thing more use cases.

1 Like

@Vyach here is a patch for inverting Euler rotations using the Euler Rotate node
https://developer.blender.org/D16217

1 Like

that’s just kicking the trash down the road: now you’d have to justify that some vector operations get these checkboxes. and at that point you might also lament that the boxes are not available on all vector operations, and therefore decide to add these to the swizzle node too – just for consistency