• The Blend
  • Posts
  • Branch to target: messy spiderwebs part 3

Branch to target: messy spiderwebs part 3

Send branches from a parent curve to a target object.

The Blend

When I first tried to learn Geometry Nodes, this problem baffled me for the longest time.

How do you connect two things with a curve?

For example, wires on a power line or ropes hanging from…a thing covered in ropes.

It’s something you come across a lot, so it really helps to understand it. Or at least have a vague idea of how it might work (that’s where I’m at. 🙂)

This is Part 3 of the Messy Spiderwebs series, where you learn how to build a spiderweb generator (to make any scene look disgusting.)

You don’t have to read the previous ones, but if you want to build the final result when Part 4 comes, you’ll need to:

Last week, you learned how to make any curve look more realistic by adding gravity. Today, you’re going to learn how to add branches to any curve.

When you're done with this one, you'll have a complete node group called Branch To Target. This node is a core piece of the spiderweb generator.

Now come see how to make any curve send out branches to a target object.

  • The Setup

  • Grouping It

(This explains how everything works, so it gets a little long. If you understand nodes pretty well, try looking through this demo file to see the final result of today’s lesson.)

The Setup

I’m going to explain this one a little differently.

First, I’ll tell you the theory behind it. The idea of how it’s going to work.

Next, you’ll build it. You’ll do that part on your own—I’ll show you a picture and give you a sample file to guide you there.

Here’s how it’s going to work.

You start with a curve. Any old curve. For example, the default curve object, which only has two points.

Next, we’ll resample that curve to give us more points to work with. For that we’ll use a Resample node, with a count around 100.

This node isn’t going to be in our final group—it’s just preparing the curve for the branches.

Now you need to instance the branches on the curve. The branches will be simple Curve Lines, with random rotation (made by adding a random value to the normal-aligned rotation.) You can use a Random Value > Boolean node to control how many branches there are.

After you have the branches, you’ll use the Geometry Proximity node to measure how close they are to a target mesh (A monkey head for me, drag it in from the Outliner and switch it to Relative mode.) You’ll need to use a Realize Instances node to convert the instances into real curves.

You can use the Position output of the Proximity node to control a Set Position node. This gives you a shrink-wrap effect, snapping all the points of the branch curves against the target. You only want the ends to snap to the target, though, so use an Endpoint Selection to control the Set Position node.

The Set Position has a second input called Source Position. This is the position that is used when the node is calculating where to snap the ends to.

So if you add a little bit of randomness here, you can control how randomly the curve ends get positioned.

Just add a Random Value to a Position node, then plug that into the Source Position. You’ll see that I used a Value node to control the Random node—the value gets connected straight to the Max, then multiplied by -1 for the Min.

Now you have the branches. Just add a Join Geometry node and join them back into the original curve.

And that’s really it. Takes a few nodes, but not that complicated.

Now you need to build it. Here’s a picture of the final node setup, inside the node group (see next section) (or you can grab the file here and see it in more detail.)

Inside the final node group

Grouping It

Let’s turn this into a reusable node group.

Select all the nodes (not the Resample node and not the Join node) and press Ctrl + G.

This makes a Group node. Select the group and press TAB to edit it. (select the Group Input node and press TAB to get out again.)

You can connect node inputs to the empty socket on the Group Input node to add input sockets to your new group.

Connect these:

  • the Target geometry.

  • the value controlling the Random node for the Source Position

  • the Probability of the Random Boolean controlling the Instance node

You can press N to open the sidebar, then switch to the Group tab. In this panel you can rename any of the inputs—I renamed the source position random controller to Spread.

It’s all done now. Great job! Try moving it around to see how it adapts to the target.

You just learned about a pretty complicated bit of nodes:

  • Instancing branches

  • Randomizing them

  • Snapping their ends to a target

  • Randomizing that

You also completed a finished node group that will be crucial to the final project.

So SAVE THIS FILE. And enable the FAKE USER button (little shield next to the group name) so you don’t lose your node group.

The last part, Part 4, is coming on Monday.

If you’re reading this online, now would be the perfect time to subscribe. (so you don’t miss Part 4, which will be the best part of the series.)

EDIT: Part 4 exists now.

Can't think what to blend?

Try something huge and distant. Anything from a city on the horizon to a wrecked spaceship in the desert.

P.S. I write fiction on the side, if you like that kind of thing. I made the cover of this one in Blender ↓ [all my work is 100% free to read]

Enjoy this newsletter? Please forward to a friend, it'll make my day. And theirs. (unless they hate it when you forward random newsletters to them.)

New to the newsletter? Join here (no pressure. But I really, really think you should click the button. Click the button. Click...the...button...) ↓

Reply

or to participate.