1
$\begingroup$

how can I select points with the same values on the same attribute? Compare node with specific values is not an option because values are random and the number of points with the same values can be different.

and maybe set int attrubute on same points (if value = 1.25 set int atr = 1, if value = 0.14 set int atr = 2, an so one)

enter image description here

################## EDIT additional info ###############

I'm trying to rebuild a spine for a bush plant to animate it.

I managed to calculate the distance between the first point in a branch and the closest point from it to the point on the trunk. This way I will probably connect the branch with the rest of the pine structure. Imgur

enter image description here

Yes, I could use the compare node and the epsilon value, but this needs to be manually adjusted per model. I want to be more automatic.

In the image with colored branches, you can see what I'm aiming for, I hope it is readable.Imgur enter image description here

$\endgroup$
4
  • 2
    $\begingroup$ Maybe I'm a bit slow in conprehending, but how do you determine which points have the same value when you don't have a specific value you want to be the same? Or asked differently: when you say points with same attributes, but their values can vary randomly - do you actually mean "select" and if so, how do you differentiate the selected points with one mutual attribute value from those with some other mutual value? Or do you mean something more like grouping by mutual attributes? $\endgroup$ Commented Apr 28 at 18:18
  • $\begingroup$ Put the attribute into a Compare node, set the compare value to what you want, set the Epsilon to control how close the values need to be to the compared value to be considered "selected". $\endgroup$ Commented Apr 29 at 0:49
  • $\begingroup$ You say Compare node with specific values is not an option because the values are random. Then how is it supposed to be determined what you put at the end: "if value = 1.25 set int atr = 1, if value = 0.14 set int atr = 2"? $\endgroup$ Commented Apr 29 at 13:03
  • $\begingroup$ Do you want to put points in "bins", where all the points in the same bin have exactly the same value for the same attribute ? You do not known how many bins are required, and the number of points per bin can be different ? From your picture, it means 7 bins, with 1 point per bin, except for bins "1.25" and "1.116" with 2 points ? $\endgroup$ Commented Apr 29 at 13:27

2 Answers 2

1
$\begingroup$

The simplest way to group elements is to extrude them (for this you need to convert your elements to vertices) move extruded vertices to positions uniquely described by the attribute, then "Merge by Distance". I tested and it doesn't work with a distance of exactly zero, so you do need some εpsilon… Once you have merged geometry, all elements having the same attribute will belong to the same mesh island, so mesh island index is the "bin" to sample:

Imgur mirror (SE image hosting has problems)

Imgur mirror

$\endgroup$
1
$\begingroup$

You can create unique groups for elements that have the same value by using this setup :

setup1

Basically, it orders the indixes based on their value, which is connected to the Weight input of the "Sort elements" node. Now that the indexes are ordered, we check for each index if the value at the next index is the same. If it isn't, we add 1 using the "Accumulate field" node. This ends up creating groups each time the value changes

WARNING: bellow is the previous method I posted, it might not always work because of the way the Hash Value node works. It is a slower method as well

As mentioned just above, this method is not recomended as it can be inconsistent (the Hash Value node doesn't guarentee the groups to be unique, which would result in collisions between elements, as mentioned in the documentation). I'm only leaving this answer in case someone wants to explore different ways of achieving this.

Ordered Groups

Creating "unique" (might not always be, as written above) groups for each value is easy, you simply need to plug your value into the Hash Value node. However, these groups are not ordered as you can see

enter image description here

So, next comes the ordering of these group.

The method I used consists on first on setting a new position of the points corresponding to the value they have, then getting the first element of each groups using the accumulate field and the result of the hash value. The points represent a group each.

Then, we order the indexes of these points based on their position with the sort elements node. If you want to reverse the order, just multiply the position value by -1

Once that is done, we simply need to get the index of the nearest point from this newly created set of ordered points. We then retrieve the original position of the mesh

setup old

$\endgroup$
3
  • $\begingroup$ from docs: "Hashes cannot be relied upon to be used as unique identifiers because they are not guaranteed to be unique." I think this is a very good answer if you don't mind a hash collision every now and then. For 10k, 100k and a million points I get 3, 240 and 23.4k collisions with this setup: i.imgur.com/1Q58PS0.png - basically you're guaranteed to get some collisions for a reasonable geometry > 10k and are overwhelmed with them for very heavy geometry. $\endgroup$ Commented May 10 at 8:05
  • $\begingroup$ @MarkusvonBroady Thanks for telling me about this, I wasn't aware the Hash Value node wasn't that reliable for groups. I came up with a different answer which ended up being much simpler and faster as it skips geometry alteration. Let me know if you think it wouldn't work as expected either $\endgroup$ Commented May 11 at 14:58
  • $\begingroup$ Oh yea, that's smart! Without testing I'd assume it's significantly faster than my solution and will work for εpsilon equal exactly zero. Interestingly, it won't create boundaries in a smooth gradient, that is if you have an ε=0.201 and values 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, it will assign all points to a single group, whereas my solution will divide into pairs, I think; haven't actually tested. No idea which behavior is better. $\endgroup$ Commented May 11 at 17:56

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.