Page MenuHome

Geometry Nodes: Implement Vector Rotate node
ClosedPublic

Authored by Leon Schittek (lone_noel) on Feb 12 2021, 9:04 PM.
Tokens
"Love" token, awarded by damian."Like" token, awarded by higgsas."Love" token, awarded by TimBrown."Burninate" token, awarded by victorlouis.

Details

Summary

This patch makes the Vector Rotate node from the shader compatible with Geometry Nodes.

Use Case
This node allows for easy rotation of direction based attribute falloffs like linear or radial gradients either directly with the node or controlled with an empty.

Example
Linear Attribute gradient rotated by an empty:


Diff Detail

Repository
rB Blender
Branch
geometry-nodes-port-vector-rotate-node (branched from master)
Build Status
Buildable 13220
Build 13220: arc lint + arc unit

Event Timeline

Leon Schittek (lone_noel) requested review of this revision.Feb 12 2021, 9:04 PM
Leon Schittek (lone_noel) created this revision.
  • Expose Input sliders for the Vector input.
Leon Schittek (lone_noel) retitled this revision from Geometry Nodes: Implement Vector Rotate node (WIP) to Geometry Nodes: Implement Vector Rotate node.Feb 21 2021, 9:12 PM
Leon Schittek (lone_noel) edited the summary of this revision. (Show Details)

Works great for me with current master 👍

Jacques Lucke (JacquesLucke) requested changes to this revision.Mar 2 2021, 1:01 PM
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc
48

This is not valid c++ (it might compile on linux): https://godbolt.org/z/1bdxYG

Better we convert the file to c++ in a separate patch, before adding features to it.

86

Obviously, in common cases where the rotation is the same for all vectors, this is quite inefficient. This could be improved by implementing a proper multi-function (instead of using CustomMF_SI_SI_SI_SI_SO, but both approaches are fine for me for now.

This revision now requires changes to proceed.Mar 2 2021, 1:01 PM

Great that it’s working for you, @Simon Thommes (simonthommes) !
What do you think about the exposed Vector input? You’re pretty much using the node how I imagined it would be and in those cases I figured it’d be nice not having to add a vector input node.
Just wanna make sure everybody is on board with this.

@Jacques Lucke (JacquesLucke) I’ve only updated the patch to fix my c++ blunder. I’ll have time to more thoroughly address your feedback this weekend.

Does exposing the Vector socket inputs require versioning? Currently it won’t expose the inputs for the Vector socket on existing Vector Rotate nodes in shaders. This doesn’t break anything but it might be weird.
Would it be better to make a separate patch for that, as well, to keep things more clean?

Great that it’s working for you, @Simon Thommes (simonthommes) !
What do you think about the exposed Vector input? You’re pretty much using the node how I imagined it would be and in those cases I figured it’d be nice not having to add a vector input node.
Just wanna make sure everybody is on board with this.

Thanks for the update!
I thought about this question before and I'm not exactly sure. I do think that the node feels quite bloated with 3 exposed input vectors. The shader node also had this initially, I can't find the decision to change this. But I do think it makes sense to hide it. Partly to emphasize that this is the main input that is being altered and to encourage the user to deliberately create an input node for use-cases like this. That helps with readibility, it makes sense to separate the operation from the input (the other inputs are part of the operation).

So I'm leaning towards following the shader node with this decision, even though I can see why you made yours differently and I can see the benefit of this approach.
If we go with a hidden input, at least Geometry Nodes do have a dedicated Vector Input node and don't have to go the way of Combine XYZ :D

Leon Schittek (lone_noel) planned changes to this revision.Mar 4 2021, 10:30 AM

In D10410#267913, @Simon Thommes (simonthommes) wrote:
But I do think it makes sense to hide it. Partly to emphasize that this is the main input that is being altered and to encourage the user to deliberately create an input node for use-cases like this. That helps with readibility, it makes sense to separate the operation from the input (the other inputs are part of the operation).

This is pretty much what made me unsure about the change and the way you put it makes a very clear case fo hiding the input. I'll go back to hiding the input with the next update.
Thanks for the feedback! :)

I moved the node to c++ in master, so you don't have to do that as part of a separate patch anymore.

  • Rebase on current master
  • Hide Vector input socket again
Leon Schittek (lone_noel) marked an inline comment as done.Mar 8 2021, 7:23 AM

@Jacques Lucke (JacquesLucke) Thanks a lot for doing the c++ conversion! :)

source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc
86

I don't think there currently is a way to actually use this node for multiple vectors, right? So for now I've kept the implementation with CustomMF_SI_SI_SI_SI_SO.

I still think the code can be simplified a bit to make it less redundant. But overall it looks good now. Will merge it in a moment with minor changes to make clang-tidy happy (else-after-return).

This revision is now accepted and ready to land.Mar 8 2021, 11:36 AM