Geometry Nodes: new Axis to Euler node #104416

Open
Jacques Lucke wants to merge 13 commits from JacquesLucke/blender:axis-to-euler into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

This adds a new Axis to Euler node which creates a new rotation. In many cases, the primary and secondary axis inputs are a normal and tangent of a mesh or curve. This provides a simpler and more direct way to create this rotation compared to using two Align Euler to Vector nodes.

image

This more direct way of computing the rotation also allows us to optimize the case better. The benchmark file below shows that this new method takes about a third of the time (46ms vs 16ms). Just for the curious, if the node were to output a quaternion instead of an (e.g. once we have a proper rotation socket or optimize the case separately), the time would drop to just 5ms.

image

This adds a new `Axis to Euler` node which creates a new rotation. In many cases, the primary and secondary axis inputs are a normal and tangent of a mesh or curve. This provides a simpler and more direct way to create this rotation compared to using two `Align Euler to Vector` nodes. ![image](/attachments/88b744eb-47de-4b28-a5f2-f50d4165bb6a) This more direct way of computing the rotation also allows us to optimize the case better. The benchmark file below shows that this new method takes about a third of the time (46ms vs 16ms). Just for the curious, if the node were to output a quaternion instead of an (e.g. once we have a proper rotation socket or optimize the case separately), the time would drop to just 5ms. ![image](/attachments/96efdd4e-c888-410d-8968-1fdadd8d8caa)
Jacques Lucke added 12 commits 2023-02-07 18:34:19 +01:00
Jacques Lucke added 1 commit 2023-02-07 18:38:32 +01:00
Jacques Lucke requested review from Hans Goudey 2023-02-07 19:24:05 +01:00
Jacques Lucke requested review from Simon Thommes 2023-02-07 19:25:40 +01:00
Hans Goudey reviewed 2023-02-07 20:46:52 +01:00
Hans Goudey left a comment
Collaborator

The code looks relatively straightforward. Assuming this works for Simon, this looks good to go.

The code looks relatively straightforward. Assuming this works for Simon, this looks good to go.
@ -9901,0 +9922,4 @@
RNA_def_property_ui_text(
prop,
"Secondary Axis",
"Axis that is aligned as good as possible given the alignment of the primary axis");

as good -> as well

`as good` -> `as well`
@ -0,0 +38,4 @@
uiItemR(layout, ptr, "secondary_axis", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
if (storage.primary_axis == storage.secondary_axis) {
uiItemL(layout, N_("Must not be equal"), ICON_ERROR);

Must not be equal -> Axes must not be equal

Just reads a bit better IMO

`Must not be equal` -> `Axes must not be equal` Just reads a bit better IMO
@ -0,0 +70,4 @@
/* Through cancellation this will set the last axis to be the one that's neither the primary
* nor secondary axis. */
tertiary_axis_ = (0 + 1 + 2) - primary_axis - secondary_axis;

Ooh, clever!

Ooh, clever!
@ -0,0 +94,4 @@
const float tertiary_factor = invert_tertiary ? -1.0f : 1.0f;
for (const int64_t i : mask) {
float3 primary = math::normalize(primaries[i]);

Not asking for any changes here, but it would be nice if we could build function nodes with multiple multi-functions. In this case we could split the normalization of primaries and secondaries to separate functions. Later on we could implement an optimization pass that removes sequential normalization functions.

I guess that might be possible with some improvements to NodeMultiFunctionBuilder?

Not asking for any changes here, but it would be nice if we could build function nodes with multiple multi-functions. In this case we could split the normalization of `primaries` and `secondaries` to separate functions. Later on we could implement an optimization pass that removes sequential normalization functions. I guess that might be possible with some improvements to `NodeMultiFunctionBuilder`?
Hans Goudey approved these changes 2023-02-07 21:12:54 +01:00
Hans Goudey left a comment
Collaborator

.

.
Jacques Lucke changed title from Geometry Nodes: new Axis to Euler node to Geometry Nodes: New Axis to Euler node 2023-02-08 12:40:30 +01:00
Jacques Lucke changed title from Geometry Nodes: New Axis to Euler node to Geometry Nodes: new Axis to Euler node 2023-02-08 12:40:43 +01:00
Simon Thommes requested changes 2023-02-10 12:36:53 +01:00
Simon Thommes left a comment
Collaborator

Seems good to me overall I tested some corner cases, where I think the behaviour could be different.

When primary and secondary axis are parallel, it should probably ignore the secondary axis entirely. At least I don't see a reason, why it would have any particular impact.

When using only the secondary axis as an input it would make sense to me to rotate first around what is selected as primary axis. Right now it seems a bit random to me, not sure of the logic behind it right now.

e.g. this shouldn't result in any rotation imo
image

Seems good to me overall I tested some corner cases, where I think the behaviour could be different. When primary and secondary axis are parallel, it should probably ignore the secondary axis entirely. At least I don't see a reason, why it would have any particular impact. When using only the secondary axis as an input it would make sense to me to rotate first around what is selected as primary axis. Right now it seems a bit random to me, not sure of the logic behind it right now. e.g. this shouldn't result in any rotation imo ![image](/attachments/a8d55d6e-aaff-42bd-8857-e8314efa8fe1)
Brecht Van Lommel added this to the Nodes & Physics project 2023-02-13 09:19:22 +01:00
Hans Goudey added this to the 4.0 milestone 2023-06-15 20:31:00 +02:00
Hans Goudey requested changes 2023-06-15 20:31:45 +02:00
Hans Goudey left a comment
Collaborator

With the rotation socket in 4.0, we have another opportunity to add this node. But it needs to be updated for that.

With the rotation socket in 4.0, we have another opportunity to add this node. But it needs to be updated for that.

Reviewers

Simon Thommes requested changes 2023-02-10 12:36:53 +01:00
Hans Goudey requested changes 2023-06-15 20:31:45 +02:00
This pull request has changes conflicting with the target branch.
  • release/scripts/startup/bl_ui/node_add_menu_geometry.py
  • source/blender/blenkernel/BKE_node.h
  • source/blender/makesrna/intern/rna_nodetree.c
  • source/blender/nodes/NOD_static_types.h
  • source/blender/nodes/function/CMakeLists.txt
  • source/blender/nodes/function/node_function_register.cc
  • source/blender/nodes/function/node_function_register.hh
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest: Wayland
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#104416
There is no content yet.