Instancing and Procedural Motion · Chapter 3 of 9

Instancing: Copies on a Mesh

Written for version 2.7.0

Let another mesh decide where the copies go: Count from a mesh's vertices, the Mesh Vertex node, copies that stand out from the surface, and the modelling that controls where the points are.

The last chapter worked out every place with arithmetic. This one takes the places from something you have modelled: one copy on every vertex of another mesh. Spikes on a ball, studs round a drum, trees on a hill, bolts on the corners of a plate. The mesh that supplies the places is called the guide mesh in this chapter. It is an ordinary mesh node, and you control the copies by modelling it.

Count from a mesh

Two things are needed: as many copies as the guide has vertices, and each copy sent to a vertex of its own. The first is a setting in the Instancer section.

Tap Vertex Count and choose the guide under Counted Mesh. The Count row then reads its number of vertices, 42 for this Icosphere. Nothing has placed the spikes yet, so all 42 stand on the host.
  1. Add the guide mesh as a node of its own. Do not parent it under the Empty that carries the Instancer: everything under that Empty is part of the prototype and would be drawn once for every copy.
  2. Select the Empty and scroll the detail panel to Instancer.
  3. Tap Vertex Count.
  4. Tap Choose Mesh beside Counted Mesh and pick the guide.
  • Until a mesh is chosen the Count row reads the typed Count followed by static fallback, and that number is used.
  • Counted Mesh lists meshes by the mesh's own name, the one under Meshes in the Selection Panel. That can differ from the name of the node that carries it.
  • The count follows the mesh. Add or remove vertices and the number of copies changes with no further step.
  • It never drops below 1 and stops at 10,000.
  • Once a mesh is chosen the menu also offers None, which goes back to the typed Count.

The Mesh Vertex node

Mesh Vertex, in the Instance folder, reads one vertex of a mesh: where it is, and which way the surface faces there. Give it the copy's number and every copy reads a different vertex.

Mesh Vertex reads the vertex whose number comes in at Index. Position puts a spike on each vertex, all pointing up. Normal Rotation (deg) into Rotation turns each one to stand straight out of the surface.
  1. With the Empty selected, tap Edit Instancer FX. Add an Instance Index and a Mesh Vertex from the Instance folder.
  2. Select the Mesh Vertex and choose the guide in its Mesh menu.
  3. Wire Index from Instance Index into Index on Mesh Vertex.
  4. Wire Position into Position on Instance Transform. The copies jump onto the vertices.
  5. Wire Normal Rotation (deg) into Rotation (deg). Each copy turns to stand out from the surface.
OutputWhat it carries
PositionWhere the vertex is
NormalThe direction the surface faces at the vertex, as a vector one unit long
Normal Rotation (deg)The turn that points a copy's own up, its Y, along that direction. It is made to be wired straight into Rotation (deg)
UVThe vertex's place in the mesh's UV layout
CountHow many vertices the mesh has
  • The Mesh menu lists the nodes that carry a mesh, by node name. With nothing chosen every output is 0 and the copies stay on the host.
  • The same menu shows under Instancer FX Inputs in the detail panel, so the guide can be swapped without opening the graph.
  • Normal Rotation points the copy's Y along the normal. Model the prototype standing up along Y with its foot on the origin, as the spike is, and it will stand on the surface.
  • It is the shortest turn from straight up to the normal. How the copy is spun about its own axis is not yours to choose, which never shows on a spike or a stud and may show on an object with a clear front.
  • Index wraps round. If there are more copies than vertices, the extra ones start again at the first vertex and stand on top of the copies already there. With Count on Vertex Count the two always match.
  • To float the copies off the surface, multiply Normal by a distance held in a Float, add the result to Position with an Add, and wire the sum into Position on Instance Transform.
  • UV is there for reading a texture at each point, so that a painted map can decide which copies are drawn or how big they are. Later chapters use it.
  • UV follows the mesh's UV Origin style, so it is always the place where the mesh itself reads its texture.

Where the points are is modelling

There is no setting for how many copies there are or where they go. A copy stands on every vertex, so the way to add, remove or move copies is to edit the guide mesh.

The studs stand on the vertices of an open cylinder, one ring at each end. Two loop cuts add two rings of vertices, and two more rings of studs appear.
  • More loop cuts, more copies. A loop cut round a cylinder adds a ring of them, and loop cuts both ways across a plane turn four copies into a grid.
  • Move vertices in Mesh mode and the copies move with them. Proportional editing shapes a whole field of copies at once.
  • Delete or merge vertices to take copies away.
  • The guide does not have to be a tidy shape. A mesh whose only job is to hold points, each dragged to where a copy should stand, is a way to place copies by hand.

What counts as a vertex

The count is of the vertices the mesh is drawn with, and that can be more than the points you see in Mesh mode. A point is stored once for every different normal or UV it has.

