Skip to content
ImagineWorld

Editing Curves with Nodes

node_idnode-book_procedural-3d-modeling-using-geometry-nodes-in-blender_chapter-08-editing-curves-with-nodes
node_typechapter-node
schema_profileworld.chapter_node.v1
statusactive
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
chapter_num8
chapter_titleEditing Curves with Nodes
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

In the previous chapter, we went over the string system inside the Geometry Node editor. Those strings were converted into Curves to visualize them in the Viewport.

In this chapter, we will be taking a closer look at some fun things we can do with the Curve system in the Geometry Node editor, such as adding noise to Curves and adding thickness to these Curves.

These skills are very useful if you want to manipulate Curves in Geometry Nodes in anything from proceduralism to creating art.

We will discuss the following topics in this chapter:

  • Adding randomization to your Curves
  • Giving thickness to your Curves
  • Exercise – creating a growing twig animation

Some figures in this chapter show the full Blender setup, including node trees, outcomes, and parameter settings. For easier viewing and readability, these figures are also available in the book’s GitHub repository.

You can find the exercise and demo from this chapter in the common .blend file in the GitHub repository.

In this section, we will show you how to manipulate your Curves by adding a randomization pattern to them. This will be handy if you’re making anything that involves a Curved Line of some sort, for example, a growing twig or a tree trunk.

In Figure 8.1, you can see the nodes that we will be using in this section:

Figure 8.1: The nodes you’ll need

Let’s take a quick look at the individual nodes:

  • Noise Texture: We will need the Noise Texture node to add noise randomization to our Curve.
  • Random Value: This node’s responsibility is to return random values in the selected datatype. In this demo, we’ll use the Vector datatype. This means that it will generate three random values within the set boundaries for each vertex.
  • Set Position: This is the most important node in this section because it is responsible for modifying our Curve. The task of this node is to set the position of different points in your geometry. For example, it can be used to add some randomization to your Curve by plugging a noise map into the Offset socket.
  • Vector Math: This node is handy for computing mathematical calculations over vectors. For example, we can multiply, subtract, divide, add, and much more. This node’s name reflects the mode it’s set to, much like the normal Math nodes.
  • Resample Curve: Lastly, this node will interpolate geometry into your Curve. In the case of this demonstration, we will be using this node to get more geometry into our Curve with the help of a higher resampling count to get a better-looking noise pattern. A higher resampling count means a higher resolution of your Curve and more geometry in your Curve.

Now that you know the nodes we’ll be using in this section, let’s get started with adding randomization to our Curves!

Let’s start by teaching you how to randomize your Curve by making use of the Random Value node:

  1. Firstly, go ahead and make a Curve in Edit mode. This can be any shape you want.

Figure 8.2: Draw a Curve

  1. After that, we can open the Geometry Node editor. Let’s add a new node tree to this Curve object.
  2. Now, it’s time to make use of the Set Position node. This node will offset the position of geometry by using either the Position input or the Offset input.

Figure 8.3: The Set Position node

In this demonstration, we will make use of the Offset input because we want to offset the geometry by a random value.

  1. Let’s start by adding this Set Position node in between Group Input and Group Output.
  2. At first, you’ll notice that nothing happens. This is because we have not modified the geometry in any way. Let’s start modifying this Curve by adding a Random Value node set to Vector. We’ll set the Min values to -1.000 on all axes. Let’s also set our Max values to 1, which is the opposite of our Min values. This is to make the results even out nicely. This is crucial when you want your geometry to shift evenly.

Figure 8.4: The Random Value node set to Vector

  1. Let’s plug in the output vector socket into the vector Offset input of the Set Position node.

We can see that depending on how much geometry you have in your Curve, the Curve wiggles a bit. If we want to get more detail in our randomization, the Curve needs to be resampled.

Figure 8.5: The Resample Curve node

Resampling is the process where we interpolate more geometry into the Curve to have more control points to work with. This can be useful for tasks such as distributing points or, in this case, randomizing a Curve by offsetting each control point.

  1. To achieve this, we can add a Resample Curve node in between the Group Input node and the Set Position node. Let’s give this node a Count value of 50.

