# How to subdivide triangles into four triangles with Geometry Nodes?

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?

Desired result: four triangles (First subdivision level). Three quads - Subdivision Surface Modifier, Mesh Subdivision Node or Surface Subdivision Node (First subdivision level). 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: 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.

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: 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. Finally, I apply only a few logic nodes to get a correct alignment of the smaller triangles.

## 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:

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.

• 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. May 1 at 21:46
• @JoeErcolino Yes, of course: just use a group and cascade it. May 1 at 21:51
• 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. May 1 at 22:43
• @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. May 2 at 17:49
• 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 ... :) May 2 at 21:48

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.

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: .. 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:  • Why shouldn't this wonderful answer win a prize!? I think the idea is great! May 3 at 10:02
• Well, @quellenform, you can buy me a consolation G&T at the 19th, but I think you won the cup, this time :) May 3 at 10:04
• 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. May 3 at 10:07
• @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 :) May 3 at 10:10

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 -Defining the base shape (right triangle) 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: -Instantiate on faces first corner 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 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.  