Skip to content
ImagineWorld

Creating a Shrinkwrapping Simulation

node_idnode-book_procedural-3d-modeling-using-geometry-nodes-in-blender_chapter-20-creating-a-shrinkwrapping-simulation
node_typechapter-node
schema_profileworld.chapter_node.v1
statusactive
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
chapter_num20
chapter_titleCreating a Shrinkwrapping Simulation
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

Chapter 20 — Creating a Shrinkwrapping Simulation

Section titled “Chapter 20 — Creating a Shrinkwrapping Simulation”

In the previous chapter, we learned how to create bugs crawling on objects. In this chapter, we’ll take a look at the process of how to shrinkwrap objects using Geometry Nodes.

In 3D simulation, shrinkwrapping is a process that creates a simplified, watertight mesh that envelops a more complex 3D model or assembly.

Just like in the real world, it creates the effect of sucking the air out of a bag with an object inside. That’s what we’re going to recreate today in the Simulation Zone and the Repeat Zone.

These objects will be the objects that we will shrinkwrap together, as seen in the examples of Figure 20.1:

Figure 20.1: Example of what we’ll make in this chapter

We will start by placing some objects around in our Viewport. Then, using the Geometry Proximity node, we will find the closest point of a bounding box between our objects. With this, we can create an animation of the object being shrinkwrapped.

We will follow this by familiarizing ourselves with the Repeat Zone and how it differs from the Simulation Zone.

Further, we will also cover how to run a low-quality simulation, which will be viewed as long as we’re using the Viewport to keep Blender running smoothly.

Figure 20.2: Viewport versus rendered

In this chapter, we’ll cover the following main topics:

  • Setting up our project
  • Building our node tree
  • Slowing down and refining the simulation
  • Familiarizing ourselves with the Repeat Zone
  • Building a viewport preview

Without further ado, let’s get started creating our scene in Blender!

You can find the exercise from this chapter in the common .blend file in the book’s GitHub repository

Let’s start by creating a new Blender project and heading to the Blender Viewport. We will need to add some objects to our scene.

Follow these steps to get started with setting up our Viewport:

  1. Let’s begin by deleting all the current objects (such as a cube, camera, and light) in our scene and adding some mesh objects.
  2. For this demo, we chose to add the Suzanne (Monkey) mesh, a cone, and a cube, but you are free to choose your own objects. We placed the objects around in a randomized manner, as you can see in Figure 20.3:

Figure 20.3: Your current viewport scene

  1. Once you are done with this, go ahead and select all the objects and add them to a new collection. This can be done by pressing M in the Viewport and then selecting New Collection. Let’s name the collection Shrinkwrapping.

This is how the Outliner should look:

Figure 20.4: Blender Outliner

  1. The next step is to create the object that will act as the shrinkwrapping mesh. To do that, let’s add a cube to our project. Make sure it’s outside of the Shrinkwrapping collection!

This is what the final Outliner should look like:

Figure 20.5: Blender Outliner

  1. Once you have completed this setup, select the cube you’ve just added and head to the Geometry Node editor and add a new node tree. Delete the Group Input node, as we will not need it for now.

This leaves us with the Group Output node, which means we’re ready to start building our node tree!

Let’s start by adding a Cube node. This node will act as our domain for our simulation.

The idea is that we make a cube with a lot of geometry, and then calculate the nearest face of each vertex relative to our Shrinkwrapping collection, making the cube our new geometry.

To do this, follow these steps:

  1. We’ll begin by giving the Cube node the following parameters:

Figure 20.6: Cube node parameters

  1. Let’s also connect it to the Group Output node to visualize this object.
  2. We can see the cube appear in our Viewport. The next step is to find the nearest faces of our Shrinkwrapping collection.
  3. To do this, let’s add a Geometry Proximity node and a Collection Info node with the Shrinkwrapping collection selected. Make sure the mode of the Collection Info node is set to Relative. This will allow us to move the Shrinkwrapping objects and have the simulation update accordingly.
  4. Let’s plug the Instances output of the Collection Info node into the Geometry input of the Geometry Proximity node.
  5. Next, add a Set Position node, which we’ll use to modify the location of our Cube node. Drop it between the Cube node and the Group Output node.

This, on its own, won’t do anything. We will need to plug in the Position output of the Geometry Proximity node to the Position input of the Set Position node.

We can see that everything disappears, which might stumble you, but this is completely normal if you know why it happens.

This is happening because, by default, the Collection Info node returns your collection objects as the Instance type, which the Geometry Proximity node ignores.

We know this is happening because of the Info icon in the Geometry Proximity node, as shown in Figure 20.7. This tells us the node has something important to say.