If you’ve executed these steps correctly, this is how your node tree should look:

Figure 8.6: Your current node tree

You can tweak the Random Value node to your liking; just keep in mind that the Min value should be the negative of the Max value. Doing this will ensure that your mid-level value will be equal to 0. You can also play around with the Count value to get more resolution in your randomness.

In Figure 8.6, we can see that the Curve is very chaotic. One way to fix this is by using a Noise Texture node instead of Random Value, which we’ll cover in the next section.

Let’s continue with our previous project file, but we’ll remove the Random Value node, as we will be using noise textures to drive our randomness now:

  1. Let’s start by adding a Noise Texture node to our Geometry Node editor. Connect the Color output to the Offset input.

Normally, mixing two datatypes is not recommended. In this case, it doesn’t matter, as the Color and Vector datatypes are very similar. Both of these datatypes consist of three values in one datatype and will be read in the same way.

  1. Once you connect the Noise Texture node correctly, you’ll see that our Curve starts wiggling again. There is a problem, though; the wiggled Curve is deviating slightly from our original Curve.

This is because Noise Texture node values go from 0 to 1. This causes an imbalance in our offset. As mentioned in the preceding section, to fix this, our minimum and maximum values need to be on opposite sides of each other.

  1. To balance this Noise Texture node, we’ll need a Vector Math node set to Subtract. Let’s drop this node in between the Noise Texture node and the Set Position node. Let’s subtract 0.5 on all axes in the Vector Math node.

If you executed these steps correctly, your node tree should look something like this:

Figure 8.7: Your current node tree

Let’s say that we also want to control how much our noise pattern affects our Curve. We can do this using another Vector Math node set to Multiply. This time, we’ll drop it after the other Vector Math node we just added.

Once you increase all three values of the Multiply Vector Math node, you’ll see that the distortion increases!

Figure 8.8: The distortion increases

If your Curve is still quite pointy after increasing the distortion, try increasing the Count value on your Resample Curve node. This will add more resolution to your Curve.

Feel free to play around with the parameters.

Now that you have mastered how to add noise to your Curves, it’s time to practice how to control the thickness of your Curves!

In this section, we’ll show you how to give your Curves thickness, along with some handy nodes to use in the Geometry Node editor.

In Figure 8.9, you can see all the nodes that we will use in this section:

Figure 8.9: The nodes you’ll need

Let’s take a quick peek at the nodes individually:

  1. Float Curve: This node works by mapping an input float to a Curve and then outputting this as another float value. It processes values from 0 to 1 and the Curve editor seen on this node also represents 0 to 1. This will be explained in depth in the Advanced thickness control section.
  2. Spline Parameter: This node will output info about your Curve if your base object (the object you’ve made in Edit mode) is a Curve. Here, you can see the outputs of the Spline Parameter node, along with their functions:
    • The Factor value will return the progress of the Curve in a value from 0 to 1. 0 means the beginning of the Curve and 1 means the end of the Curve
      • The Length value will return the length of the Curve
      • The Index integer value will return the unique identifier of each Curve that the object contains
  3. Curve to Mesh: This node will convert a Curve, like the one we’re working with in this chapter, into a mesh that we can use to display geometry. The Profile Curve input of this node will define the profile that this Curve will use based on whatever you plug into this input. Keep in mind that the Profile Curve input only accepts other Curves. There’s also an extra input called the Scale input, which controls the thickness of your outputted mesh.

Now that we have a fair idea of the nodes required to control the thickness of Curves, let’s see how to implement them!

Let’s get started by learning how to add thickness to our Curves:

  1. Start by drawing a Curve in Edit mode again. This can be any shape you want.

Figure 8.10: Draw a Curve

  1. Next, we’ll open the Geometry Node editor to add a new node tree to this Curve.
  2. To get started with controlling the thickness of this Curve, we will need to drop in a Curve to Mesh node to convert our Curve into a mesh.
  3. You will see that nothing happens because we do not have a Profile Curve yet. Let’s use a Curve Circle as our Profile Curve, as shown in Figure 8.11. You can change the Radius input of your Curve Circle to your liking.

