0
$\begingroup$

so I have a system that instances blocks in a grid pattern based on a meshgeo node on enter image description here

and this without the geo node being ongeo node off

What im trying to achieve is to make the highest block in an x y coordinate a red block. so for each xy coordinate I want to select the box that is on top of all the other boxes. enter image description here

here's another example

enter image description here

$\endgroup$
2
  • $\begingroup$ could you please add a sketch or image of the result you wanna achieve? Because if you make the highest block for each row and column red, you would have e.g. on a "typical" v roof of a house everything red, because all x height values are equal -> so all are "highest" -> red. $\endgroup$
    – Chris
    Jan 28, 2023 at 9:07
  • $\begingroup$ ive edited the post but basically im trying to get the cubes that are on top of the other cubes to change the material. well a better example would be like how in minecraft the dirt block that is the highest becomes a grass block. $\endgroup$
    – something
    Jan 28, 2023 at 9:56

1 Answer 1

1
$\begingroup$

To do it, I propose to generate the grid a bit differently, using the bounding box of the shape.

From that,

  • ray cast the grid points along Z with the original shape as target
  • if the ray is inside the target (the dot product of the ray with the hit normal is positive)
  • then if the distance to the hit point is less than the grid space, the point is on top
  • if this distance is greater than that, the point is not on top

enter image description here

enter image description here

$\endgroup$
7
  • $\begingroup$ wow thanks, ive been tinkering around with raycast node aswell but never got it to work like that. $\endgroup$
    – something
    Jan 28, 2023 at 10:22
  • $\begingroup$ After playing around with this, I found that you actually dont need a bounding box and removing the bounding box gives massive performance boost since you dont need too calculate all of the points in the bounding box. $\endgroup$
    – something
    Jan 29, 2023 at 2:35
  • $\begingroup$ ok Aqil, I was not able to obtain a good result starting with the initial volume. How did you did it? $\endgroup$
    – lemon
    Jan 29, 2023 at 7:13
  • 1
    $\begingroup$ you can replace the bounding box node with an extra extrude node (if the spacing in the distribute points on volume nodes are smaller tho, like 1.000 x 1.000 x 1.000 you dont even need to add an extra extrude node) and play around with the value in the "less than" compare node that is connected to the hit distance value from the raycast node. $\endgroup$
    – something
    Jan 29, 2023 at 17:03
  • $\begingroup$ basically you just play around with the values manually until it looks right $\endgroup$
    – something
    Jan 29, 2023 at 17:13

You must log in to answer this question.

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