11
$\begingroup$

I've been trying to build a Geometry Node group that in part is able to create a mesh of even thickness around a three-dimensional curve that features sharp corners.

After much research I'm aware that Blender is unable to do this with it's own Curve Profile system due to flaws in how it handles three-dimensional curves, but is there a way this can be solved in some basic way through Geometry Nodes and something like a Mesh Extrusion node by providing it a correct Offset for each corner?

I'm not great at this kind of mathematics and I don't want to be stuck in a Pythagoras maths hole for a week to find the missing link here. One Stack Overflow post mentioned something involving calculating the Secant but they never explained why and I wasn't able to replicate their math.

Left is what I want, middle is what I get by default, right is an approximation of the curve being used.

Left is what I want, middle is what I get with my current Geometry Nodes stack with just some sharp corners, right is an approximation of the curve being used.

$\endgroup$
3
  • $\begingroup$ does your curve lay on a plane..? in that case it's a lot easier to get something decent... in fact you could just use a 2D curve and get pretty good results -if it looks as in your picture- $\endgroup$
    – alambre
    Apr 10, 2022 at 3:27
  • $\begingroup$ I can minimize it to a 2D plane in the worst case scenario and I'm aware solution exist for it, but for now I'm trying to solve this in 3D. $\endgroup$
    – Takanu
    Apr 10, 2022 at 14:07
  • $\begingroup$ Hi there, I am involved in addressing this issue in Blender. This is still in development but closing in on a solution and that'd be great if you could provide some feedback here: devtalk.blender.org/t/… - Thanks in advance! $\endgroup$
    – Bruno
    Jan 14, 2023 at 9:49

1 Answer 1

19
+500
$\begingroup$

Unfortunately, the problem cannot be solved without mathematics, but with this example you should still be able to achieve the desired result:

Roughly speaking, you would just have to calculate the scaling factor for the cross section at your points and apply it as offset to the mesh.

  1. First you need the direction vector between two points.

    To be able to work on cyclic curves with this setup, the math node Wrap helps you to find the right index of the points.

    Additionally, if you are working on multiple curves at the same time, the index value of the point where the individual curves start is added here. You achieve this with the node Accumulate Field.

    This value is then the index of the next point within a spline, which you feed directly into the node Field at Index.

    To get the direction vector simply subtract the position of the current point from the position of the next point.

  2. Then you would have to calculate the angle between two edges/lines.

    With the help of the math node Arccosine you can get the angle from the previously calculated direction vector and the normals of the points which you get directly from the Curve to Points node.

    In fact, this result is then the angle bisector between two edges, which I call here $\theta$.

  3. After you have applied your Curve to Mesh, you only have to use the Set Position node and offset the individual points of the mesh with a certain scaling factor.

    You get the factor of scaling with the formula $\vec{a} \circ \vec{b} \times(\frac{1}{\sin(\theta)}-1)$.

    Where $\theta$ is the bisected angle between two edges/lines, $\vec{a}$ is the normal of the curve point and $\vec{b}$ is the direction vector between the points of the generated mesh and the original curve point.

    In order to get a correct result even for curves that are not cyclic, create a selection beforehand that omits the first and last points depending on the value of Is Spline Cyclic.

The result should then look like this:

Result

Node Tree


(Blender 3.1+)

$\endgroup$
12
  • $\begingroup$ great answer! seems to work a lot better than default 3d curve $\endgroup$
    – alambre
    Apr 11, 2022 at 17:46
  • $\begingroup$ Thanks! ...the only drawback is that the normals for a Shade Smooth are not calculated until you convert the object to a mesh, since you can't set normals with Geometry Nodes. However, the same problem exists with Curve to Mesh without this technique. Therefore, both variants have their advantages and disadvantages. $\endgroup$
    – quellenform
    Apr 11, 2022 at 18:03
  • $\begingroup$ This answer is incredible, I'm going to look at it in more detail tomorrow but from poking at the Blend file this clearly solves the problem. Also your GitHub stuff on curves is awesome and really helpful for the things I'm trying to make. Thanks so much! $\endgroup$
    – Takanu
    Apr 11, 2022 at 18:29
  • 1
    $\begingroup$ For anyone wondering how to deal with the loss of the Transfer attribute node please refer to this post blender.stackexchange.com/questions/276087/… $\endgroup$
    – Gorgious
    Feb 12, 2023 at 11:50
  • 1
    $\begingroup$ Hehe my pleasure, what's the use of being an internet points millionnaire if I never use it to reward excellent answers :) $\endgroup$
    – Gorgious
    Feb 22, 2023 at 18:53

You must log in to answer this question.

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