Skip to main content
1 of 2
user avatar
user avatar

The Attribute Statistics node is lacking an index output for things like the min/max values. Here's a technique i use frequently based on the Attribute Transfer node:

Basic min/max finding:

Grouped min/max:

  1. For the basic "Find index of min/max": Arrange points on the X axis using the search value. Subtract the minimum value so they all start at x = 0 (this also works for negative values).enter image description here
  2. Then use Transfer Attribute to find the closest point to (0,0,0). Since this will be the point with the smallest search value, we can use this to get the index attribute of that point. Notice the explicit Combine Vector input node, this is needed because we need to override the default input of Source Position (which would be the position of any point for which we evaluate this field).enter image description here
  3. This setup can return the maximum value as well by simply using Max output of the statistics node.

The technique can be extended to search in multiple sub-groups simultaneously. For that i separate the point group by spacing them out on the Y axis, in addition to the original X axis sorting.enter image description here The purpose of the spacing is to avoid accidentally getting the closest point from a different group. The statistics node's Range output is useful for that, i multiply it by 2 to be on the safe side.enter image description here In the attribute search the source positions are then similarly spaced out along the Y axis, to find the closest point in each group. I use a separate input value for this, which makes it easier to pick a single group or map min/max values from a different geometry. enter image description here One caveat: If a group is empty, this method will just pick the closest point from a neighboring group. You can add a final distance check to see if the nearest point is closer than the Y axis spacing to handle this case if necessary.

user436