Skip to main content
2 of 5
Explained the solution
André Zmuda
  • 2.4k
  • 6
  • 15

This one works even with scrambled indices.

Node Setup

It uses, what I call the Array Pattern. I already used this technique in the thread Select a subset of points in geometry nodes?.

The Array Pattern

Geometry nodes don’t provide a way, to store data in arrays. But there is a way to simulate arrays.

Imagine you stored the value of every index of an array on a line with x = index and y = 0. To store a value, you place a point that holds the data on this line. Every time, you want to overwrite the value of this index, you simply place a new point on this line. The only thing, you have to make sure is, that the new point is closer to z=0 than all points at this index before.

To read a value of a certain index, you can simply use the Transfer Attribute node, to read the data from the point, that is closest to (index, 0, 0). In certain cases you have to make sure, that the spacing of the indices is large enough, so that you don’t read the next index point instead of a data point.

Concrete Solution

We start by creating a copy of all the original points. These are our data points. Every data point represents the index of an original point:

data points

Next, we place the data points into our array. We use the Mesh Island index of the related original point as the array index. And we calculate z to z = 1 / (index + 1). And then we simply iterate over all data points and place them into the array. This way, the point with the highest index of a mesh island will be closest to z in the corresponding index bucket. We have to add 1 to the index, because index 0 would otherwise lead to 1/0 which in blender is 0.

filling the array

Finally, we iterate over our original points and transfer the value of the corresponding array index into the ID of the original point.

reading from the array

André Zmuda
  • 2.4k
  • 6
  • 15