Geometry Nodes: support wildcard in Remove Named Attribute node #118258

Merged
Jacques Lucke merged 10 commits from JacquesLucke/blender:remove-attribute-wildcard into main 2024-02-19 21:21:27 +01:00
Member

The main difficulty is to decide how the pattern should work. This has been discussed previously on devtalk.
Currently, this patch implements the simplest useful pattern matching. It allows a single wildcard character ('*') which can match at the beginning, end or in the middle of the attribute name. It should be relatively straight forward to version this to something else if we ever want to do so (which is not necessarily the case for more complex pattern matching languages like fnmatch or regular expressions).

image

The main difficulty is to decide how the pattern should work. This has been discussed previously on [devtalk](https://devtalk.blender.org/t/string-pattern-matching-language-in-blender-and-geometry-nodes/27410). Currently, this patch implements the simplest useful pattern matching. It allows a single wildcard character ('*') which can match at the beginning, end or in the middle of the attribute name. It should be relatively straight forward to version this to something else if we ever want to do so (which is not necessarily the case for more complex pattern matching languages like `fnmatch` or regular expressions). ![image](/attachments/441c1d13-d25a-4c1f-9f6b-8bf64c6eefcd)
Jacques Lucke added 3 commits 2024-02-14 12:27:53 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
ce1847fa7e
improve error message
Jacques Lucke changed title from Geometry Nodes: support Wildcard in Remove Named Attribute node to Geometry Nodes: support wildcard in Remove Named Attribute node 2024-02-14 12:28:16 +01:00
Author
Member

@blender-bot build

@blender-bot build
Jacques Lucke requested review from Simon Thommes 2024-02-14 12:28:43 +01:00
Jacques Lucke requested review from Hans Goudey 2024-02-14 12:28:44 +01:00
Simon Thommes requested changes 2024-02-14 13:49:57 +01:00
Simon Thommes left a comment
Member

This would already provide a lot of value! So as long as it's easy to version with any future addition it seems like a good compromise to me, since this would already covers the most obvious use-cases.

I do think we would probably need to make the pattern matching an explicit option as a boolean input. Both to allow users to opt out and use the '*' literally in their attribute names, as well as to communicate that this feature is happening in the first place and which nodes support it.

I'd propose and additional Pattern Matching (?) boolean input. Default True (?).

Open to name suggestions

This would already provide a lot of value! So as long as it's easy to version with any future addition it seems like a good compromise to me, since this would already covers the most obvious use-cases. I do think we would probably need to make the pattern matching an explicit option as a boolean input. Both to allow users to opt out and use the '*' literally in their attribute names, as well as to communicate that this feature is happening in the first place and which nodes support it. I'd propose and additional `Pattern Matching` (?) boolean input. Default True (?). Open to name suggestions
Member

I just now realized that you do have this option implemented as an enum. What is the benefit over using a boolean input? Are you intending to add several options in the future?

I just now realized that you do have this option implemented as an enum. What is the benefit over using a boolean input? Are you intending to add several options in the future?
Author
Member

Just so I get this right, you propose to add an additional boolean input but still leave the dropdown menu as it is now, so that there is both?

Just so I get this right, you propose to add an additional boolean input but still leave the dropdown menu as it is now, so that there is both?
Author
Member

I just now realized that you do have this option implemented as an enum. What is the benefit over using a boolean input? Are you intending to add several options in the future?

Well the thing is, I don't know if we need multiple options in the future, because there is no single obvious pattern matching system: https://devtalk.blender.org/t/string-pattern-matching-language-in-blender-and-geometry-nodes/27410

Adding it as a node option makes it significantly simpler to change it later if we need to.

> I just now realized that you do have this option implemented as an enum. What is the benefit over using a boolean input? Are you intending to add several options in the future? Well the thing is, I don't know if we need multiple options in the future, because there is no single obvious pattern matching system: https://devtalk.blender.org/t/string-pattern-matching-language-in-blender-and-geometry-nodes/27410 Adding it as a node option makes it significantly simpler to change it later if we need to.
Member

Just so I get this right, you propose to add an additional boolean input but still leave the dropdown menu as it is now, so that there is both?

No, I was proposing to add just the boolean input. At the time of writing I didn't realize you had the enum implemented.

I don't have a particular preference. Intuitively it feels better as a boolean input to me. I realize that there are several options, but tbh I don't really feel like this is the kind of thing that we need to give full customization over, but rather something where we should just pick an option and run with it. But maybe that view is too naive, I haven't fully kept up with the devtalk thread.

> Just so I get this right, you propose to add an additional boolean input but still leave the dropdown menu as it is now, so that there is both? No, I was proposing to add just the boolean input. At the time of writing I didn't realize you had the enum implemented. I don't have a particular preference. Intuitively it feels better as a boolean input to me. I realize that there are several options, but tbh I don't really feel like this is the kind of thing that we need to give full customization over, but rather something where we should just pick an option and run with it. But maybe that view is too naive, I haven't fully kept up with the devtalk thread.
Jacques Lucke added 2 commits 2024-02-15 11:43:05 +01:00
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-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
e862cc8a44
use boolean input
Author
Member

@blender-bot build

@blender-bot build
Member

I did some back and forth consideration and now I think just going with your initial approach of using an enum is probably best.

This allows us to keep the simple wildcard method around when implementing a more complex pattern matching that might create overhead for users that only require the simple approach.

Sorry for derailing the process a bit, I wasn't fully caught up with the issue.
I still don't really think there is an incredible amount of value in implementing several more complex methods in the future rather than just picking one, since we will also have other tools like lists and loops to outsource some of the logic. But now I can see how that is regardless of making this input an enum, since even just having [none, simple, complex] to choose from is valuable.

I did some back and forth consideration and now I think just going with your initial approach of using an enum is probably best. This allows us to keep the simple wildcard method around when implementing a more complex pattern matching that might create overhead for users that only require the simple approach. Sorry for derailing the process a bit, I wasn't fully caught up with the issue. I still don't really think there is an incredible amount of value in implementing several more complex methods in the future rather than just picking one, since we will also have other tools like lists and loops to outsource some of the logic. But now I can see how that is regardless of making this input an enum, since even just having [none, simple, complex] to choose from is valuable.
Jacques Lucke added 1 commit 2024-02-15 13:43:05 +01:00
First-time contributor

Hey Jacques, thank you very much for this patch and moving things along, this is a functionality we are eagerly awaiting to optimize our Geometry Node heavy workflows and pipelines!

While this is very useful in this state, the ability to have some sort of invert selection (maybe ala modifier invert icon, or an "!" at the beginning of the string, or even a boolean toggle), in a sense the ability to say we would like to keep only this set of attributes or everything but not the attribute match, would cover our most frequent use-cases...

When applying complex geometry nodes setups and creating attributes for deformation simulations for example, we could be generating sets of attributes starting with def_sim_* that would be used in calculations, masking, and shading. What would be very useful is for this wildcard node to have the ability to keep only these attributes, and remove the dozens generated upstream from weight painting, rigging, etc, that we often receive from other studios and have no control over their naming schemes.

This may be outside the scope of this commit, but I thought I'd chime in with a very frequent use-case for wildcard selection/deselection :)

Hey Jacques, thank you very much for this patch and moving things along, this is a functionality we are eagerly awaiting to optimize our Geometry Node heavy workflows and pipelines! While this is very useful in this state, the ability to have some sort of invert selection (maybe ala modifier invert icon, or an "!" at the beginning of the string, or even a boolean toggle), in a sense the ability to say we would like to keep only *this set* of attributes or everything but *not* the attribute match, would cover our most frequent use-cases... When applying complex geometry nodes setups and creating attributes for deformation simulations for example, we could be generating sets of attributes starting with def_sim_* that would be used in calculations, masking, and shading. What would be very useful is for this wildcard node to have the ability to keep only these attributes, and remove the dozens generated upstream from weight painting, rigging, etc, that we often receive from other studios and have no control over their naming schemes. This may be outside the scope of this commit, but I thought I'd chime in with a very frequent use-case for wildcard selection/deselection :)
Author
Member

I'm hesitant to adding an invert checkbox, mainly because its behavior is harder to define. Like, do you really want to remove face smoothness attributes that have been added by Blender (but not by the user explicitly)?

Note that it is possible to capture the attributes you want to keep first, then delete all attributes, and then to store them as named attributes again. Definitely not the same level of convenience, but might work ok for your specific use case.

I'm hesitant to adding an invert checkbox, mainly because its behavior is harder to define. Like, do you really want to remove face smoothness attributes that have been added by Blender (but not by the user explicitly)? Note that it is possible to capture the attributes you want to keep first, then delete all attributes, and then to store them as named attributes again. Definitely not the same level of convenience, but might work ok for your specific use case.
Contributor

While this is very useful in this state, the ability to have some sort of invert selection (maybe ala modifier invert icon, or an "!" at the beginning of the string, or even a boolean toggle), in a sense the ability to say we would like to keep only this set of attributes or everything but not the attribute match, would cover our most frequent use-cases...

In my similar PR #116833 my approach was to add options "regex" (everything matching a regular expression) and "inverse regex" (everything not matching a regular expression). That offers an easy way to do many common tasks using standard expression syntax, without the need to write a custom pattern matcher.
I started off with just "regex", but had to add the other option once I discovered how painful it is to invert regex patterns.

> > While this is very useful in this state, the ability to have some sort of invert selection (maybe ala modifier invert icon, or an "!" at the beginning of the string, or even a boolean toggle), in a sense the ability to say we would like to keep only *this set* of attributes or everything but *not* the attribute match, would cover our most frequent use-cases... > In my similar PR #116833 my approach was to add options "regex" (everything matching a regular expression) and "inverse regex" (everything *not* matching a regular expression). That offers an easy way to do many common tasks using standard expression syntax, without the need to write a custom pattern matcher. I started off with just "regex", but had to add the other option once I discovered how painful it is to invert regex patterns.
Simon Thommes approved these changes 2024-02-19 15:10:33 +01:00
Simon Thommes left a comment
Member

For this patch is a good first iteration of this kind of functionality.

On the topic of inverting the selection: I think generally this is useful functionality, but I have my doubts about how useful exactly it is before we have support for something like lists, since you couldn't define a list of exceptions, but only a single pattern. Regarding this I have the same issue, which Jacques mentioned, which is that every other attribute really means EVERY other attribute. Which is a totally valid use-case, but in most cases probably not what the user expects. Regardless, I'm not saying that we can't already have a checkbox to invert the attribute selection, but this to me is a separate discussion and that should happen in a separate task.

This patch as it is is good to go imo.

I just have one small question @JacquesLucke Just out of curiosity, would we able to expose the number of matching attributes in the tooltip of the string input? I'm not sure how difficult that would be, just think the information would be useful and this could be the right place to put it if we can do that without much extra effort.

For this patch is a good first iteration of this kind of functionality. On the topic of inverting the selection: I think generally this is useful functionality, but I have my doubts about how useful exactly it is before we have support for something like lists, since you couldn't define a list of exceptions, but only a single pattern. Regarding this I have the same issue, which Jacques mentioned, which is that every other attribute really means EVERY other attribute. Which is a totally valid use-case, but in most cases probably not what the user expects. Regardless, I'm not saying that we can't already have a checkbox to invert the attribute selection, but this to me is a separate discussion and that should happen in a separate task. This patch as it is is good to go imo. I just have one small question @JacquesLucke Just out of curiosity, would we able to expose the number of matching attributes in the tooltip of the string input? I'm not sure how difficult that would be, just think the information would be useful and this could be the right place to put it if we can do that without much extra effort.
Author
Member

I just have one small question @JacquesLucke Just out of curiosity, would we able to expose the number of matching attributes in the tooltip of the string input? I'm not sure how difficult that would be, just think the information would be useful and this could be the right place to put it if we can do that without much extra effort.

It's something we can do separately. I'm not exactly sure what behavior it should have when there are instances.

> I just have one small question @JacquesLucke Just out of curiosity, would we able to expose the number of matching attributes in the tooltip of the string input? I'm not sure how difficult that would be, just think the information would be useful and this could be the right place to put it if we can do that without much extra effort. It's something we can do separately. I'm not exactly sure what behavior it should have when there are instances.
Hans Goudey approved these changes 2024-02-19 16:19:02 +01:00
@ -17,1 +27,4 @@
static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayoutSetPropSep(layout, true);
Member

These two lines are unnecessary, I guess we've been copying them between nodes

These two lines are unnecessary, I guess we've been copying them between nodes
JacquesLucke marked this conversation as resolved
@ -30,0 +49,4 @@
}
else if (wildcard_count >= 2) {
params.error_message_add(NodeWarningType::Info,
TIP_("Can have at most one * in the pattern"));
Member

How about Only one * is supported in the pattern? Just reads a bit simpler IMO

How about `Only one * is supported in the pattern`? Just reads a bit simpler IMO
JacquesLucke marked this conversation as resolved
@ -66,0 +133,4 @@
for (const StringRef attribute_name : failed_attributes) {
quoted_attribute_names.append(fmt::format("\"{}\"", attribute_name));
}
const std::string message = fmt::format(TIP_("Cannot delete built-in attributes: {}"),
Member

delete -> remove

Doesn't rally matter, but might as well use the word consistently

`delete` -> `remove` Doesn't rally matter, but might as well use the word consistently
JacquesLucke marked this conversation as resolved
Jacques Lucke added 4 commits 2024-02-19 16:27:54 +01:00
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
87f092ec45
delete -> remove
Author
Member

@blender-bot build

@blender-bot build
Jacques Lucke merged commit 6c46178a7f into main 2024-02-19 21:21:27 +01:00
Jacques Lucke deleted branch remove-attribute-wildcard 2024-02-19 21:21:29 +01:00
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
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 project
No Assignees
5 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#118258
No description provided.