Geometry Nodes: Matrix socket type, attribute type, and initial nodes #116166

Merged
Hans Goudey merged 47 commits from HooglyBoogly/blender:nodes-matrix-socket into main 2024-02-13 18:59:46 +01:00
Member

Implements the design from #116067.
The socket type is called "Matrix" but it is often referred to as "Transform"
when that's what it is semantically. The attribute type is "4x4 Matrix" since
that's a lower level choice. Currently matrix sockets are always passed
around internally as float4x4, but that can be optimized in the future
when smaller types would give the same behavior.

A new "Matrix" utilities category has the following set of initial nodes"

  • Combine Transform
  • Separate Transform
  • Multiply Matrices
  • Transform Direction
  • Transform Vector
  • Invert Matrix
  • Transpose Matrix

The nodes and socket type are behind an experimental flag for now,
which will give us time to make sure it's the right set of initial nodes.
The viewer node overlay doesn't support matrices-- they aren't supported
for rendering in general. They also aren't supported in the modifier interface
currently. But they are supported in the spreadsheet, where the value is
displayed in a tooltip.


image
Screenshot from 2023-12-13 17-53-39

Implements the design from #116067. The socket type is called "Matrix" but it is often referred to as "Transform" when that's what it is semantically. The attribute type is "4x4 Matrix" since that's a lower level choice. Currently matrix sockets are always passed around internally as `float4x4`, but that can be optimized in the future when smaller types would give the same behavior. A new "Matrix" utilities category has the following set of initial nodes" - **Combine Transform** - **Separate Transform** - **Multiply Matrices** - **Transform Direction** - **Transform Vector** - **Invert Matrix** - **Transpose Matrix** The nodes and socket type are behind an experimental flag for now, which will give us time to make sure it's the right set of initial nodes. The viewer node overlay doesn't support matrices-- they aren't supported for rendering in general. They also aren't supported in the modifier interface currently. But they are supported in the spreadsheet, where the value is displayed in a tooltip. --- ![image](/attachments/8d687fbb-5bef-4bbb-afb5-fe412cde1407) ![Screenshot from 2023-12-13 17-53-39](/attachments/5096af51-925e-4275-8510-329da4a574f9)
Hans Goudey added 11 commits 2023-12-14 00:32:27 +01:00
Hans Goudey changed title from Geometry Nodes: Matrix node sockets, attribute types, and function nodes to Geometry Nodes: Matrix socket type, attribute type, and initial nodes 2023-12-14 00:32:51 +01:00
Hans Goudey added this to the Nodes & Physics project 2023-12-14 00:33:07 +01:00
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR116166) when ready.
Hans Goudey added the
Interest
Geometry Nodes
label 2023-12-14 00:33:24 +01:00
Hans Goudey added this to the 4.1 milestone 2023-12-14 00:33:29 +01:00
Hans Goudey added the
Module
Nodes & Physics
label 2023-12-14 00:33:35 +01:00
Hans Goudey added 1 commit 2023-12-14 00:34:41 +01:00
First-time contributor

In the future, perhaps matrix from input location, rotation and scale?

In the future, perhaps matrix from input location, rotation and scale?
First-time contributor

Instead of location to transform, rotation to ~ & scale to ~, I think it's more preferable to have something like "compose transform"

Instead of location to transform, rotation to ~ & scale to ~, I think it's more preferable to have something like "compose transform"
First-time contributor

One node doesn't follow the verb-first nomenclature, Matrix Multiply. Perhaps it should be changed to Multiply Matrix.

edit : I'd also like to discuss the socket color. Right now I can distinguish it from the rotation socket color, but only if I look closely for a brief moment -at a glance, they look almost exactly the same. Is it just me ?

One node doesn't follow the verb-first nomenclature, Matrix Multiply. Perhaps it should be changed to Multiply Matrix. edit : I'd also like to discuss the socket color. Right now I can distinguish it from the rotation socket color, but only if I look closely for a brief moment -at a glance, they look almost exactly the same. Is it just me ?
Hans Goudey added 2 commits 2023-12-18 17:29:00 +01:00
Hans Goudey added 1 commit 2023-12-19 16:58:50 +01:00
Hans Goudey added 2 commits 2023-12-19 18:23:38 +01:00
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
7797f48a43
Change name to multiply matrices
Author
Member

