7
$\begingroup$

I need to subdivide a mesh of equilateral triangles so that each triangle gets subdivided into four new equilateral triangles. I want to use Geometry Nodes because I want to set the subdivision level interactively by entering the level in an input field.

I can achieve the desired result using Edge Subdivision in Edit Mode, but the procedure lacks the interactivity of Geometry Nodes.

The Subdivision Surface Modifier, the Subdivide Mesh node and the Subdivision Surface node, when correctly parameterized, all produce three quads instead of the desired four triangles (see attached images).

Is there other node or combination of nodes that can achieve the desired result interactively?

Thanks in advanced.

Desired result: four triangles (First subdivision level). Desired result: four triangles (First subdivision).

Three quads - Subdivision Surface Modifier, Mesh Subdivision Node or Surface Subdivision Node (First subdivision level). Three quads - Subdivision Surface Modifier, Mesh Subdivision Node or Surface Subdivision Node (First subdivision level).

$\endgroup$
1

3 Answers 3

9
$\begingroup$

One way to do this might be to simply recreate the mesh you want.

It's not clear from your question exactly what you plan to do, but you might find this approach helpful:

enter image description here

Here I simply scale the triangle by a factor of $0.5$, and instantiate it at its own points.

The missing piece in the middle is scaled by the same factor, but additionally rotated by $180°$.

Finally, I merge the pieces back together with Merge by Distance.


(Blender 3.2+)

If you want to create multiple subdivision levels, just put the nodes into a group and cascade them.


Update 1, here's what you're looking for....

If you really want the whole thing to be completely procedural, and keep the subdivision dynamic, then it gets a little more complicated.

It took me a while to figure out the structure too, but you can solve the problem with this:

enter image description here

The principle is the same as what I do in the example above, but a little more mature.

First, I duplicate the triangle and scale the individual duplicates according to the desired resolution, so that its vertices make the centers of the triangles in each row.

Then I filter out the triangles I don't need, and convert the remaining ones into curves, so that by resampling them I get a corresponding number of points for the triangles in between.

enter image description here

Finally, I apply only a few logic nodes to get a correct alignment of the smaller triangles.

enter image description here enter image description here


(Blender 3.2+)


Update 2, now it's really getting crazy....

Dear Robin, Node-Challenge accepted:

The same principle I use in the above examples can be taken even further and adapted for any mesh.

By not instantiating the original geometry as before, but simply using triangles and moving and scaling their positions, they can be placed directly in the required positions:

enter image description here enter image description here

Please forgive me for not having time to clean up and document the node tree this time ...there's still room for improvement. But I think the idea should be clear.


(Blender 3.2+)

$\endgroup$
9
  • $\begingroup$ Interesting and helpful approach. If I understand well this produces only the first level subdivision. Can it be used for an arbitrary subdivision level (2, 3, 4 ... cuts)? I want to set the subdivision level interactively. $\endgroup$ May 1, 2023 at 21:46
  • $\begingroup$ @JoeErcolino Yes, of course: just use a group and cascade it. $\endgroup$
    – quellenform
    May 1, 2023 at 21:51
  • $\begingroup$ I would like to set the subdivision level interactively, that is to say by entering the subdivision level in a field without having to modify the Geometry Nodes. Modifying the Geometry Nodes to set the subdivision level contradicts the non-destructive characteristic of GN. $\endgroup$ May 1, 2023 at 22:43
  • $\begingroup$ @JoeErcolino OK, I took another look at the issue, and found an interesting solution. However, this would be more for advanced users. Maybe this will help you. $\endgroup$
    – quellenform
    May 2, 2023 at 17:49
  • 1
    $\begingroup$ Really great stuff! I'm working on one .. the strategy: expand the triangle(s) to a parallelogram across the shortest edge, delete shortest edge for a clean quad, subdivide the parallelogram, triangulate (by shortest edge method), delete faces beyond the end of the original triangle. I haven't had much time and made patchy progress. I'm sure you could implement it more cleanly than me. But I may post it anyway, when done... eventually ... :) $\endgroup$
    – Robin Betts
    May 2, 2023 at 21:48
4
$\begingroup$

This one isn't going to win any rounds of Node Golf.

Given a set of separated triangles:

  • It uses the sorting capacity of Corners of Face to find the corner after the shortest edge of each triangle.
  • Based on that info, extrudes long edge 1 in the direction of long edge 2 to create a parallelogram
  • Deletes the original triangular face, having stored the ordered point-positions of its shortest edge.

..enter image description here

I'm afraid there's so much capturing and domain-wrangling, the above picture is barely readable.

Anyway, once you're there, you can subdivide and triangulate the parallelograms by shortest edge:

enter image description here

.. and detect normal-viewed 'left' or 'right' of the short edges of the original triangles to delete the unwanted halves of the parallelograms.

The result seems quite robust, so far:

enter image description here

$\endgroup$
4
  • $\begingroup$ Why shouldn't this wonderful answer win a prize!? I think the idea is great! $\endgroup$
    – quellenform
    May 3, 2023 at 10:02
  • $\begingroup$ Well, @quellenform, you can buy me a consolation G&T at the 19th, but I think you won the cup, this time :) $\endgroup$
    – Robin Betts
    May 3, 2023 at 10:04
  • $\begingroup$ Well, strictly speaking, my solution answers the question quite precisely, but it is unfortunately only applicable to a single equilateral triangle that is flat on the ground. $\endgroup$
    – quellenform
    May 3, 2023 at 10:07
  • $\begingroup$ @quellenform I've yet to find a good way of filling mesh edge-only--loops at arbitrary angles/positions?.. maybe I should post that as one for you to answer :) $\endgroup$
    – Robin Betts
    May 3, 2023 at 10:10
1
$\begingroup$

One more way to do it: using parametric coordinates of a triangle.

Three steps in this solution:

  • Defining a right triangle with the good amount of subdivisions
  • Instanciate this triangle on each face first corner
  • Calculate the position of the realized instances along their corresponding face corners

enter image description here

-Defining the base shape (right triangle)

enter image description here

It creates a grid 1x1 meters with the good amount of vertices (2^n + 1).

Then place it at starting position (0,0).

Stretch it along Y to ensure the triangulation along the wanted longest diagonals.

Stretch it back to 1 by 1 meters.

Removes upper vertices so that from a grid, we keep a triangle.

An illustration of this steps:

enter image description here

-Instantiate on faces first corner

enter image description here

Triangulate the mesh.

Capture the face indices.

Transform the faces to points, placing each point at the first corner of each face.

Instantiate on there points the right triangle created above and realize the instances so that we can move their individual vertices.

-Calculate the parametric positions

enter image description here

Extract the corners positions of each face (the "corner position" group node simply samples the face corner to retreive its position).

As the right triangle is placed at the first face corner, shift it back from (0, 0) X and Y coordinates. Then extract its original positions in X and Y.

These positions are the parametric factors to go along "corner0 -> corner1" and "corner0 -> corner2".

Then add back "corner0" position, which is the final position to set.

enter image description here

$\endgroup$

You must log in to answer this question.

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