4
$\begingroup$

I am trying to use geometry nodes to build a wall, where the stones of every second layer are offset to create a brick-like pattern. I tried using mesh lines to points for more control, so that I could access every line separately. I instantiate a vertical mesh line for the vertical dimension, then a horizontal one for every point on the vertical one, then convert the whole thing to points and instantiate the original brick on every point.

The problem is I want to add a slight variation of scale and rotation to every instance of the original brick. All advice recommends simply plugging in a random value to the "instance on points" node, but when using the double mesh lines approach the result looks like this: original approach using double lines

I know I can simply use a grid mesh, as it seems to make all the points "equal" and randomization of rotation works just fine: Second approach using a grid mesh

Unfortunately I do not know how to offset every second horizontal line of points in a grid mesh. So my question is twofold: is it possible to achieve an actually random rotation for every instance in the first approach, and/or is it possible to offset every second line of points in the second one?

$\endgroup$

1 Answer 1

3
$\begingroup$

First of all, you can instance objects on the Mesh Line points without having to convert them with Mesh to Points.

The next thing is: when you use the Grid for Instance on Points, on each point of the grid is created a new instance with its own index in X and Y direction. So each instanced cube is rotated individually.

When you instance the vertical lines on the horizontal line, the points on each line instance and the instanced cubes are indexed 0, 1, 2, 3. So they all share the same indices according to their position on the line and so they get the same random value.

To change that the more complicated way you could use a Capture Attribute node to get the indices of the line instances and add them to the cubes indices to make them all have different values or the easier way is to Realize Instances after the second Instance on Points node, so that each point of each line has an individual index.

random instances

By the way, I do not know if this is on purpose: you are using random Float values instead of Vector values. This way, each of the three axes is rotated by the same random values. With a vector output each axis on each cube would get an individual random value, so instead of a random (0.3°, 0.3°, 0.3°) for example it could be (0.3°, 4.2°, 1.8°).

$\endgroup$
8
  • $\begingroup$ Thank you much! Realizing Instances worked of course — I am still not used to the concept of inherited attributes in this system... Re.float rotation and unnecessary converting to points — thanks for the info! Tbh I was trying to solve this without asking so I built and rebuilt the logic several times, so some of the unnecessary steps were left in by accident. $\endgroup$
    – swat6296
    Commented Jul 25, 2023 at 8:03
  • 1
    $\begingroup$ Oh, another thing: if you would look into the Spreadsheet for the rotation of the cubes, you might see negative values although your minimum is set to 0. These can appear for max values larger Pi/2, because the cosine of these values is negative and are the same for cos(1.6) = cos(-1.6), so although the output of the Random Value is between 0 and X > Pi/2, the resulting rotation value stored in the instances will always be between -Pi and +Pi. There is something similar in the opposite direction when you have min values smaller than -Pi/2 and max value is 0. $\endgroup$ Commented Jul 25, 2023 at 8:26
  • $\begingroup$ The confusion here stems from the fact you can access internal indices of an instance. Something Robin Betts has used in multiple answers of his like here $\endgroup$ Commented Jul 25, 2023 at 10:39
  • $\begingroup$ @MarkusvonBroady Yes, definitely. But to explain the different behaviour between how it works with the grid and lines instanced on lines this is not necessarily relevant. On the (original) grid each point is an individual element, whereas the (instanced) line points are not individual per se. $\endgroup$ Commented Jul 25, 2023 at 11:00
  • $\begingroup$ @GordonBrinkmann it is relevant because without knowing about this fact I would either expect that without realizing instances, there are no points, and therefore nothing is spawned on the 2nd "Instance on Points", or instances are treated as points, therefore only 4 cubes are spawned (because there are 4 instances), and yet here, as far as I understand, each vertex of each instance is being accessed, but when it comes to ID, only ID of an instance (not vertex of instance) is being accessed. 🥴 $\endgroup$ Commented Jul 25, 2023 at 11:31

You must log in to answer this question.

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