Figure 20.7: Info icon on the Geometry Proximity node

When hovering over this icon, it tells us that Instances in the input geometry are ignored. This is exactly what we needed to know!

To convert instances to normal geometry, we can drop in a Realize Instances node between the Collection Info node and the Geometry Proximity node, which solves the issue.

Once you add this, you can see that we are making progress. Our cube has now turned into a shape that resembles a convex hull around our Shrinkwrapping collection! This is shown in Figure 20.8:

Figure 20.8: Convex hull-like shape in the Viewport

This is a nice result, but it’s not our end goal. To get more detail in this shrinkwrapping simulation, let’s make sure it gets run over and over again using a Simulation Zone.

Let’s put the Set Position node in a Simulation Zone. It will disconnect all the node inputs from the Set Position node, so be sure to reconnect the Position node connection back to the Set Position node. Also, the Cube node will need to be connected to the Simulation Begin node.

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

Figure 20.9: Your current node tree

You will see that when you hit play, nothing happens for now. This is because we’re not actively changing the geometry other than the first frame.

To finalize our shrinkwrapping simulation, we will need a Dual Mesh node. Let’s start by explaining what a Dual Mesh node does in the next section.

To explain what exactly this node achieves, let’s start by explaining what a dual is.

In geometry, a dual is created by interchanging the roles of the faces and vertices of an original shape. You can visualize this by placing a new point (a vertex) in the center of each face of the original shape. By connecting the points on adjacent faces, you form the edges and faces of a new shape, which is the dual.

In Figure 20.9, you see a visualization of the dual algorithm, where we first place points at the center of the faces, and then connect these into new faces:

Figure 20.10: Process of creating a dual of a mesh

This is exactly what the Dual Mesh node achieves: it allows us to create a dual of our current topology.

This is useful in our current scenario because it allows the Geometry Proximity node to compute our mesh differently. Each time a frame passes in our simulation, the Dual Mesh node should be computed, so that we get a different result each frame. Keep in mind that after two Dual Mesh node computes, we’re back to our original mesh, but this is okay in our use case because we’re modifying our geometry as each frame passes. This gives us a new layer of resolution with each new frame, allowing for more shrinkwrapping steps.

Let’s go ahead and drop this Dual Mesh node right after our Set Position node. This allows it to compute each frame and change the mesh for the next iteration of the Set Position node.

When we now hit play, you’ll see that our shrinkwrapping simulation works!

Tip

For optimal results, hide your Shrinkwrapping collection from the Viewport so that it won’t clip through the shrinkwrapped mesh.

There is a slight issue, though. The mesh is constantly flickering. This is a byproduct of the Dual Mesh node. This is caused by the lack of resolution in our model because we have stretched our cube out so far. This can be easily solved by adding a Set Shade Smooth node at the end of your node tree because this node will shade out all the faces.

Our simulation is going very fast, though. It would be cooler if we could slow down the animation and, in turn, make it more accurate, which we’ll explore in the next section!

Let’s get right into it! The problem we have in our current simulation is that the simulation computes too fast – this introduces errors in our geometry. It’s best to let the shrinkwrap simulation run more slowly so that we have more substeps in our simulation.

Let’s take a look at how we can achieve this:

  1. To do this, we can mix the Position vector of the Geometry Proximity node with our original Position vector, which will cut the resulting position.
  2. Add a Mix Vector node between the Geometry Proximity node and the Set Position node.

By default, it will not result in the desired result. That’s because we haven’t provided a second vector yet.

  1. Next, let’s add a Position node to our Geometry Node editor and connect the output to the second vector input of the Mix Vector node.

By default, the Factor input of the Mix Vector node is set to 0.5. You can tweak this to your liking. While a higher number will make the simulation happen slower, thus more accurate, a lower number will make the simulation happen faster, thus less accurate. In this demo, we’ll keep the value of 0.5.

When you now reset your timeline and hit play, on the simulation, you’ll see that our shrinkwrapping simulation works pretty well!

If you followed the previous steps correctly, your node tree should look like this:

Figure 20.11: Your current node tree

There is a problem, though. When we want to manipulate the position of the shrinkwrapped objects live, you’ll notice that the simulation clips through the objects as we move.

We would be able to fix this by re-running the entire simulation every time a movement is detected. This is what we’ll explore in the next section!

Familiarizing ourselves with the Repeat Zone

Section titled “Familiarizing ourselves with the Repeat Zone”

In previous chapters, we have always used the Simulation Zone, which is a loop that constantly modifies the data contained inside as an animation. The Repeat Zone works a little differently.

