![](https://files.koenig.kodeco.com/uploads/2023/05/geometry_nodes_blender_featured_banner@1.5x.png)
Procedural Game Asset creation with Geometry Nodes in Blender
In this article, you’ll learn about procedural asset creation in Blender using geometry nodes. In the process, you’ll create a treasure chest with a guardian protecting its treasure. By Ayush.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
Procedural Game Asset creation with Geometry Nodes in Blender
25 mins
- Getting Started
- Using Geometry Nodes
- Utilizing the Spreadsheet
- Using the Node Editor
- Modeling with Geometry Nodes
- Data Flow in Geometry Nodes
- Extruding the Chest Panels
- Combining branches
- Data Processing
- Understanding Socket Shapes
- Debugging Nodes
- Manipulating Vectors
- Pivoting
- Instancing
- Distributing Collection Elements
- Selective Instancing
- Using Curve Nodes
- Mesh to Curve Conversion
- Spline Manipulation and Profiles
- Exploring Basic Materials
- Where to Go From Here?
Pivoting
The pivot of the cover needs to be moved to the top corner of the main body. Look at the spreadsheet, and you’ll notice that for the main chest body, the top corner is at the zeroth index.
The position attribute at this index is the center of rotation needed for the Vector Rotate node. The Sample Index node that retrieves a value from a domain at the specified index can be used to retrieve the position attribute at this index.
Make the following changes in the root node system:
- Connect the vector output from Vector Rotate to the position input of the
cover_nodes
group. - In the
cover_nodes
group, drop Set Position before Group Output and use its position input as a new output in Group Input. - Back at the root level, connect the angle input from Vector Rotate to the result output in Clamp, then connect the value input of Clamp to a new connection from Group Input in order to add a range for the angle input.
- In the
body_nodes
group, connect geometry output from the node labeled scale-y to the pivotMesh in Group Output.
Instancing
Now you’re ready to fill the treasure chest with treasure. The project contains a gem folder with a collection of gem models that you can use for this purpose. Place copies of these gems in the treasure chest randomly. Duplicating the gem models multiple times is a rather inefficient process that isn’t optimized for rendering purposes, so you need to create instances and spread them around. Although there are many nodes that facilitate this type of spreading, the Instance on Points and Distribute Points on Faces node are the most commonly used.
Distributing Collection Elements
Instance on Points instances an input geometry connected to its instance socket using a point cloud. The Distribute Points on Faces can be used to return the required point cloud based on any input geometry. In this case, since the gems are actually in a collection, you can use the Collection Info node, which can be used to reference a collection in a node tree.
In the Outliner window, select the Plane object and reveal it by pressing the closed eye icon next to it. Then open the geometry nodes tab for the Plane object after selecting it and connect the geometry from Collection Info to the Instance inputs in the Instance on Points nodes.
Selective Instancing
The combination of Instance on Points and Distribute Points on Faces creates instances all over the mesh. Sometimes an asset may require that some faces remain visible while others are covered with instance details. The treasure chest surface may be covered with moss on certain portions, while others remain fairly clean. Having this type of control is useful to add detail to the final render. Textures nodes present an easy way to create a wide variety of details when used with instancing. You’ll use the Musgrave Texture to selectively show instances on surfaces in this section.
Select the body object, and in the moss_instances
group, connect the Result output from the Less Than node to the Selection input of the Instance on Points node.
Then, in the root node system, connect instances from both moss_instances
to Join Geometry.
Using Curve Nodes
The treasure chest now has some treasure, but there are still a few things to flesh out. Speaking of fleshing things out, the cover is a bit thin. You can use the same technique you used to make the main body thicker using the Mesh Boolean node. But, since the cover is not filled internally, there will be a small issue.
Mesh to Curve Conversion
To get rid of this gap, you fill the cylinder. Curve nodes are a family of nodes that operate on curves. For example, the Fill Curve can fill the interior of any closed curve. However, the cover is not actually a curve, but a mesh. Mesh To Curve can do the conversion but it’s just a partial solution at the moment. You need to convert the border edges of the cover into a curve, but there may be unexpected results as Mesh To Curve converts the whole mesh by default. Luckily, it also has a selection socket.
Select border edges with a field that uses the Edge Neighbors as an input. This node can get the number of faces an edge is connected to. If the count happens to be one, the edge is a border edge. The information returned by this field can then be hooked to the selection socket of Mesh to Curve. Connecting Mesh To Curve to Fill Curve will then finally fill the cover.
Update the cover_nodes
node with the following steps:
- Connect a geometry output from Delete Geometry to Mesh input in Mesh To Curve.
- Drop a Join Geometry before Set Position and connect Fill Curve‘s mesh output to Join Geometry.
- Drop a Mesh Boolean before Set Position and add a Transform to bridge Join Geometry‘s geometry and Mesh2 from Mesh Boolean.
Spline Manipulation and Profiles
A treasure chest now opens to reveal a pile of treasure. What more can a brave adventurer want?
How about a challenge, perhaps?
A challenge in the form of a tentacle monster might be cool. Tentacles basically require a form that propagates through a curve getting smaller along the way — also known as the profile of the curve.
The Curve To Mesh node converts a curve to a mesh and has a secondary input called profile. It’s the first part of achieving a basic tentacle. Next, the tentacle needs to become smaller along its length as well. The Set Curve Radius has a radius input with a diamond with dot socket shape. This means the radius can be different for each control point in the curve creating an effect of the tentacle shrinking along its length.
In the Outliner window, reveal the tentacles collection. Then select the tentacle_1
object. Edit the tentacle_system
group and connect the geometry output from Transform Geometry to the profile curve input in Curve To Mesh and from Group Input to the curve input in Set Curve Radius.
The tentacles are now present in all their glory. To gain more control over these assets, you can control the tentacle length as well. This process of changing the length of a curve maintaining its shape is known as trimming. The Trim Curve node can be used to achieve this effect.
In the tentacle_system
group, connect the curve output from Trim Curve to the curve input in Set Curve Radius.
Select one of the tentacles in the outliner window, then select its modifier properties in the properties window and play with the value of the tentacle_length field to see the tentacles shrink and grow as you change the value accordingly.