8
$\begingroup$

I'm trying to align corner pieces so they always face inwards and also maintain right angles, like so: example

By aligning instances to vertex normals I'm getting something like this (red face is always pointing inwards, so it's doing something right): current result Current nodetree: current nodetree

Earlier I tried to rotate or mirror instances by selecting them manually via vertex IDs, but that's tedious and not at all dynamic.

So the question is: what kind of vector math magic can I use to get the result in the first picture? Can it be done with vertex normals, or perhaps by somehow referencing neighboring points to get the orientation?

.blend file can be downloaded here.

PS: another question that was suggested while composing this one (How to properly orient instances along corner edges) didn't help very much.

Edit: typos

Edit 2: Temporary solution

I was able to scale (mirror) instances depending on their position in relation to bounding box center (if it's below, mirror along Z axis etc.): enter image description here enter image description here

That did the trick, but sadly it only works with simple boxes. Or you'll get something like this where mid-level corner pieces are incorrectly pointing upwards as they are below the bounging box center (this problem also applies to X and Y axis): enter image description here

$\endgroup$

2 Answers 2

8
$\begingroup$

Here's a way for all corners (except ambiguous).

enter image description here

Since the base mesh has a simple structure (Edges are aligned to X, Y or Z axis, normals and edge angles don't vary very much, except for the sign), the normals of the vertex and edge angles of connected edges can be used to determine if a vertex will get an instance or if it needs additional rotation.

If edges with angles equal to $0$ are ignored, determining if a corner is concave or 'semi-concave' is much easier (especially if there is inset faces). They can be ignored by transferring captured edge angles (captured to edges) from a mesh with edges of angle $0$ deleted:

enter image description here

Here's some values and what they mean here:

enter image description here

  • If the vertex has a number of edges equal to 3 (ignoring edges with angle $0$), it is a three-point corner. $$$$ enter image description here

  • 'Semi-Convex' corners (with one concave edge) have an average edge angle of $\large -\frac{\pi}{6}$. $$$$ enter image description here

  • Fully concave corners will have an average edge angle equal to $\large -\frac{\pi}{2}$. $$$$ enter image description here

  • Ambiguous corners (concavity of surrounding edges equals convexity) have an average edge angle of $0$, this is also true for non corner points (surrounding faces face same direction). Instances weren't put here. $$$$ enter image description here

  • 'Semi-Concave' corners (with one concave edge) have an average edge angle of $\large\frac{\pi}{6}$. $$$$ enter image description here

  • Fully convex corners have an average edge angle equal to $\large\frac{\pi}{2}$.

We can use these to do specific things depending on the properties of the corner.

Geometry Nodes:

enter image description here

Here only convex corners are selected:

enter image description here

enter image description here

You could put a different instance on ambiguous corners by checking the edge angle and using the result as instance index:

enter image description here

enter image description here

$\endgroup$
2
  • $\begingroup$ +1. Missed this one earlier. Really nicely done. $\endgroup$
    – Robin Betts
    Jul 11, 2022 at 7:36
  • $\begingroup$ Sorry for the long wait! I was honestly hoping to dissect your solution to get some understanding of how exactly it works and only then reply, but then life happened. I did not have a chance to dive into it, so I'll just mark it as a solution. All I can say is that it just works, and thank you dearly for your time! $\endgroup$ Sep 2, 2022 at 19:16
4
$\begingroup$

In the end, I did it with face normals by using three compare nodes and three switches. Compare nodes look if normal points in certain direction (positive X, negative Y, negative Z) and switches pass the corresponding scale value down the line where it gets added together and plugged into instancer's scale input: enter image description here

Result: enter image description here

All thanks to this guy Kammerbild on YT: "Blender: procedural buildings with geometry nodes fields | pt. 2"

$\endgroup$
3
  • $\begingroup$ How are you selecting convex v concave corners? $\endgroup$
    – Robin Betts
    Jun 13, 2022 at 10:50
  • 1
    $\begingroup$ @RobinBetts, if I understood correctly, you're referring to the fact that some vertices don't have corner pieces on them. I've somewhat cheated by using Vertex Neighbors and Math Less Than 4 nodes and plugged them into instancer's selection input. So any vertex that has 3 or less neighbors gets selected (you can see that in a nodetree screenshot in original post). $\endgroup$ Jun 13, 2022 at 11:25
  • $\begingroup$ Thx, sorry, missed it. :) $\endgroup$
    – Robin Betts
    Jun 13, 2022 at 12:46

You must log in to answer this question.

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