Figure 8.11: Your current node tree

  1. Let’s now start controlling the thickness of our Curve. We will do this by changing the value of our Scale in our Curve to Mesh node.

After you’ve done that, you should be able to control the thickness of your Curve!

Let’s configure our node tree so that we have finer control over where the thickness occurs in our Curve. We can do this by making use of the multi-valued node connection that the Scale input of the Curve to Mesh node uses.

Let’s start simply:

  1. We will add a Spline Parameter node to obtain the Factor value of our Curve. As said before, the factor value returns the progress of our Curve.
  2. Let’s drop in a Spline Parameter node and connect the Factor output to the Scale input of the Curve to Mesh node.

As you can see, the beginning of our Curve is thick and the end of our Curve is thin because the Factor represents the beginning and end of our Curve in a number. So, if we use that number to reflect our thickness, we get this specific result, as shown in Figure 8.12:

Figure 8.12: Thickness driven by the Spline Parameter node

We get this specific result because as our Curve starts out, our Spline Factor starts at 0, which results in a narrow point. As our Curve progresses, the Spline Factor will increase to 1, which is exactly what we see in the Viewport.

  1. Let’s take this a bit further. We can define a custom thickness gradient by adding a Float Curve node, which will convert this 0 to 1 value into any gradient that we want.

For example, let’s add a Float Curve node in between the Spline Parameter node and the Curve to Mesh node and modify the Float Curve to look like the following figure:

Figure 8.13: The Float Curve editor

As the Curve editor shows, the beginning and end of the Curve will be thin, but the middle of the Curve will be thick, with the end being thin again. When we look at our Viewport, we can see that this is exactly the case, as shown in Figure 8.14:

Figure 8.14: The Viewport

With that, we’ve come to the end of this demonstration. You now possess the skills to start working on the exercise in the next section, where you will be creating a growing twig animation.

Exercise – creating a growing twig animation

Section titled “Exercise – creating a growing twig animation”

In this exercise, it’s time to put your newly founded skills to the test. We will be creating an animation where a twig grows procedurally.

Let’s think about the steps we need to take to achieve this effect:

  1. Start with a Curve Line primitive.
  2. Add noise to this Curve with a Noise Texture.
  3. Adding a profile to our Curve.
  4. Add thickness control to the Curve.
  5. Animate it!

Now that you know the rough outline of how this project will go, let’s get started!

In the previous demos of this chapter, we have always used a predefined Curve object to start our node tree. This time, we want the Curve to grow, so we will use a Curve Line node.

Figure 8.15: Curve Line node

This will allow us to make the Curve larger or shorter procedurally, which is exactly what we want.

Let’s get started building this node tree!

  1. Once you have started up a new geometry node project on the default cube, go ahead and disconnect the default Group Input node and replace this with a Curve Line node.
  2. In Figure 8.15, you can see that the Curve Line node got an End input on the Z axis. We will need this input to control how long our twig is.
  3. To access the End input’s axes separately, let’s add a Combine XYZ node to your editor and connect it to the End input of the Curve Line node.

Now, we can see that the axes have separate inputs. We’re interested in the Z axis, since this is the axis that is pointed upward.

  1. Let’s connect the Z axis to a Value node. This will allow us to control the height of our twig. For testing, let’s leave it at 5 for now.

If you have followed these steps correctly, this is what your node tree should look like:

Figure 8.16: Your current node tree

Now that we’ve got our basic Curve, it’s time to drive this Curve with a Noise Texture!

To do this, we have to largely follow the same steps as in the demo before this project:

  1. Let’s add a Set Position node between the Curve Line and the Group Output node. This will be responsible for shifting the control points in our Curve.
  2. Let’s also add a Noise Texture node to our project and connect the Color output to the Offset input of our Set Position node. Make sure the Noise Texture node has a Scale value of 0.2, which looks the most natural for a growing twig.
  3. Once you do this, you’ll see that your Curve shifts a bit to the X and Y axes. Just like before, we need to subtract 0.5 from all axes on the vector to establish the mid-level of our Noise Texture.
  4. To do this, let’s add a Vector Math node set to Subtract with values of 0.5 on all axes and drop it between the Set Position node and the Noise Texture node.

