5
$\begingroup$

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

enter image description here

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

enter image description here

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

enter image description here

enter image description here

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.

$\endgroup$
3
  • 4
    $\begingroup$ 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 $\endgroup$
    – Gorgious
    Feb 24, 2023 at 7:02
  • 2
    $\begingroup$ 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. $\endgroup$
    – Gorgious
    Feb 24, 2023 at 7:05
  • $\begingroup$ @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. $\endgroup$ Feb 24, 2023 at 8:54

1 Answer 1

6
$\begingroup$

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:

enter image description here

.. and the result of testing proximity to that:

enter image description here

Edit (response to comments)

enter image description here

  • The top Accumulate Field returns the sums of point-position vectors, grouped by mesh-island
  • 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)].

The result is the mean point-position, by island.

$\endgroup$
5
  • $\begingroup$ Thanks! Can you please explain how this works? I don't understand how accumulate field works and the use of the integer value of the second node that you used. Understanding these concepts would be very helpful for me in the future. $\endgroup$ Feb 24, 2023 at 9:24
  • $\begingroup$ Awesome ! I'm just wondering, wouldn't using the "Island Count" output give the same number as the result of the bottom accumulate field ? $\endgroup$
    – Gorgious
    Feb 24, 2023 at 9:39
  • $\begingroup$ Hi, @NikhilNair .. I hope the edit helps. The sum of '1' per-point just returns the number of points, per island. $\endgroup$
    – Robin Betts
    Feb 24, 2023 at 10:22
  • 1
    $\begingroup$ Hi, @Gorgious. I don't think so.. the Island Count returns the number of islands. I'm looking for the number of points in each island, contributing to the island-vector-sum. (With no guarantee that islands will all have the same number of points) $\endgroup$
    – Robin Betts
    Feb 24, 2023 at 10:25
  • 1
    $\begingroup$ Oh, right, brainfart on my part, thanks for the explanations :) $\endgroup$
    – Gorgious
    Feb 24, 2023 at 12:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .