4
$\begingroup$

I am exploring the new geometry nodes, my goal is to create a very simple procedural tree: a brown cone and a few green pyramids on top of it 🌲. I would like to apply random variations to the pyramids like rotation, scale, color later maybe subdiv and deformation as well. For now I just work with cubes.

Geometry nodes seem not to support array-like operations so far (Blender 2.93), so I added an array modifier in front of it. However, when I use the Random Float node, I have no idea how to set the seed individually for each object copy that was created by the Array modifier. I tried to make the seed a custom parameter of the geometry nodes modifier and use a driver to set a unique value for each instance. However, that plan failed since self in the driver expression points to the modifier, not to the object so I cant get something like an index out from the Array modifier, also connecting the driver to location.z related to the original cube, not to its modified version.

My second try was to use the Bounding Box node and get the min.z to feed it into the seed. This failed as well, since it also seems to relate to the original object before the application of Array.

Both my attempts are captured in the following screenshot. The spreadsheet shows values of the driver (location.z) the random rotation is seeded by the min.z of the bounding box. enter image description here

So I am wondering, how to access the array instance index or similar data inside the geometry nodes?

$\endgroup$
5
  • 2
    $\begingroup$ At the moment it is not possible. What I would explore though is using the UVs offset parameter in the Array modifier, and use the UVs information in the GN tree. Since you are only arraying along Z axis it would also be really easy to separate each instance by its Z coordinate. Will not work for more complicated models or intricate arrays though $\endgroup$
    – Gorgious
    Jun 9 at 5:47
  • $\begingroup$ you can solve this by other "workarounds" but with geometry nodes. Are you open for such solutions? $\endgroup$
    – Chris
    Jun 9 at 6:50
  • $\begingroup$ @Gorgious that is an interesting hack, I will try it and let you know. Still, I would wish for a proper solution offered by Geometry Nodes. $\endgroup$
    – Isolin
    Jun 10 at 14:22
  • $\begingroup$ @Chris Thank you, but I am only interested in exploring the procedural power of Blender. In that sense, I could easily create a script that would replace the Array modifier and create unique objects with IDs. But that does not align with the geometry nodes workflow I envision. $\endgroup$
    – Isolin
    Jun 10 at 14:48
  • $\begingroup$ Ok, no problem. Good luck $\endgroup$
    – Chris
    Jun 10 at 14:49
2
$\begingroup$

I was able to find a way! There is a mesh primitive node called Line. I can use it as a 1D array. Unfortunately I didn't find a way how to convert a float to an integer to feed its count slot, so I switched to end points combined with resolution.

I can also easily extract the index property from the line vertices, just by using an attribute separate xyz of the vertex z position.

So here is the relevant part of my setup (lower left of the screenshot). The node graph of the tree already grew large as I have quite some variations inside.enter image description here

$\endgroup$
2
$\begingroup$

@Isolin's way seems much more in the spirit.. but here goes with a follow-up of @Gorgious' comment. This just gets a random-per-array-element attribute on to all the array-object's vertices.

enter image description here

  • Setting a U offset of 1 in the Array modifier
  • flooring the split-out U of the 'UV Map' attribute gives you an index per array element, on all vertices
  • That index can be randomized by using it to look up into some kind of noise texture: (clouds.. it's always clouds :) )
  • The random value per array element can be put through some kind of function to modify other attributes.

enter image description here

(Left: original .. Right: with GN )

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.