Hello !

I needed a little break from my procedural buildings , so after seeing an amazing talk by Anastasia Opara I tried to reproduce her book generator in blender (toward 26mn in the talk) :

I didn’t think it would be that much complicated, but eventually I figured out a way of doing it…

Mainly because there is no loop in geometry nodes yet, I find that it was hard to replicate exactly how she did it. So I find my own way in the end.

For those interested here is a short description of the method :

I start by generating some points and some random values for scale and rotation.

At this stage what I get is something like that :

The cubes are instanced on points and scaled / rotated according to the random values.

Then comes the tricky part, it’s basically a lot of vector operations based on these random values.

The basic idea is to do all the calculations beforehand , to know the exact position of the book according to their rotation and scale, and when I get these value I can instance object or do some modeling based on that.

The first step was to get these vectors :

It’s not taken from the geometry, but by taking the random values and do some math operation . Like taking the Z random scale and use rotate vector on that according to the random rotate value (that will give the purple lines).

At some point I had to make a group that help me visualize these values, forming these colored arrows.

Then comes the most difficult part, using previous vectors I look for these ones :

That’s basically the contact points between two books.

I used the Field at Index node to inspect the next “book” .

You can see that the red arrow change direction depending if one book is next to a bigger book.

The direction isn’t relevant, but I needed to find the upmost corner of the smallest book between two books and point toward the biggest.

To give these arrows the right length I needed a way to get the intersection point between two lines , because at this stage there isn’t any geometry to do some raycast .

I looked up for finding the interesection point of two segments in 3D.

And I ended up translating this code into geometry nodes.

Then I find the intersection point of the red arrows with the purple or blue lines in the previous capture.

Once that was done, the last step is to take the shortest line between the red and the green , and substract that from the original positions :

And all the books will stack between each-other \o/ !

There is still some way to make that fail, there are some intersection in the black circle because it only take into account the closest books, but if there isn’t too much variations in size it will work !

At this stage I could then build the books.

The good thing in having only fields and do all the calculation beforehand, is that I can model the books straight , witch is much simpler, and rotate them in a last step :

because rotation and center points are stored in the geometry as attributes, I can always access them down the line and use them when I want…

I think it’s the most involved thing I’ve done in GN yet, despite the visual simplicity of the result.

I’ve learned a lot in the process !

I hope at some point doing things like that could be less involved, on a production I would have probably gave up and used a more manual approach which would have been faster, unless there are really a huge amount of books and client would be phobic of repetition patterns.

I’ll see if I can build a bit more on that now that the difficult part is figured out…

If someone look into it I would be really glad to know of other ways of doing it (hopefully simpler) that would allow these kinds of rotation / distribution !

Thanks !