Guide from the Add menuVertices countedWhy
Plane4One for each corner
Cube24Three at each corner, one for each face that meets there
Icosphere, 2 Subdivisions42One for each point
Cylinder, 12 Vertices, Cap Ends off2613 round each end: the column where the UVs meet is stored twice
  • A flat shaded mesh has a separate normal for every face, so a point is stored once for each face that meets it. On a Cube the copies stand three to a corner, each square to a different face.
  • Shade Smooth gives a point one normal, and so one vertex. Use it on a guide whenever you want one copy for each point. It is in the Shading menu of the node's detail panel, and under Shading in Mesh mode.
  • A UV seam splits points as well. The two copies on a cylinder's seam stand in the same place and face the same way, so you see one, but both are counted.
  • With Cap Ends on, a cylinder's end rings are stored again for the flat caps, facing straight up and down, and copies stand there too.
  • A UV Sphere stores its seam column twice and each pole once for every segment, so copies pile up at the poles. An Icosphere is the better ball to stand things on.
  • If the Count row reads more than you expect, shading or a seam is the reason.

Modifiers

  • Mesh Vertex reads the guide as it is displayed, with its modifiers worked out. Vertex Count counts the mesh's own vertices, before modifiers.
  • So with a Subdivision or a Mirror on the guide the two disagree. There are more points to stand on than there are copies, and only some of the points get one.
  • To use the points a modifier makes, tap Apply All in the guide's Modifiers section first. They become real vertices and the count follows.
  • A guide that is skinned to an armature is read in its unposed shape. The copies do not follow a pose.

Examples

Trees on a hill

Trees on a plane that was cut into a grid and pulled up into a hill. With Normal Rotation wired they stand square to the slope and lean outward. With only Position wired they keep their places and grow straight up.
  1. Add a Plane. In Mesh mode, cut it into a grid with loop cuts both ways and pull the middle up with proportional editing.
  2. Use Shade Smooth on it, so that each point is one vertex.
  3. Select the tree's Empty, tap Vertex Count and choose the plane under Counted Mesh.
  4. In the graph, wire Instance Index into a Mesh Vertex that reads the plane, and its Position into Position.
  5. Leave Rotation (deg) with no wire.
  • Trees grow upward whatever the ground does, so they take the place and not the turn. Rocks, tufts of grass and fence posts sunk into a slope look better with the turn.
  • With Rotation free, a random turn about Y can go into it: Instance Random times 360 into Y of a Construct Vector3, as in the last chapter. A random Scale works either way.
  • Loop cuts give trees in rows. Drag vertices about in Mesh mode, or delete a few, to break the rows up.
  • The hill is the ground as well as the guide, so it stays visible.

Bolts on a plate

The plate itself is no use as a guide. A box counts 24 vertices, three to a corner, and they are on its edges, not where the bolts go. Make a second mesh whose only job is to say where the copies stand.

The bolts sit on the four vertices of a plane laid on the plate. Tap the eye beside the plane in the Node Hierarchy to hide it: the bolts stay, because the Instancer still reads a hidden mesh.
  1. Add a Plane and scale and move it until its four corners are where the bolts belong, lying on the top of the plate.
  2. On the bolt's Empty, tap Vertex Count and choose the plane. In the graph, point Mesh Vertex at the plane and wire Position and Normal Rotation (deg).
  3. In the Node Hierarchy, tap the eye beside the plane.
  • A hidden node is not drawn, in the viewport or in a render. Its mesh is still there to be counted and read.
  • Hiding a node hides everything parented under it. Keep the Empty that carries the Instancer out from under the guide.
  • For more bolts, add vertices. A loop cut across the plane adds one on each of two edges.

Lamps along a curve

A curve node carries a mesh too, the one it is drawn with, so a curve can be a guide. Shown as a Wire, that mesh is a line of points.

A curve whose Style is Wire is a line of points joined by edges. Counted and read like any other guide, it puts one lamp on every point the curve is drawn through, and the lamps follow when the curve is reshaped.
  1. Add a Curve and shape it.
  2. In its Curve section, under Display, set Style to Wire.
  3. On the lamp's Empty, tap Vertex Count and choose the curve's mesh, which is named after the curve.
  4. In the graph, point Mesh Vertex at the curve and wire Position into Position.
  • Each stretch between two control points is drawn through as many points as Resolution says, plus one at the very end of the curve. Two stretches at a Resolution of 4 give 9 points. Raise Resolution for more copies.
  • The points are not an equal distance apart. They sit closer together where the control points are close and further apart where they are not.
  • A wire has no surface. Normal reads straight up and Normal Rotation is 0, so the copies stand upright and do not turn to follow the curve.
  • With Style on Tube the curve's mesh is the tube, and copies stand on every vertex of it.
  • The wire draws as a line. Hide the curve with its eye if it should not show.

Limits worth knowing

  • Copies go on vertices and nowhere else. There is no node that spreads copies evenly over a surface, or at random across its faces. Large faces get few copies and small faces many, because that is where the vertices are.
  • Mesh Vertex answers in the space of the node that carries the Instancer, already worked out so that the copies land on the vertices wherever the two nodes are. Move, turn or scale the guide and the copies go with it. Move the Instancer's node and they stay on the guide.
  • So it does not matter where the Empty is. Leaving it at the origin, unturned and at a scale of 1, keeps things simple: anything you add to Position in the graph is measured along the Empty's axes, and scaling the Empty makes every copy bigger.
  • To leave some vertices bare, use Visibility with a random test, as in the last chapter, or delete the vertices.
  • The count stops at 10,000. A guide with more vertices than that gets copies on its first 10,000.
  • The viewport and a render read the same vertices, so the layout is the same in both.
Something unclear?

Tell us which mesh was the guide and how it was made, what the Count row read, which outputs of Mesh Vertex were wired, and where the copies ended up. A screenshot of the graph helps.

Send Feedback