Instead of running once per frame to simulate the flow of time, the Repeat Zone executes its entire loop a specified number of times, all within a single frame’s calculation. This makes it a powerful tool for procedural generation and complex modeling tasks. Keep in mind that the Repeat Zone is not as useful for animated simulations as the Simulation Zone is. This is because the Repeat Zone does not show each iteration as a frame, but rather outputs all iterations at once.

This allows us to run an entire proper-looking shrinkwrap in a single frame, which also allows us to modify the position of the objects in real time.

Let’s get right into adapting our current node tree to work based on the Repeat Zone. Luckily, this does not require many steps. All we need to do is meticulously transfer the nodes in the Simulation Zone to a Repeat Zone where the inputs and outputs are connected in the exact same way as before. Let’s give the Repeat Zone an Iteration value of 40. This means that the nodes inside the zone will be repeated 40 times.

Once you have completed this, you’ll see our simulation is no longer an animation, but rather a continuously updating simulation of shrinkwrapped objects!

You might notice that the Repeat Zone can be slow at times, especially when we give our original Cube node more resolution to work with. Luckily, we can fix this by working with a Viewport preview!

A viewport preview prioritizes speed by using simplified calculations, lower geometry resolution, and fewer simulation steps, giving you fast, interactive feedback. In contrast, the final render uses full, high-quality settings for maximum accuracy, which can lead to a completely different and more detailed result.

We can achieve this by splitting up our node tree into two parts, one track for a viewport preview and one for a final render, just like we demonstrated in Figure 20.1. Here are the steps for setting this up:

  1. To get started, duplicate the current Repeat Zone along with the Cube node, and put it right below the current node tree.
  2. Connect the Position output of the Geometry Proximity node to the Position input of the Set Position node. We will not be making use of the mixed vector because this is just a viewport preview, which does not have to be accurate.
  3. Lower the Iteration value from the duplicated Repeat Zone to 10. This will give a low-quality result of what we previously had.
  4. It’s not connected to our output yet, though. To fix this, we will need to introduce ourselves to the Switch node:

Figure 20.12: The Switch node

This node allows the user to emulate a switch between different data types. This means that it uses a Boolean input to decide whether it’s taking the False input or the True input.

  1. As our Boolean input, we’ll make use of the Is Viewport node:

Figure 20.13: The Is Viewport node

As the name of this node suggests, this node will return whether we’re viewing our scene through a Viewport (True) or through a rendering (False).

Together with the Switch node, we can decide what part of our node tree should be visible.

  1. To make use of this node, let’s put the Switch node between the first Repeat Zone end and the Set Shade Smooth node.
  2. Like we said before, we’ll use the Is Viewport node as our Boolean input, so let’s connect it to the appropriate socket.
  3. Lastly, all we need to do is connect the other Repeat Zone output to the True input of the Switch node. Once you have completed this, your Viewport should appear again.

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

Figure 20.14: Your current node tree

To clean up the node tree, let’s group the nodes into two sections:

  1. Let’s select the nodes responsible for the render layer, and put them in a frame using Shift + P. Let’s name the group Render Layer with a red color.
  2. Let’s do the same for the nodes responsible for the Viewport layer, but let’s name it Viewport Layer with a green color.

Now that we are no longer bound to performance issues on the Render Layer, feel free to increase the resolution of our Cube node as well as the Iteration count of our Repeat Zone.

For this demo, we used a Vertices value of 250 on all axes on the Cube node, as well as an Iteration count of 150. We also used a Mix value of 0.9, which means our simulation will compute with a lot of substeps. Feel free to play around with these values to see what works best for you.

Now, let’s finish off Render Layer by adding a Subdivision Surface node right after the Render Layer Repeat Zone end. Let’s give it two levels of subdivision. This will ensure our end result is nice and smooth.

If we now add a camera and render our project in the Workbench mode, our result will look something like this:

Figure 20.15: Your finished result

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

This chapter demonstrated how to create a shrinkwrap effect using Geometry Nodes in Blender.

The process began by using a Geometry Proximity node to pull the vertices of a high-resolution cube toward a collection of target objects. This core logic was placed inside a Simulation Zone, where a Dual Mesh node was used to iteratively alter the mesh topology and create the shrinking animation. The setup was then adapted to use a Repeat Zone, which allowed the entire simulation to run in a single frame for real-time interactivity.

Finally, performance was optimized by creating separate high-quality and low-quality node branches, using an Is Viewport and Switch node to provide a fast preview while preserving detail for the final render.

In the next chapter, we’ll look at some common issues beginners might experience using the Simulation Zone and Repeat Zone.