I changed the nodes to "Combine Transform" and "Separate Transform". While "compose" and "decompose" might imply the non-trivial nature of the operations better, we thought the consistency with the other combine and separate nodes was worth it.

I also changed "Matrix Multiply" to "Multiply Matrices" to go with the verb first naming.

I'd also like to discuss the socket color. Right now I can distinguish it from the rotation socket color, but only if I look closely for a brief moment -at a glance, they look almost exactly the same. Is it just me ?

Feel free to propose a different color :D I'm struggling with that a bit too. The current color doesn't seem too bad, but there may be a better choice.

I changed the nodes to "Combine Transform" and "Separate Transform". While "compose" and "decompose" might imply the non-trivial nature of the operations better, we thought the consistency with the other combine and separate nodes was worth it. I also changed "Matrix Multiply" to "Multiply Matrices" to go with the verb first naming. >I'd also like to discuss the socket color. Right now I can distinguish it from the rotation socket color, but only if I look closely for a brief moment -at a glance, they look almost exactly the same. Is it just me ? Feel free to propose a different color :D I'm struggling with that a bit too. The current color doesn't seem _too_ bad, but there may be a better choice.
Hans Goudey requested review from Lukas Tönne 2023-12-19 18:31:58 +01:00
Hans Goudey requested review from Jacques Lucke 2023-12-19 18:31:58 +01:00
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR116166) when ready.
Hans Goudey added 2 commits 2023-12-19 20:34:12 +01:00
First-time contributor

Feel free to propose a different color :D I'm struggling with that a bit too. The current color doesn't seem too bad, but there may be a better choice.

Here is a first try at making socket colors more spaced out and differentiable.

socket_colors_draft.png

and a blend file to generate them
socket_colors.blend

I took it as an opportunity to rethink the color distribution by grouping some similar types together on the color wheel. I only lightly touched the more "established Blender colors" (geometry, object, material), didn't want to shake everything up either since those are used throughout the interface, not just in nodes. I played with saturation and lightness to try and differentiate the ones that were closest together.

But how extensible is this really ? I'm not sure we can keep relying on colors if more types are introduced.

Corollary : perhaps these should be user-themable ?

Here is a second try, with more differenciation and approximately equal perceived intensities between sockets. YMMV
(Looks like I can't link the attachments in the post anymore, they're at the bottom of this post.)

> Feel free to propose a different color :D I'm struggling with that a bit too. The current color doesn't seem _too_ bad, but there may be a better choice. Here is a first try at making socket colors more spaced out and differentiable. ![socket_colors_draft.png](/attachments/58e239d0-2179-4544-b334-681e200a688d) and a blend file to generate them [socket_colors.blend](/attachments/b875a925-7ca5-4316-8155-3aaabc4fb1ee) I took it as an opportunity to rethink the color distribution by grouping some similar types together on the color wheel. I only lightly touched the more "established Blender colors" (geometry, object, material), didn't want to shake everything up either since those are used throughout the interface, not just in nodes. I played with saturation and lightness to try and differentiate the ones that were closest together. But how extensible is this really ? I'm not sure we can keep relying on colors if more types are introduced. Corollary : perhaps these should be user-themable ? Here is a second try, with more differenciation and approximately equal perceived intensities between sockets. YMMV (Looks like I can't link the attachments in the post anymore, they're at the bottom of this post.)
Hans Goudey added 1 commit 2023-12-27 06:06:59 +01:00
Author
Member

I took it as an opportunity to rethink the color distribution by grouping some similar types together on the color wheel

Thanks for doing that, but I don't think we'll change so many of the colors right now. It's probably important to reuse the white color for collections too.

Anyway, a deep purple still might work for matrix sockets.

>I took it as an opportunity to rethink the color distribution by grouping some similar types together on the color wheel Thanks for doing that, but I don't think we'll change so many of the colors right now. It's probably important to reuse the white color for collections too. Anyway, a deep purple still might work for matrix sockets.
Hans Goudey added 2 commits 2024-01-09 19:37:51 +01:00
First-time contributor

A minor thing, but if the printing of the matrix when mousing over to preview was aligned column-wise, it would help with visually parsing it for inspecting & debugging. Otherwise very excited to get access to matrix data types!

