Geometry Nodes is one of the latest additions to the ever-evolving world of Blender and is one extremely powerful tool. It allows you to create and change an object's geometry in more complex ways than regular modifiers, and it allows you to create complex scenes quickly and in non-destructive ways, meaning you can always go back and tweak some of the parameters, making it extremely dynamic and versatile. Welcome to the exciting world of Geometry Nodes!
One thing to note is that Geometry Nodes is still being developed extensively by the developers of Blender, which means that new nodes will be added, and more workflow options will be available to you, making it one of the most exciting new features to come to the Blender toolset.
In this chapter, you will learn how to use some of the most popular nodes, and you will get a feel of what you can do using Geometry Nodes. You will learn how to distribute objects on points, using Math nodes to calculate attributes such as the distance between objects, as well as how to modify certain attributes such as scale, position, and rotation. Additionally, you will learn how to randomize certain attributes, which is important when creating dynamic motion graphics scenes.
This chapter will give you a good, but basic, understanding of Geometry Nodes, and later in this book, we will make use of other methods that will build on this chapter.
In this chapter, we're going to cover the following main topics:
- Introduction to Geometry Nodes in Blender
- Creating and manipulating geometry using nodes
- Using textures to control attributes
- Animating with Math nodes
All the projects in this book have been created and built on Blender 2.93.x. The projects should work perfectly fine with Blender 3.x versions too. There may obviously be slight changes going forward as they develop Blender 3, but most of the changes they usually do are minor and should not break any workflows. However, the Geometry nodes chapters will work strictly on versions 2.93.x, since these nodes are updated with every version change. Version 2.93 has Long Term Support (LTS) till 2023 and you can download it from here. https://www.blender.org/download/lts/2-93/
All the projects of this book have been uploaded on Github here: https://github.com/PacktPublishing/Taking-Blender-to-the-Next-Level
Introduction to Geometry Nodes in Blender
In this section, we will be looking at the Geometry Nodes workspace and how to apply the Geometry Nodes modifier to our base mesh. Additionally, we will take a quick look at the different nodes that are currently available in Blender. You will learn how to distribute an instance object across points on another object. Additionally, we will make use of some of the most used nodes such as the Point Instance node and the Subdivide node. You will also learn what attributes are and how you can use them to change the way your instance objects are displayed. Finally, we will use nodes to randomize different attributes of our instance objects such as the position, rotation, and scale.
The Geometry Nodes workspace
Geometry Nodes functions as a basic modifier, but it also has its own workspace and editor. If you look at the top of the Blender interface, you should see a tab called Geometry Nodes. Additionally, you can change any window in Blender to the Geometry Nodes workspace by clicking on the drop-down menu in the upper-left corner of the window and selecting Geometry Node Editor from the list of available workspaces. This means you always have control over how you work:
If you look at the workspace, you will see the 3D Viewport window in the upper-right corner, the Spreadsheet window in the upper-left corner, and the Geometry Nodes window at the bottom. Currently, there is a total of 63 nodes in Blender version 2.93.2, but this number will quickly grow in later versions of Blender:
One area that Blender has been lacking in for a while now is in the creation of MoGraph dynamically; Geometry Nodes changes that completely by turning Blender into a powerful MoGraph-making machine! The reason why Geometry Nodes is perfect for MoGraph is that you can quickly manipulate many objects at once and because of its non-destructive nature. Additionally, you can introduce textures to drive movement or even use other modifiers in conjunction with Geometry Nodes.
Another great use for Geometry Nodes is for scattering objects quickly and easily. In previous versions of Blender, we had to make use of a particle or hair system to scatter objects across geometry, and that only gave us a certain amount of control. However, with Geometry Nodes, we have complete control to customize our node tree exactly the way we want.
You can even expose some of the parameters and values directly in the Modifier panel, making it very easy to customize your Geometry Nodes creations or giving you the ability to build custom node setups to share with others.
As mentioned earlier, there are currently 63 available nodes to use (including the Frame and Reroute nodes), as shown in the following screenshot. This number will likely increase with later versions:
If you have used the Compositing or Shading workspaces before, then you should be familiar with using nodes. However, don't fear if this is your first time using nodes. It can be very daunting at first, but we will look at the process step by step, and in no time, you will be able to create amazing and dynamic scenes using Geometry Nodes. In the next section, we will create our first, very basic node setup, and see it in action!
Creating and manipulating geometry using nodes
In this section, we will be creating our very first basic scene using Geometry Nodes. You will learn how to add the Geometry Nodes modifier to your base mesh and how to instance an object onto each vertex of your base mesh. We will look at some of the nodes that you can use to manipulate these instances such as Position, Scale, and Rotation. Additionally, you will learn how to randomize certain attributes, and we will also take a look at the different types of attributes and how they are used.
Let's begin by creating a new Blender project.
Creating the base mesh
Let's begin by creating our base mesh. For this example, we will be creating a plane object and applying the Geometry Nodes modifier to it. Then, we will use this plane object to distribute instances of another object across it:
- Click on File and select New | General.
- Delete everything in your scene by pressing A and then pressing X. Click on Delete to confirm. You now should have a blank new scene. Now feel free to save your project!
- Create a plane by pressing Shift + A and selecting Mesh | Plane.
Now, let's scale our plane.
- Select the plane, press S, then 10, and then Enter. This will scale your plane to a size of 10 m x 10 m. It's always good practice to select Apply your scale whenever you modify the scale of an object in Blender, especially if you will be adding any modifiers to that mesh.
- To do this, select the plane, press Ctrl + A, and then select Scale from the drop-down menu. This will apply the scale factor and reset the object's scale to 1:
- You can view the scale factor by selecting your plane and pressing the N shortcut to open the side menu. In the Item tab, underneath Transform, you will see the Scale factor, which should currently be X: 1.000/Y: 1.000/Z: 1.000:
Creating a new Geometry Nodes modifier
Now, let's open the Geometry Nodes workspace by clicking on the tab at the top of the Geometry Nodes interface. You will now see the Geometry Nodes workspace split into three main views: the 3D Viewport window (in the upper-right corner), the Spreadsheet window (in the upper-left corner), and the Geometry Node Editor window at the bottom. Perform the following steps:
- To create our first Geometry Nodes system, let's click on our plane to select it.
- Click on the NEW button at the top of the Geometry Node Editor:
Congratulations! You have created your first Geometry Nodes setup! You will see two nodes that have been added automatically: the Group Input node and the Group Output node.
It's important to note that your data will always flow from the Group Input node on the left-hand side to the Group Output node on the right-hand side. Everything between these two nodes will modify our geometry.
Creating our instance object
- With your mouse pointer over the 3D Viewport window (in the upper-right corner), press Shift + A and select Mesh | Icosphere.
- Select the Icosphere instance in the 3D Viewport window, press G, and then press X to move it along the X axis away from the plane.
In the next section, we will use this Icosphere node as an instance object.
Creating our first nodes
- Click on the plane object in the 3D Viewport window to select it.
With your Icosphere instance out of the way and your plane selected, you should now see two nodes in the Geometry Node Editor. If you don't see any nodes, make sure that the Geometry Nodes modifier is selected or has been highlighted in the modifiers panel on the right-hand side:
- With your mouse pointer over the Geometry Node Editor window, press Shift + A to access the Node Add menu.
- Hover over the Point category and click on Point Instance to create your first node.
- Click anywhere to place your node.
- Now, let's drag our new node onto the line that connects the Group Input node and the Group Output node.
- Additionally, you can zoom in and out by scrolling the mouse wheel and pan by holding down the mouse wheel.
- Move your Point Instance node closer to the Group Output node as we will be adding new nodes, mainly between the Group Input node and the Point Instance node, in this example:
Nodes that change attributes should almost always be placed before the Point Instance node, as the points are not referenced after this node.
Specifying the instance object
Let's do this now:
- Click on the Object drop-down menu on the Point Instance node to select the Icosphere mesh object that we created from the list earlier:
Now, let's take a look at what has happened in the 3D Viewport window:
As you can see, we now have four Icosphere instances. Ignore the original Icosphere instance that we moved off to the side – you can even hide it if you want. The reason we see four Icosphere instances is that our plane has four vertices. It's creating an instance on each vertex. Let's increase the number of vertices by subdividing our plane. We can do this right inside the Geometry Node Editor as there is a Subdivide node that we can use.
The Subdivide node
- Press Shift + A to access the Add menu, point to the Mesh category, and click on the Subdivide node.
- Move the node and place it on the line just right of the Group Input node:
Notice that you now have nine Icospheres in your scene. The reason for this is that our plane now has nine vertices because of the Level 1 Subdivide node.
- Change the subdivision Level value to
3. Now you should see a total of 81 Icospheres because we have increased the number of vertices on our plane to 81:
The Point Scale node
- Press Shift + A and select Point | Point Scale.
- Slot it in right after our Subdivide node:
Additionally, you can search for nodes without needing to know where to find them. When you press Shift + A to bring up the nodes menu, click on the Search option at the top and type in the name of the node you are looking for.
Notice that on the Point Scale node, you have access to three different numbers: X, Y, and Z. This is called a vector as it's a set of three numbers. Change one of the numbers by clicking on it and dragging sideways. You will see how the scale of your Icospheres changes according to the axis you scale on. Let's change the Type setting from Vector to Float.
- Click on the drop-down menu next to Type and select Float from the list. Now you only have one number to change, which will scale your Icospheres uniformly.
- Click and drag the Factor value to adjust the size of the instance. For now, set it to any size you like.
We have now set the scale of our instance objects using the Point Scale node. In the next section, we will look at the different types of attributes available in Geometry Nodes.
Different types of attributes
Let's take a moment to look at the different types of attributes and data types that you will see:
- Integer: An integer is a number that can be written without a fractional component.
- Float: A float is a floating-point number, which means it is a number that has a decimal place.
- Vector: A vector is a set of three float numbers and is mostly used to calculate a position in world space.
- Boolean: A Boolean only has two values and can be used for something that's either
- Attribute: This is a text field to input an attribute name.
The most commonly used attributes are Position, Scale, and Rotation (these are all vector-based as they consist of three numbers, which each correspond to the three axes of X, Y, and Z). However, there are also a few others that we will look at in later chapters.
The Point Rotate node
- Press Shift + A and select Point | Point Rotate (or you can use the search function).
- Add this node to the right-hand side of the Point Scale node:
You will see that the Point Rotate node uses a Vector data type because you can rotate using the different X, Y, and Z axes.
Click and drag the values next to the different axes to see how your Icospheres rotate in your scene. Please note that the difference between Object and Point is that Object will rotate every point in the local space of the object, while Point will rotate every point in its local space as specified by its Rotation attribute.
The Point Translate node
- Press Shift + A and select Point | Point Translate or use the search function. Again, you will see that it uses a vector as we can translate in either X, Y, or Z.
- Drag the values next to X, Y, and Z to see all of your Icospheres moving along that axis:
The Attribute Randomize node
Our scene still looks very uniform and a bit boring; however, Geometry Nodes allows you to easily randomize your attributes! Let's see how we can randomize the Scale attribute of our Icospheres. For this, we will need a node called Attribute Randomize.
Let's add it now:
- Press Shift + A and select Attribute | Attribute Randomize to add the node.
- Place it on the right-hand side of the Point Translate node:
Let's examine how we can randomize the Scale attribute.
Randomizing the Scale attribute
- Click on the empty box next to Attribute. You will see a list of available attributes that we can use.
- Select Scale from the list. Instantly, you will see that all of your Icospheres now have different sizes! Additionally, you can type in the attribute name in the empty box. However, note that the attribute names are case sensitive, so be aware of this when typing in an attribute name rather than selecting it from the drop-down list.
- The Min and Max float numbers determine the range of randomness. Change these numbers to see how they affect your scene. (Tip: Hold Shift while dragging these values to have more accurate control.)
The default data type value is set to Float, which means we use one number for all three axes, which will result in a uniform scale.
- Change this to Vector by clicking on the drop-down list at the top of the node and selecting Vector:
- Adjust the three values under Min and Max to see how this affects your scene and how the scaling is no longer uniform by adjusting these values:
- This might be the desired effect you are going for, but let's change the data type back to Float so that we're scaling our instance uniformly.
- Set the Min value to
0and the Max value to
1. Notice that some of the Icospheres are not being displayed or might be very tiny. This is because we're using the Replace/Create operator, which means we're choosing a value between
1and replacing the current Scale attribute with this new number. Note this value can be
0, which will result in some Icospheres with a scale of
0, making them disappear.
- Change the operator setting from Replace/Create to Add.
Now we are adding our random value to the current Scale attribute, which will not result in Icospheres with a scale of
0. Other operators you can use are Multiply and Subtract, which work in a similar way to the Add operator.
Randomizing the Position attribute
This time, we're going to duplicate our Attribute Randomize node and reuse it for the Position attribute:
- Click the current Attribute Randomize node to select it.
- Press Shift + D to create a duplicate copy.
- Drag the new copy to the right-hand side of the current Attribute Randomize node:
Let's configure the node as follows:
- Change the data type to Vector. The reason for this is that we want to randomize the X, Y, and Z positions for each instance.
- Set the Operator setting to Add.
- Select the position attribute from the Attribute drop-down box, or you can simply type
positioninto the box. Please note that attribute names are case sensitive:
- Set your Min value to
-10and Max value to
10. This will randomize our Icospheres' positions from
10in world space:
Randomizing the Rotation attribute
Let's configure this node as follows:
- Change the data type to Float. The reason we're using a float is that we want to use one value to rotate our instance in all axes. You can use a vector to have exact control over how we rotate. However, for this example, we're going to use a float.
- Change the Operator setting to Replace/Create.
- Change the Attribute setting to rotation:
- Set the Min value to
0and the Max value to
Changing the instance object
Start by creating a new instance object in our scene. For this, we will be adding a Suzanne object:
- With your mouse pointer over the 3D Viewport window, press Shift + A and select Mesh | Monkey.
- Move the Suzanne mesh to the side of our scene by pressing G and then pressing X.
- Click on one of the Icospheres to view your Geometry Nodes.
- Click on the Point Instance node to select it.
- Click on the Icosphere item next to Object and select Suzanne from the drop-down list:
You can also mute or deactivate certain nodes to see exactly what they do. This is good practice for troubleshooting your node tree. To do this, highlight the node or nodes you want to mute and press the M shortcut.
Now, let's mute our three Attribute Randomize nodes:
Congratulations! You have now created your first basic scene using Geometry Nodes. Please save your project now, as we will continue to work on it during the next section.
Using textures to control attributes
In this section, we will be using textures to manipulate attributes to create interesting and more complex scenes. You will learn how to use the Attribute Sample Texture node to change specific attributes using a texture map.
Let's begin by making some changes to the scene that we saved in the previous section:
- First, let's delete all three of our Attribute Randomize nodes. You can highlight them all at once and press X to delete them. However, remember to reconnect the line between the Point Translate node and the Point Instance node. Additionally, you can also use the Ctrl + X shortcut when deleting nodes while keeping the connection in place.
- Next, let's increase our level of subdivisions to
5by adjusting the Level value on the Subdivide node. This will increase the number of instances we have in our scene.
- Also, decrease the Point Scale factor to
0.2to decrease the size of our Suzanne instances:
The Attribute Sample Texture node
- Add a new Attribute Sample Texture node to your node tree between the Point Translate node and the Point Instance node:
- Click on New on the Attribute Sample Texture node to create a blank texture.
- You can also name your texture here – let's call it
- Click on the Show texture in texture tab icon on this node to open the new texture in the texture side menu:
Your texture will now be displayed in the side menu:
- Let's change the texture type by clicking on the drop-down list that is currently showing Image or Movie. For now, change this to a Wood texture:
Nothing will happen yet as we still need to configure our new node. Let's do that next.
Back in the Geometry Node Editor, let's take a look at the Attribute Sample Texture node. It has two attribute slots that we can use. The Mapping attribute is used to determine where and how the texture is evaluated.
- Click on the empty box next to Mapping and select UVMap from the list of attributes.
- The Result setting can be any attribute we want to affect using the texture. So, let's choose scale. You can either select it from the drop-down list or type the word
scale, in lowercase, and then press Enter:
Notice that our instance's scale has been updated and matches our wood texture. Where we have black pixels, the scale factor will be set to
0. And where we have white pixels, we will have a scale factor of
1. Feel free to experiment with other texture types to see how it affects your scene.
You can even load your own custom image texture by choosing Image or Movie as the Type setting and then clicking on Open to load your image:
For this example, I've moved the Point Scale node after the Attribute Sample Texture node and lowered the value to
0.4. The reason for placing the node here is that our Attribute Sample Texture node is changing our scale attribute. Therefore, any node before the Attribute Sample Texture node will not have any effect on the scale attribute. Remember that the data is flowing from left to right:
By now, you should have a basic understanding of what Geometry Nodes is and how it can be used to create amazing patterns or scenes.
In the next section, we will look at how to add keyframes and animation to our Geometry Nodes using basic math.
Animating with Math nodes
In this section, we look at how to create interesting animations using Math nodes and other objects in your scene. We will create a basic scaling animation by using the distance value between two objects in our scene and modify the scaling attribute using some easy math. So, let's get started!
For this section, you can start with a new Blender project:
- Delete all of the default objects by pressing A and then pressing X to confirm the deletion.
- Create a plane object by pressing Shift + A and selecting Mesh | Plane.
- Using the pop-up Add Plane dialog box in the lower-left corner of the 3D Viewport window, set the Size setting of the plane to
10 m. Click anywhere in the viewport to confirm these parameters:
- With the plane selected, click on the Geometry Nodes tab at the top of the interface.
- Click on the New button to create a new Geometry Nodes modifier on the plane. You should now see the Geometry Node Editor with two default nodes, Group Input and Group Output.
- Let's create our instance mesh. With your mouse pointer hovering over the 3D Viewport window, press Shift + A and select Mesh | Torus.
- Scale down the torus by 50% by pressing S and then pressing 0.5.
- Move the torus out of view by pressing G then pressing X. Move the mouse until it's away from our plane object.
- Most importantly, we need to apply the scale of this torus; otherwise, we might run into some interesting surprises later. With the torus selected, press Ctrl + A and click on Scale. Now, let's jump back into our node tree!
- Select the plane to enable the Geometry Nodes view. Remember, if you still can't see the nodes, ensure that the Geometry Nodes modifier is highlighted if you have other modifiers in this object.
Now, let's add our first nodes.
- For node number one, we will create a Subdivide node. Slot it in just after the Group Input node.
- Additionally, we need a Point Instance node to instance our mesh. Slot it right before the Group Output node.
- Set your Subdivide node Level to 3.
- Select your new Torus object from the drop-down list of the Point Instance node:
Note that you have lots of tori in your scene. Yup, I also didn't know that the plural of a torus is tori until now!
- Hover over the 3D Viewport window, press Shift + A, and select Mesh | Cube.
- Move the cube to the edge of our torus instances by pressing G and then pressing X:
- Back in our node tree, click on one of the torus instances to view the node tree if it's not visible.
- Add a new node, called the Object Info node, by pressing Shift + A and selecting Input | Object Info or using the search function. We are not going to connect this node to our other nodes at this moment – just place it directly beneath the Subdivide node. We are going to use this node to calculate the distance between our tori and the cube object.
- On this Object Info node, click on the Object drop-down list and select the Cube object from the list. You can also use the eyedropper tool.
- Then, click on the Relative button. This will calculate the current information of the cube and not just the original data:
The Attribute Vector Math node
Now, let's create our first Math node – the Attribute Vector Math node. There are a few Math nodes available, but for this specific example, we need to use the Attribute Vector Math node because of its Distance operator:
- Press Shift + A and select Attribute | Attribute Vector Math.
- Slot it in right after the Subdivide node:
Notice that the Object Info node is not yet connected.
One thing to bear in mind is that any node that uses an attribute is calculating that attribute for each instance in every frame.
Now, let's take a moment to look at the Attribute Vector Math node and how we will use it. We want to calculate the distance between our Cube object and every Torus instance object. We already have the position value of each Torus instance saved in the position attribute, and with our Object Info node (connected to our cube object), we also have the relative position of the cube. Let's see how we can calculate the distance.
- First, let's change the operation of our Attribute Vector Math node from Add to Distance by clicking on the top drop-down menu on the node and selecting Distance from the many different operations available.
- Then, change B from Attribute to Vector. The reason we're using a vector here is that the cube's position will be a type of vector for each axis:
- For attribute A, we want to use our torus positions. To do this, click on the empty box next to A and select position from the list or enter the word
positionand press Enter.
- For attribute B, we want to use our cube's position, so let's connect our Object Info node's Location to the Attribute Vector Math node's B input.
Now we need to save the result of this operation to an attribute. Here, we can create our new attribute by entering a new attribute name that's not in use, but an easier option would be to simply overwrite the current scale attribute with our new result. Let's do that next.
- Click on the empty box next to Result and select scale from the list. If you don't see the scale attribute in the list, you can type in the word
scaleand press Enter:
- Looking at the 3D Viewport window, you will see that the scale of the instance objects has changed. Instances closer to the cube have a smaller scale, while instances further away from the cube have a bigger scale value. Please refer to the following screenshot:
- Add a new Attribute Math node and slot it in after the Attribute Vector Math node. Note these are different nodes – one uses vectors and the other uses float data types.
We want to make our scale factor smaller, so let's use the divide operation to do this. We will perform a simple calculation to make our scale factor smaller:
scale / value = smaller scale
- Change the operation at the top of this node from Add to Divide. Leave A as Attribute, but let's change B to Float. This will give us access to change this value manually.
- For Attribute A, select scale from the drop-down menu, or you can enter it manually and press Enter to confirm.
For the Result setting, we can overwrite an existing attribute. In this example, let's overwrite the scale attribute. To do this, click on the empty box next to Result and select scale from the list. Again, you can enter this manually and press Enter to confirm.
Your tori will disappear from the 3D Viewport window because we are now dividing by 0, resulting in their new scale being 0.
- Let's change our B value by clicking and dragging the Float value to the right-hand side – find a number that gives you good results. I chose
Let's examine our node tree:
First, we are subdividing our plane into three levels. Then, we calculate the distance between our cube object and every torus in our scene by using the Attribute Vector Math node. We then save this distance value into our existing scale attribute, overwriting the current value. Following this, we divide our new scale attribute by 10 (the float we entered manually), resulting in a smaller scale factor.
Now, let's move our cube around the scene to see the effect in action.
- Select your cube in the 3D Viewport window and press G. Then, press Shift + Z. This key combination will limit your cube's movement to the X and Y axes, excluding the Z axis. As you can see, you have created a cool-looking scaling animation. The closer the cube gets to a torus, the smaller the torus will become.
- Experiment by adding some position keyframes to your cube and see what you can create:
Using this method, you can easily create interesting and dynamic motion graphics scenes inside of Blender. Experiment with this technique and try to affect the rotation or position of your instance objects rather than their scale. Have fun creating interesting animations!
Congratulations! You should now have a basic understanding of how to create different Geometry Nodes and how to use them to change certain attributes to create dynamic effects. Now, let's use what we have learned to create something more interesting.
In the next chapter, we will create a motion graphics scene using all of the techniques we've learned so far. Additionally, we will look at how to apply materials to our instance objects!