Geometry Nodes: support group ids in Sample Nearest Surface node #118150

Merged
Jacques Lucke merged 17 commits from JacquesLucke/blender:sample-nearest-surface-group-ids into main 2024-02-15 20:35:12 +01:00
Member

This adds group ids to the Sample Nearest Surface node. This allows e.g. finding the closest point on a specific mesh island.

Three new sockets are added:

  • Group ID: Is evaluated on the face domain and splits the input mesh into multiple parts, each with its own id.
  • Sample Group ID: Determines in which group the closest nearest surface is detected.
  • Is Valid: Outputs true if a nearest surface was found, it's false if the group is empty.

image

This adds group ids to the `Sample Nearest Surface` node. This allows e.g. finding the closest point on a specific mesh island. Three new sockets are added: * `Group ID`: Is evaluated on the face domain and splits the input mesh into multiple parts, each with its own id. * `Sample Group ID`: Determines in which group the closest nearest surface is detected. * `Is Valid`: Outputs true if a nearest surface was found, it's false if the group is empty. ![image](/attachments/fba5beb9-4d43-49a1-aedc-dd840dca869f)
Jacques Lucke added 1 commit 2024-02-12 18:51:14 +01:00
Jacques Lucke requested review from Simon Thommes 2024-02-12 18:52:44 +01:00
Jacques Lucke requested review from Hans Goudey 2024-02-12 18:52:44 +01:00
Jacques Lucke added 2 commits 2024-02-13 11:21:10 +01:00
Simon Thommes requested changes 2024-02-13 12:00:04 +01:00
Simon Thommes left a comment
Member

I think now we need an Is Valid output like the UV sampling node for cases where there is no match for Group ID.

Other than that this looks good to me!

I think now we need an `Is Valid` output like the UV sampling node for cases where there is no match for Group ID. Other than that this looks good to me!
Jacques Lucke added 3 commits 2024-02-13 12:43:30 +01:00
Hans Goudey reviewed 2024-02-13 22:00:43 +01:00
@ -107,0 +136,4 @@
3, "Sample Position");
MutableSpan<bool> is_valid_span = params.uninitialized_single_output<bool>(4, "Is Valid");
mask.foreach_index([&](const int i) {
Member

It might be worth having a fallback for the simple case when sample_ids is single?

Seems like it could be worth it to support not allocating the is valid output too?

Though I'm sure those things are insignificant compared to the actual lookup, especially now...

It might be worth having a fallback for the simple case when `sample_ids` is single? Seems like it could be worth it to support not allocating the is valid output too? Though I'm sure those things are insignificant compared to the actual lookup, especially now...
Member

I guess you don't think it's worth having a special case where we just call get_closest_mesh_tris?

I guess you don't think it's worth having a special case where we just call `get_closest_mesh_tris`?
Author
Member

Yeah, I don't really think that's necessary. If anything, I'd probably rather optimize for different cases in SampleNearestSurfaceFunction::call directly.

Yeah, I don't really think that's necessary. If anything, I'd probably rather optimize for different cases in `SampleNearestSurfaceFunction::call` directly.
Jacques Lucke added 3 commits 2024-02-14 11:00:19 +01:00
Jacques Lucke added 1 commit 2024-02-14 11:07:25 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 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
a4096a0017
support unused Is Valid Output
Author
Member

@blender-bot build

@blender-bot build
Jacques Lucke changed title from WIP: Geometry Nodes: support group ids in Sample Nearest Surface node to Geometry Nodes: support group ids in Sample Nearest Surface node 2024-02-14 11:11:14 +01:00
Simon Thommes requested changes 2024-02-14 19:12:49 +01:00
Simon Thommes left a comment
Member

I'm having some trouble understanding what the fallback output is derived from whenever the Group ID is not valid. It should probably just be 0 like it is for UV sampling, right now it is actually related to the input attribute.

I didn't notice this before, sorry. After this is fixed I'm pretty sure it's good to go from my end.

I'm having some trouble understanding what the fallback output is derived from whenever the Group ID is not valid. It should probably just be 0 like it is for UV sampling, right now it is actually related to the input attribute. I didn't notice this before, sorry. After this is fixed I'm pretty sure it's good to go from my end.
Jacques Lucke added 2 commits 2024-02-14 22:43:50 +01:00
Hans Goudey reviewed 2024-02-14 23:22:27 +01:00
Hans Goudey left a comment
Member

If we were using panels in builtin nodes, it might be nice to put all the new sockets in a new panel. But this probably isn't the first node we should do that to.

This mostly looks good to me, just a left a few inline comments.

If we were using panels in builtin nodes, it might be nice to put all the new sockets in a new panel. But this probably isn't the first node we should do that to. This mostly looks good to me, just a left a few inline comments.
@ -29,12 +29,17 @@ static void node_declare(NodeDeclarationBuilder &b)
const eCustomDataType data_type = eCustomDataType(node->custom1);
b.add_input(data_type, "Value").hide_value().field_on_all();
}
b.add_input<decl::Int>("Group ID").hide_value().field_on_all();
Member

Could you look into adding some descriptions for these inputs? That would probably really help people trying to figure it out for the first time.

Could you look into adding some descriptions for these inputs? That would probably really help people trying to figure it out for the first time.
JacquesLucke marked this conversation as resolved
@ -37,1 +39,4 @@
}
b.add_output<decl::Bool>("Is Valid")
.dependent_field({3, 4})
.description("Whether the sampling was successfull");
Member

It would be nice to mention why the sampling might not be successful (or just be more specific here)

It would be nice to mention why the sampling might not be successful (or just be more specific here)
JacquesLucke marked this conversation as resolved
Author
Member

If we were using panels in builtin nodes, it might be nice to put all the new sockets in a new panel. But this probably isn't the first node we should do that to.

Hm, maybe we can do a pass over some nodes with optional group ids later and put them all in panels.

> If we were using panels in builtin nodes, it might be nice to put all the new sockets in a new panel. But this probably isn't the first node we should do that to. Hm, maybe we can do a pass over some nodes with optional group ids later and put them all in panels.
Jacques Lucke added 3 commits 2024-02-15 10:42:48 +01:00
buildbot/vexp-code-patch-lint 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-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
f149beb492
improve description
Simon Thommes approved these changes 2024-02-15 10:50:14 +01:00
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey approved these changes 2024-02-15 17:39:37 +01:00
@ -97,0 +119,4 @@
/* Construct BVH tree for each group. */
bvh_trees_.reinitialize(groups_num);
for (const int group_i : IndexRange(groups_num)) {
Member

It would probably be worth parallelizing this when there are lots of groups

It would probably be worth parallelizing this when there are lots of groups
JacquesLucke marked this conversation as resolved
Jacques Lucke added 2 commits 2024-02-15 20:32:18 +01:00
01f94abbaf use multi-threading when building bvh trees
Could still be optimized a bit more for the case when there are few
large bvh trees, but I'll do that separately.
Jacques Lucke merged commit 75e9056cac into main 2024-02-15 20:35:12 +01:00
Jacques Lucke deleted branch sample-nearest-surface-group-ids 2024-02-15 20:35:14 +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
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#118150
No description provided.