Instancing

After you have mastered the basics of working with shapes, understanding different data types and the way this data flows. It is time to upgrade yourself and start working with instances. So make sure you’ve got your basics covered and let’s jump in.

By the end of this article you can easily make content like this.

What is instancing

Instancing is a patching method in which a single node is instantiated. Instead of making 100 Circle nodes, you make a single Circle and set its instance count to 100.

100 circle nodes vs 1 instanced circle node

So why do you need instances?

First there is scalability, you could move 5 shapes by hand. But what about 100? What if you want to move them? Are you going to move them all manually? Work smarter, not harder! Scaling instances also allows for the creation of cloner effects, delay effects and slice animation patches.

Secondly there is readability, a patch with 100 circle nodes, 100 move nodes and 100 shape render nodes would become a huge mess.

Thirdly there is effectiveness, collections of instances can interact with each other in many different ways. Patterns can emerge from simple mathematical operations, creating imagery that you didn’t know you could pull off!

Complex geometric patterns emerge when you introduce nodes like Linear and Circle Pattern to your patching.


Instances & Collections

Imagine a node being a container for an object (for example a Circle). The instance count is how many of those objects are in the container. But each circle is still unique. For example, each of the circles has its own radius.

25 circles, from a single node, each with their own radius.

An instanced signal is called a collection as it contains multiple values of the same type. Instanced signals can be identified by a striped cord. By hovering over an outlet of an instanced node you will see multiple values.

The Gradient Palette produces a collection of Float4 values. Hovering over its outlet we can see the values.

Mode nodes, producing more collections.

Each instance in a collection has an index.
The first instance in a collection is at index 0, the second at index 1 and so on.
Burn this into your brain as it will be really important later down the line.

Start burning!
Do it!
Do it now!


The Repeat Rule

In Wire we work from left to right.
If a collection has a higher instance count than the node it goes into, that node's instance count will be updated to match.

In the example below we have a single Circle node going into a Move node.
The Circle Pattern node provides us with 10 float2 values.
Because of this the Move node is updated to 10 instances and we end up with 10 circles.

A single Circle shape gets updated to 10 because the Circle Pattern node provides the Move node with 10 instances.


Creating Collections

So far so good, but how do we create collections?


Manual Instancing

You can manually instantiate a node by going into the node panel and set its instance count there. Most nodes can be instantiated, but there are exceptions (for example: it would make no sense to instantiate a constant like Pi).

After you have manually increased the instance count above 1, three horizontal lines will appear in the node panel besides the parameters. This indicates that those parameters are instantiated.

Clicking on the three lines allows you to manually enter the value for each instance.

Alternatively you can CTRL+Click the parameter on the node self to open the instance widget.

The multi-editor in the node panel

 The multi-editor widget opened by CTRL-clicking the node.


Collection Nodes

Some nodes will always produce an instanced signal.

Nodes like Sequence, Linear, Grid Pattern and  Circle pattern will generate collections of coordinates that can be used to move shapes, textures or meshes around.

Experimentation is key! By multiplying a couple of different sizes Linear collections we can create complex geometric visuals.


Gradient Palette will generate a gradient collection of colors (float4). Note that these color collections can easily be converted to textures by using the To Texture node.

By joining multiple Gradient Palette nodes together we get some rainbow puke action.


Collection Information

Sometimes you need to retrieve information about the collection itself.

The most used node is the Size node which will give you the size of a given collection.

This is often used to feed into a node with a size inlet to make sure all collections in a patch are at the same size.

Alternatively you can use the Indices node to get a collection of integers of the indices of the collection.

Meet Size. Size will be your best friend when scaling your patches.


Combining Collections

On your quest of becoming an instancing master you will, at some point, want to combine multiple collections into a bigger collection or split it back into single channels

Two collections of the same type (for example Float 2) can be combined by using the Join node. Alternatively, multiple single channel signals can be formed into a collection using Join.

Joining collections of 5,  25 and 50 instances into a big collection of 80.

The Insert node will Insert one collection into another collection at a given index. This can be useful when you want to place values at a specific place in an existing collection.

A collection can be split into single channel signals again by using Split.

A collection can be merged into a single channel by using the Merge node. Do note that the Merge node behaves differently depending on the type you’re giving it. When using textures you can set the scaling and blend mode. When using strings you can select a separator. 

Merging is especially useful when working with texture, as instanced textures can be taxing on performance.

In this patche we're merging the collection of 4 textures to prevent the need of instancing the Threshold and Edge Detection node further down the line. Saving some valuable computing power.

Manipulating Collections

A step up from simply combining and splitting up collections is the actual manipulation of individual instances. Keep in mind that each instance has an index and that indices run from 0 to the size of the collection minus 1. So a collection with 10 instances has indices running from 0 to 9.

Specific instances can be read from a collection by using the Read node. Imagine having a collection of values and you only need the first value. You use the Read node at index 0.

The Span node can be used if you want to extract a range of values from a collection.

Two different ways to extract information from the Sequence node.

You can overwrite values in a collection with the Write node.

Collections can be sorted by using the Sort node or randomized by using the Shuffle node.

The values in a collection can be moved around by using the Shift node or reversed using the Reverse node.

A collection can be repeated by using the Expand node. Note that this node has multiple modes like Repeat and Ping-Pong to play around with.

Overwriting index  5 using the Write node.


Math & Logic

You can apply Math operations on collections like you do on single channel signals.

For example: you can multiply every value in a collection with a single value. Alternatively you could multiply a collection with another collection. In this case index 0 of collection 1 would be multiplied with index 0 of collection 2 and so on.

The same concept applies to Logic.

You can check if there is any value in a collection larger than 5 using the Greater node.

Alternatively you could check one collection against another collection. In that case index 0  of collection 1 would be compared to index 0 of collection 2.

 Applying some simple logic to the Sequence node.


There are a couple of collection-specific math and logic nodes.

You can calculate the average, median or mode of a collection using the respective nodes.

The same is true for calculating the running total of a collection.

The lowest and highest values in a collection can be extracted using the Min and Max nodes.

On the logic side we have nodes like None, Any and All to make collection-specific checks.

In Verbindung stehende Artikel