Instancing and Procedural Motion · Chapter 1 of 9
Instancing: One Object, Many Copies
Written for version 2.7.0
What an instance is, adding an Instancer to a node, Count and Seed, the Instancer FX graph, and a first row of copies with Instance Index.
The Rig Editor chapters made things one at a time: a mesh, its materials, its bones. This path is about having many of one thing, such as a row of posts, a stand of trees or a field of grass, without building each by hand. It starts with the Instancer, which draws one object many times over.
The Add menu, Empties and meshes, and parenting one node under another in the Node Hierarchy.
What an instance is
An instance is a copy that is drawn, not made. The model still holds one object. The Instancer draws it again and again, and gives each drawing its own place, turn and size.
- Change the original and every copy changes with it, at once. Edit the mesh, swap its material or reshape it, and the whole row follows.
- The model stays small. Eight trees or eight hundred, the Node Hierarchy and the file hold one.
- Where each copy goes is worked out by a small graph, not placed by hand. Change one number and the whole arrangement moves.
- The graph can read the clock, so the copies can move on their own. Later chapters use this for wind and for things that react to other objects.
Duplicating the node does none of this. Each duplicate is a separate node to select, move and keep in step with the others, and a change to one stays with that one.
The prototype is a whole subtree
The Instancer belongs to a node, and what it repeats is that node together with everything parented under it. That bundle is called the prototype. In the picture above the Tree is an Empty with two meshes under it, a Trunk and a Crown, and all of it is drawn in each copy.
- An Empty is the natural host. It draws nothing itself, so it can hold several meshes that travel together.
- A mesh node can host an Instancer too. Then that mesh, and anything under it, is the prototype.
- An armature cannot host one, and it cannot be parented under another node. To repeat a rigged mesh, parent the mesh bound to the armature under an Empty and give the Empty the Instancer. The armature stays at the top level.
- The host node's origin is the zero point. A copy with no offset stands exactly where the host stands, and moving or turning the host carries every copy with it.
Add an Instancer
- Make the small object you want repeated, and parent it under an Empty. The last chapter covers both.
- Select the Empty.
- In the detail panel, scroll to Instancer, below Transform.
- Tap Add Instancer.
- Nothing seems to change in the viewport. There are ten copies now, but a new Instancer moves none of them, so they all stand on the same spot.
- Enabled switches the copies off without losing anything. With it off the prototype draws once, where you made it.
- Remove Instancer takes the Instancer and its graph away for good. Undo brings them back.
Count and Seed
- Count is a number field. Tap it, type a number and confirm. It runs from 1 to 10,000.
- Seed is a whole number that feeds every Instance Random node in the graph. The same Seed always gives the same arrangement, on every device and in every render. A different Seed gives a different one that follows the same rules.
- Seed does nothing until the graph uses Instance Random. The next chapter puts it to work.
| Count | Where the number comes from |
|---|---|
| Static | The number you type in Count |
| Vertex Count | The number of vertices in a mesh you choose under Counted Mesh. Edit that mesh and the count follows |
Vertex Count is for putting one copy on every vertex of another mesh, which a later chapter builds. Until you choose a mesh the row reads static fallback and the typed Count is used.
The Instancer FX graph
Where the copies go is decided by a graph called Instancer FX. It is the same kind of graph as a material's: nodes, wires, and one output node. It runs once for every copy, and what reaches the output is that copy's transform.
- With the host selected, tap Edit Instancer FX in the Instancer section.
- The graph docks under the viewport. Its title is the node's name followed by Instancer FX.
- Tap an empty part of the canvas to add a node, and drag from an output dot to an input dot to wire two nodes together.
- Tap the pin at the right of the graph's bar to close it. The arrows beside the pin open it full screen.
| Instance Transform | What it sets for each copy | With no wire |
|---|---|---|
| Position | Where the copy stands, measured from the host node along the host's own axes | 0, 0, 0: on the host |
| Rotation (deg) | Its turn in degrees, about X, Y and Z. The three are combined in the order Y, X, Z, the same order a node's own rotation uses | 0, 0, 0 |
| Scale | Its size along each axis | 1, 1, 1 |
| Visibility | Whether it is drawn. 0.5 or more draws it, less hides it | 1: drawn |
- The Add Node card offers fewer folders here than in a material: Input, Parameters, Math, Logic, Channels, Texture Processing and Instance. The graph is worked out copy by copy, not pixel by pixel, so colour, noise and coordinate nodes are not part of it.
- The Instance folder holds the nodes that tell copies apart: Instance Index, Instance Random, Grid, Node Transform and Mesh Vertex.
- A hidden copy keeps its number. Hiding copy 3 does not turn copy 4 into copy 3.
A row of copies
Instance Index gives every copy its number, counting from 0. Multiply that number by a distance and you have how far along the copy should stand.
- Tap empty canvas, open the Instance folder and choose Instance Index.
- Add a Multiply from Math and a Construct Vector3 from Channels.
- Wire Index into A of the Multiply. Select the Multiply and set B to the spacing you want, for example 1.5.
- Wire the Multiply into X of the Construct Vector3.
- Wire the Construct Vector3 into Position on Instance Transform.
- Copy 0 gets 0 times the spacing, so it stays on the host. Copy 1 moves one step, copy 2 two steps, and so on.
- Y and Z of the Construct Vector3 are left at 0, so the row runs along X only. Use Y for a stack, or Z for a row running front to back.
- A number in the graph is changed by dragging up or down on it, as everywhere in the editor.
- The row follows the host. Turn the Empty and the whole row turns with it.
Index, Normalized and Count
| Output | What it carries | Good for |
|---|---|---|
| Index | The copy's number: 0, 1, 2 and so on | Spacing copies evenly |
| Normalized | The same position as a fraction, 0 on the first copy and 1 on the last | Anything that should run from one end to the other whatever the Count: a fade in size, an arc, a climb |
| Count | How many copies there are | Dividing a length or a circle into equal parts |
- Normalized stays the same shape when you change Count. A row that grows from short to tall still does so with twenty copies or two hundred.
- With a single copy Normalized is 0.
Instancer or Instanced Offset?
A mesh's Modifiers list has an entry called Instanced Offset, which also repeats things. The two do different jobs.
| Instancer | Instanced Offset | |
|---|---|---|
| Where it lives | On a node, in the Instancer section | On a mesh, in its Modifiers list |
| What it repeats | The node and everything under it | That one mesh |
| What you get | Copies that are only drawn | Real geometry, joined into the one mesh |
| How copies are placed | A graph, free for every copy | One step, repeated in a line |
| Can each copy differ | Yes: place, turn, size and visibility | No, each follows the last by the same step |
| Can it move over time | Yes, the graph can read the clock | No |
| Can copies be welded together | No | Yes, with its merge distance |
- Reach for Instanced Offset when the result should be one solid object: a chain, a fence rail, a staircase.
- Reach for the Instancer when you want many separate things, when they should vary, or when they should move.
Limits worth knowing
- Count stops at 10,000.
- An Instancer inside another Instancer's prototype does nothing. Only the outer one makes copies.
- Picking and the selection outline stay where the original was made. Tap a copy and nothing is selected. Tap the original's own spot, or its row in the Node Hierarchy.
- A light inside the prototype is repeated in every copy, and each one counts towards the limit on lights in a frame. The Instancer section says so when the prototype holds a light.
- The copies are drawn, not built, so there is nothing to edit in Mesh mode beyond the one original.
- A skinned mesh in the prototype follows its armature's current pose in every copy. Giving each copy its own pose is Pose FX, a later chapter.
Grid for rows and columns, a ring from Sin and Cos, and Instance Random to break the pattern up.
Tell us which node carried the Instancer, what was parented under it, the Count, and what the viewport showed instead of what you expected. A screenshot of the graph helps.