# How is the position of a mesh island calculated in geometry nodes?

I'm using the distance between cube and cube.001 as the factor for shading.

When I do it without using the positions of the mesh islands, it works as expected.

Then I connected the position values of the mesh islands to the source position socket and the result was a bit weird.

I want to know how mesh islands work and how I can make a setup where the entire island is affected by the shader (properly) and not just the faces.

• Hello ! I'm not surprised the results are weird here. You're evaluating the Points location on the Points domain using the Mesh Island index. These are two unrelated information sources. There is no Mesh Island domain so you can't use fields that way. AFAIK the information of a Mesh Island position is not available trivially in GN, since it's not a geometry domain per se. I think what you want to do here is regroup your points per mesh island using an accumulate field and the island index as a group selection, and an attribute statistic to get the mean value. Cheers Feb 24, 2023 at 7:02
• Also, I think an easier solution in this case would be to use instances which do have a unique location that's easy to fetch, instead of realized geometry islands. Feb 24, 2023 at 7:05
• @Gorgious Thanks for the reply! I tried what you said, but it doesn't seem to work(Or, maybe I'm doing something wrong). However, I did find a workaround. I scaled the islands with a value of 0 so that all the vertices of an island are positioned at the centre of that island (I think that's what you meant by getting the mean) and then used a 'sample index' node to get the position of those vertices. I can't use instances because I'm creating the islands using 'mesh boolean' node. Feb 24, 2023 at 8:54

As @Gorgious has commented, you have scrambled indices. In Field at Index, each point is returning the location of the point with the index of the island it is in.

Here's a way of obtaining the mean point-location per mesh-island:

.. and the result of testing proximity to that:

• The bottom Accumulate Field returns the sums of 1 per point, grouped by mesh-island.. (i.e. the number of points, per island).
• The Vector Divide is a (naughty?) cast from Integer I to Vector (I,I,I), scaling the summed position-vectors (by island) by [1 / the integer number of points (by island)].