Instancing and Procedural Motion · Chapter 9 of 9
Instancing: Bending Copies with Pose FX
Written for version 2.7.0
A rigid blade can only tilt. Give the prototype a few bones and Pose FX bends every copy on its own: grass that curves in the wind, reeds, kelp, and a small crowd that does not move in step.
Everything so far has moved copies as rigid pieces. The grass leans, ducks and falls over, but each blade stays as stiff as a card, because the Instancer FX graph sets one place, one turn and one size for a whole copy. Real grass curves. This last chapter of the path gives the prototype a few bones and uses a second graph, Pose FX, to turn those bones differently in every copy. The same idea makes reeds, kelp, and a small crowd that does not move in step.
A layer that remembers where something has been, and grass that slowly stands back up.
Tilt and bend
- A tilt turns the whole blade about its foot. The tip travels a long way and the blade stays straight.
- A bend leaves the foot where it is and curves the blade along its length, more towards the tip. It reads as something soft.
- Pose FX does not replace the Instancer FX graph. That graph still says where each copy stands, which way it faces and how tall it is. Pose FX only poses the bones inside it.
1. A prototype that can bend
A mesh bends where it has edges to bend at, and it bends because bones pull on it. The Rig Editor path teaches all three parts in its chapters Editing a Mesh, Armatures and Bones, and Weights. Here they are used in their simplest form.
- Make the blade a little taller and give it loop cuts across its width in Mesh mode, so that it has six or more rows of edges up its length.
- Add an Armature. It appears with one bone. Move it so the bone's head sits at the foot of the blade.
- In Bones mode, tap the bone's tail and Extrude three times up the blade, for a chain of four bones. Name them Root, Lower, Upper and Tip.
- In Node mode, select the Blade. In its Armature section tap Assign to Armature, choose the armature, and choose Automatic Weights.
- Try it in Pose mode: tap a bone, which picks Rotate up, and drag. The blade should bend there. Put the bones back to rest when you have seen it.
- Make sure the Blade is still parented under Grass Field.
- Three or four bones are plenty for a blade. Every bone is one more thing to work out for every copy.
- An armature is never parented under another node, and it does not need to be. Pose FX asks only that the mesh bound to it is inside the prototype.
- Leave the armature standing on Grass Field's origin. The copies are drawn from where the bones hold the blade, so an armature standing somewhere else carries every copy off by the same amount.
- The armature's own row has an eye. Hide the skeleton once it works: it is drawn once, on the original's spot, in the middle of the field.
2. Switch on Pose FX
- Select Grass Field and scroll the detail panel to Instancer.
- Under Edit Instancer FX there is now a switch called Pose FX. It is only there when something in the prototype is bound to an armature. Switch it on.
- Tap Edit Pose FX. A graph docks under the viewport, named Grass Field followed by Pose FX. It holds one node, Instance Transform.
- With Pose FX off, every copy takes the armature's pose as it stands. Pose the original and all nine hundred copy it.
- With Pose FX on and nothing wired, the result is the same. The graph adds to the pose, and an empty graph adds nothing.
- The two graphs are separate documents. Edit Instancer FX opens the one that places the copies, Edit Pose FX the one that poses their bones.
- Float nodes in the Pose FX graph are listed in the detail panel under Pose FX Inputs, below Instancer FX Inputs.
3. What the Pose graph sets
The Instancer FX graph is worked out once for each copy. The Pose FX graph is worked out once for each bone of each copy, and what reaches its output is added to that bone's pose.
| Instance Transform, in Pose FX | What it does to the bone | With no wire |
|---|---|---|
| Position | Moves the bone from where its pose has it, along the bone's own axes | 0, 0, 0: no move |
| Rotation (deg) | Turns the bone about its head, on top of its pose. X and Z bend it, Y twists it about its own length | 0, 0, 0: no turn |
| Scale | Scales the bone, and with it the part of the mesh it holds | 1, 1, 1: no change |
- There is no Visibility here. Whether a copy shows is decided once per copy, in the Instancer FX graph.
- A bone's own Y axis runs along its length, from head to tail. That is why Rotation Y twists and Position Y slides the bone along itself.
- A bone carries the bones that grow from it, as in Pose mode. Turn Root by 10 degrees and everything above it leans 10 degrees with it.
- What the graph gives is a difference, not a pose. Zero means leave the bone as it is, so a pose you set by hand stays, and Pose FX moves on top of it.
- Constraints on the bones are still solved, for each copy, after its pose has been changed.
4. Bone Index
If the graph gave the same answer for every bone, there would be little point in asking per bone. The Instance folder has two nodes here that the Instancer FX graph lacks, and the first is Bone Index: it says which bone is being asked about.
| Bone Index output | What it carries |
|---|---|
| Index | The bone's number in the armature, counting from 0. In a chain built upward from the first bone, the root is 0 |
| Normalized | The same as a fraction: 0 at the first bone, 1 at the last |
| Count | How many bones there are |
- Add a Float, give it the Label Bend and the value 16.
- Add a Construct Vector3. Wire Bend into X, and wire the Construct Vector3 into Rotation (deg). Every bone now turns 16 degrees from the one below, and the blade curls evenly from the ground up.
- Add a Bone Index from the Instance folder, and a Multiply. Wire Bend into A and Normalized into B, and wire the Multiply into X in place of Bend. The root no longer turns at all.
- For a whip, add a Pow from Math. Wire Normalized into A, leave B at 2, and wire the Pow into B of the Multiply.
- The turns add up along the chain. Four bones turning 16 degrees each put the tip 64 degrees over. With Normalized the four turns are 0, 5, 11 and 16, which is 32 degrees at the tip.
- Normalized keeps the foot planted, which is what makes it grass and not a hinge.
- Pow with a B above 1 holds the lower bones back even more. Below 1 it does the opposite and bends the blade near the ground.
- Normalized does not change when you add bones, so the same graph serves a chain of four and a chain of twelve.
5. Bending grass
Now the wind. Everything the Instancer FX graph can read, the Pose FX graph can read too: Instance Index, Instance Random, Grid, Node Transform, and Sample Texture. They give the copy's own values, the same for all of its bones. So the Wind layer from the grass chapter can drive the bend, each copy by the gust passing over its own spot.
- In the Pose FX graph, add a Grid and set Columns to the same number as in the Instancer FX graph.
- Add a Construct Vector2 with U in X and V in Y, a Texture Object set to Wind Target, and a Sample Texture reading it at that UV.
- Add a Split Vector on Color and a Remap of its X with Out Min -1 and Out Max 1, exactly as in the grass chapter.
- Multiply the Remap by the Bend Float, then Multiply that by Normalized from Bone Index.
- Wire the result into X of the Construct Vector3 that feeds Rotation (deg). For a diagonal bend wire it into Z as well.
- In the Instancer FX graph, take the wind's tilt out of the rotation, or leave only a little of it.
- The two graphs do not share nodes. The Grid here is a second Grid, and it needs its Columns typed again or the copies read the wrong spots.
- Bend is the turn of the last bone at full gust. The tip ends up at roughly twice that with four bones, since the turns below it add up.
- A little rigid tilt under the bend looks natural: the whole blade leans a few degrees and then curves on top.
- The trail and the effector of the last two chapters work here as well. A mark read from Trail Target can bend the blades down instead of scaling them.
6. A wave up the chain
So far every bone of a blade acts at the same moment. If each bone acts a little later than the one below it, movement travels up the chain: the tip follows the root. Subtract the bone's Normalized, times a small number, from whatever is driving the motion.
- Add an Elapsed Time and a Float with the Label Speed. Multiply them.
- Add an Instance Random, Multiply its Value by 6.28, and Add that to the last Multiply. Each copy now starts at its own point of the swing.
- Add a Bone Index and a Float with the Label Lag. Multiply Normalized by Lag.
- Add a Subtract. Wire the Add into A and the Lag product into B.
- Add a Sin, and Multiply it by a Float with the Label Sway. Wire that into X of the rotation's Construct Vector3.
- With Lag at 0 all bones swing together. Raise it and the upper bones fall behind. Around 2 the tip is a third of a swing late, which reads as a soft wave. At 6.28 it is a whole swing late.
- Sin runs from -1 to 1, and 6.28 is one full swing, so a random number from 0 to 1 times 6.28 spreads the copies over the whole cycle.
- Sway is degrees per bone. With six bones in step, 8 degrees each is 48 at the tip. Keep it small on long chains.
- The same trick works on the wind. Subtract Normalized times a small number, such as 0.05, from U before it goes into Sample Texture. The tip then reads the gust a moment after the root has, and the blade whips. If the wind's Speed on Scroll Coords is negative, add instead of subtracting.
7. One named bone: Bone Match
The second node that only Pose FX has is Bone Match. It asks whether the bone being worked out is one particular bone, by name.
- Add a Bone Match from the Instance folder. In its inspector, choose a bone in the Bone menu, here Head.
- Build the motion for that bone: a Sin of time with a random phase, as in the last section.
- Multiply the motion by Match, then by the number of degrees it should swing.
- Do the same for the Arm with a second Bone Match and a faster Sin.
- Wire the Head's result into X and the Arm's into Z of the Construct Vector3 that feeds Rotation (deg).
- Match is 1 for the chosen bone and 0 for every other. Multiplying by it switches a piece of the graph on for one bone alone.
- The Bone menu lists the bones that the prototype's meshes are bound to.
- Bones are matched by name. Rename a bone and the node has to be pointed at it again.
- Two Instance Random nodes with different Seeds keep the nod and the wave from following each other.
- Bone Index and Bone Match can work together: Normalized for a general curve, and a Match to add something to the Tip alone.
Recipes
| To get | Build |
|---|---|
| Reeds at the edge of a pond | A tall thin blade on four bones, a single row or a narrow band from Grid, the wind bend of section 5 with a small Bend, and a random height in the Instancer FX graph |
| Kelp or a row of tentacles | A long strand on six or more bones, and the wave of section 6. Lag sets how snaky it is, Speed how lively |
| A small crowd | A simple figure with a bone for each part that moves, a Bone Match for each of those bones, and a different Instance Random for each motion |
| Grass that is pressed down and curls | The mark from the Trails chapter, times Normalized, added to the bend in the Pose FX graph |
Honest notes
- Pose FX is worked out for every bone of every copy, on every frame. Nine hundred blades on four bones is 3,600 answers a frame, on top of the 900 for placing them. Keep the bone count as low as the shape allows, and lower the Count before anything else if the viewport slows.
- A render with the Ray Traced engine has to rebuild every posed copy whenever it restarts, which is heavy at high counts.
- Copies follow the armature's live pose. Posing the original changes all of them, with Pose FX on or off, because Pose FX adds to that pose.
- An armature has a Pose FX of its own, in the armature's detail panel. It is the same graph with the same Bone Index and Bone Match, for a single rig that is not instanced: a tail that sways or a plant that breathes. It runs before the armature's constraints.
- A blade bends only where it has loop cuts and only as smoothly as its weights allow. If the curve shows corners, add cuts, or repaint the weights so that each row is shared by two bones.
- In the viewport a bend driven by a layer is one frame behind that layer's picture. The Ray Traced preview holds the copies still while it refines.
The two render engines, lights and layers, and taking a picture of what you have built.
Tell us how the prototype is built: how many bones, how the mesh was bound, and whether Pose FX was on. Say what the copies did instead of what you expected. Screenshots of the Pose FX graph and of the original in Pose mode help.