A minor thing, but if the printing of the matrix when mousing over to preview was aligned column-wise, it would help with visually parsing it for inspecting & debugging. Otherwise very excited to get access to matrix data types!

What about socket tooltip?

What about socket tooltip?
Hans Goudey added 1 commit 2024-01-10 14:38:30 +01:00
Hans Goudey added 2 commits 2024-01-10 20:17:27 +01:00
Hans Goudey added 1 commit 2024-01-10 20:26:52 +01:00
Member

Do you still want to remove the Project Vector node from this patch? Not sure if there is too much benefit in having it in here. It's less obvious than the others.

The Transform Vector node behavior node is also not entirely obvious. It's not clear whether it transforms a point, or direction (or normal).

Did you investigate better alignment using a monospace font in the tooltip?

Do you still want to remove the Project Vector node from this patch? Not sure if there is too much benefit in having it in here. It's less obvious than the others. The Transform Vector node behavior node is also not entirely obvious. It's not clear whether it transforms a point, or direction (or normal). Did you investigate better alignment using a monospace font in the tooltip?

I'd prefer to change tooltip to show transformation, instead of matrix components. But this still just table of numbers...

I'd prefer to change tooltip to show transformation, instead of matrix components. But this still just table of numbers...
Member

Yeah, also wonder if the spreadsheet could show some more info other than ..., like whether the matrix is just a translation, or rotation, etc. But that can also be done separately.

Yeah, also wonder if the spreadsheet could show some more info other than `...`, like whether the matrix is just a translation, or rotation, etc. But that can also be done separately.
Hans Goudey added 2 commits 2024-01-12 17:29:10 +01:00
Author
Member

A minor thing, but if the printing of the matrix when mousing over to preview was aligned column-wise, it would help with visually parsing it for inspecting & debugging. Otherwise very excited to get access to matrix data types!

Yeah, this would be great. Unfortunately we don't have the right infrastructure for custom mono-space tooltips yet. That's a good thing to work on in the future though.

Yeah, also wonder if the spreadsheet could show some more info other than ..., like whether the matrix is just a translation, or rotation, etc. But that can also be done separately.

It seemed like a good way to make this PR simpler and less arbitrary for now. That could definitely be investigated in the future though.


I've removed the "Project Vector" node from this PR, since we don't have a strong enough use case for the moment.

> A minor thing, but if the printing of the matrix when mousing over to preview was aligned column-wise, it would help with visually parsing it for inspecting & debugging. Otherwise very excited to get access to matrix data types! Yeah, this would be great. Unfortunately we don't have the right infrastructure for custom mono-space tooltips yet. That's a good thing to work on in the future though. > Yeah, also wonder if the spreadsheet could show some more info other than `...`, like whether the matrix is just a translation, or rotation, etc. But that can also be done separately. It seemed like a good way to make this PR simpler and less arbitrary for now. That could definitely be investigated in the future though. --- I've removed the "Project Vector" node from this PR, since we don't have a strong enough use case for the moment.
Hans Goudey added 1 commit 2024-01-19 18:46:57 +01:00
Hans Goudey added 1 commit 2024-01-23 15:27:58 +01:00
Hans Goudey added 3 commits 2024-01-23 18:06:50 +01:00
Jacques Lucke requested changes 2024-01-24 11:30:13 +01:00
Jacques Lucke left a comment
Member
  • The default value for a square matrix should be the identity and not just zeros.
  • Do we really need to store the value in bNodeSocketValueMatrix? Seems like that shouldn't be necessary for now because we can't set it anyway. Can also probably get rid of decl::Matrix::default_value.
  • Fix sorting in NOD_static_types.h.
  • Rename Transform Vector to Transform Point.
  • I'm not super happy with adding a new Object Transform with this patch. Either it should be done before this patch, or the new socket should be added to the existing Object Info node. I don't think there is enough justification for adding a new node for this.