This will normalize the position and return our Curve to the origin point of your object.

  1. We can also see that our Curve only consists of two points. To add more resolution, we can add a Resample Curve node after our Curve Line node. Let’s set it to Length with a value of 0.1. This will ensure a control point will be placed for each 0.1 unit of our Curve.
  2. For our next step, let’s add a profile to our Curve. To do this, let’s add a Curve to Mesh node with a Curve Circle node as our Profile Curve. Let’s set the Radius of this Curve Circle to 0.1.

If you have followed these steps correctly, this is what your node tree should look like:

Figure 8.17: Twig without thickness control

Our Curve still does not look like a twig, though, so let’s fix that!

Let’s add some thickness control to our twig:

  1. To do this, let’s utilize the Scale input on our Curve to Mesh node.
  2. Just like before, let’s use a Spline Parameter node’s Factor output to drive the Scale of our Curve to Mesh node. You will see that this results in an upside-down twig. This is not what we want, obviously.
  3. To fix that, let’s add a Float Curve node between the Spline Parameter node and the Curve to Mesh node.
  4. We want our twig to end pointy. To do that, let’s reverse the pattern of the Float Curve node, as shown in Figure 8.18:

Figure 8.18: Float Curve configuration

If you have followed these steps correctly, this is what your node tree should look like:

Figure 8.19: Your current node tree

When you take a look at your Viewport, you can see that we kind of already have a twig-shaped object! But we can definitely improve it.

Let’s start with the obvious. Right now, the twig wiggles on all positions equally. We want it to be a gradient instead, with the top of the twig moving the most:

  1. To do this, let’s add a Vector Math node set to Multiply after the Vector Math Subtract node.
  2. Let’s connect the Factor output of the previously added Spline Parameter node to the second multiplication field of our Vector Math node.
  3. Now, we can see that the base of our twig is static and will not move.
  4. Some users would like the twig to have more shape—that’s perfectly possible! All we have to do is add another Vector Math node set to Multiply and drop it after our previous Vector Math node.
  5. Choose a value that looks good to you. For this demonstration, we went with a multiplication value of 6.

And with that, our basic twig is now completed! The next step will be to animate it.

Let’s head back to the far left of this node tree, to the Value node, which we added near the beginning. When we change this value from 0 to 10, we can see that our twig grows procedurally:

  1. To animate this, let’s go to our first frame by pressing Shift + Left Arrow.
  2. Let’s start animating our value node by setting its value to 1 and, while hovering over this value, pressing the I key on your keyboard. This will turn this field yellow/orange.
  3. Let’s do the same thing but at frame 150. Let’s enter 8 into our Value node and press I on the field again.
  4. Once you play the animation, you’ll see that your twig grows! If you want extra variation during the growing, like real twigs would, we can perform some extra quality steps.
  5. All we have to do to achieve this is change our Noise Texture from 3D to 4D. This will add a new input called the W input (see Figure 8.20), which is like a seed value to our noise.
  6. Let’s connect our previously mentioned Value node to this W value as well. This means that we will change our noise pattern throughout our animation. This makes the twig look way more natural.

And with that, our procedural twig animation is finished! Here’s a full look at the entire node tree we have created:

Figure 8.20: Your finished node tree

If you want to challenge yourself, you can figure out how to create Group Inputs to this node tree to easily control the various parameters we have added along the way.

And with that, we come to the end of this chapter!

In this chapter, you learned how to manipulate Curves in the Geometry Node editor by adding noise to them and giving them thickness. You also learned how to use various nodes, such as the Noise Texture node, the Combine XYZ node, the Set Position node, the Vector Math node, and the Resample Curve node, to achieve these effects. In addition, you learned how to create a procedural growing twig animation.

These skills are useful for creating various types of Curved objects and shapes in Blender, such as growing twigs and other organic shapes. Adding noise to your Curves will allow you to add variation between models, which makes your scene look more realistic. Being able to manipulate Curves in this way can allow for greater flexibility and creativity in your projects.

The next chapter will delve into the exciting topic of using Geometry Nodes to modify meshes. With this powerful tool at your disposal, you will have the ability to transform the geometry of your meshes in a variety of ways.