* [x] The default value for a square matrix should be the identity and not just zeros. * [x] Do we really need to store the value in `bNodeSocketValueMatrix`? Seems like that shouldn't be necessary for now because we can't set it anyway. Can also probably get rid of `decl::Matrix::default_value`. * [x] Fix sorting in `NOD_static_types.h`. * [x] Rename `Transform Vector` to `Transform Point`. * [x] I'm not super happy with adding a new Object Transform with this patch. Either it should be done before this patch, or the new socket should be added to the existing Object Info node. I don't think there is enough justification for adding a new node for this.
@ -251,2 +253,4 @@
return property;
}
case SOCK_MATRIX: {
BLI_assert_unreachable();
Member

This is reachable when connecting a matrix socket modifier group input.

This is reachable when connecting a matrix socket modifier group input.
Hans Goudey added 6 commits 2024-01-30 14:19:19 +01:00
Author
Member

I'm not super happy with adding a new Object Transform with this patch. Either it should be done before this patch, or the new socket should be added to the existing Object Info node. I don't think there is enough justification for adding a new node for this.

In the past we had talked about splitting the object info node into "Object Transform", "Evaluated Object Geometry", and "Original Object Geometry". But we can totally consider that later. I'll remove it for now.

>I'm not super happy with adding a new Object Transform with this patch. Either it should be done before this patch, or the new socket should be added to the existing Object Info node. I don't think there is enough justification for adding a new node for this. In the past we had talked about splitting the object info node into "Object Transform", "Evaluated Object Geometry", and "Original Object Geometry". But we can totally consider that later. I'll remove it for now.
Jacques Lucke reviewed 2024-01-30 15:17:20 +01:00
@ -288,2 +292,4 @@
DefNode(FunctionNode, FN_NODE_SLICE_STRING, 0, "SLICE_STRING", SliceString, "Slice String", "")
DefNode(FunctionNode, FN_NODE_STRING_LENGTH, 0, "STRING_LENGTH", StringLength, "String Length", "")
DefNode(FunctionNode, FN_NODE_TRANSFORM_DIRECTION, 0, "TRANSFORM_DIRECTION", TransformDirection, "Transform Direction", "")
DefNode(FunctionNode, FN_NODE_TRANSFORM_POINT, 0, "TRANSFORM_VECTOR", TransformVector, "Transform Point", "")
Member

Some missing renames.

Some missing renames.
HooglyBoogly marked this conversation as resolved
Hans Goudey added 4 commits 2024-02-09 01:20:21 +01:00
Hans Goudey added 1 commit 2024-02-09 01:24:15 +01:00
Iliya Katushenock reviewed 2024-02-09 10:36:59 +01:00
@ -1299,1 +1299,4 @@
}
else if (socket_type.is<float4x4>()) {
const float4x4 &value = *static_cast<const float4x4 *>(socket_value);
ss << value[0] << ",\n";

All other types is printed via custom formatting (maybe this is not the best idea to relate internal debug print of value and UI representation..). Could this be done via fmt as all other just for consistency?

All other types is printed via custom formatting (maybe this is not the best idea to relate internal debug print of value and UI representation..). Could this be done via fmt as all other just for consistency?
@ -0,0 +60,4 @@
if (no_rotation && no_scale) {
mask.foreach_index(
[&](const int64_t i) { transforms[i] = math::from_location<float4x4>(location[i]); });

mask.foreach_index -> mask.foreach_index_optimized<int>.
const int64_t i -> const int i.
Same in other nodes.

I hope will find time for the benchmarks for the last loop to check if devirtualize_varray and foreach_index_optimized makes sense too, then this will be in main.

`mask.foreach_index` -> `mask.foreach_index_optimized<int>`. `const int64_t i` -> `const int i`. Same in other nodes. I hope will find time for the benchmarks for the last loop to check if `devirtualize_varray` and `foreach_index_optimized` makes sense too, then this will be in main.
Author
Member

Unless I can prove it's faster I don't think this is worth it.

Unless I can prove it's faster I don't think this is worth it.
Hans Goudey added 3 commits 2024-02-13 14:48:00 +01:00
Jacques Lucke approved these changes 2024-02-13 18:46:08 +01:00
Jacques Lucke left a comment
Member

The patch description still has to be updated.

The patch description still has to be updated.
Hans Goudey merged commit 1cfe9dd08c into main 2024-02-13 18:59:46 +01:00
Hans Goudey deleted branch nodes-matrix-socket 2024-02-13 18:59:48 +01:00
Sign in to join this conversation.
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
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
Overlay
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
Interest
Workbench
Interest: X11
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
8 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#116166
No description provided.