Houdini 20.5 Crowd simulations

SOP motion paths

How to use SOP motion paths to modify the behavior of a small number of agents.

On this page

Overview

The crowds DOP workflow is a simulation-based approach, where at any given time, agents are in a particular state that defines their movement and the animation clip that is played back. In a particular state, agents could, for example, be walking toward a goal, or wandering around and avoiding other agents. The forces that act on the agents and steer their movement are constantly evaluated, as are triggers, which determine what is happening around the agents and transitions them to another state at some point in time. This approach is powerful for large crowds, because you can set up a few simple rules to control the general behavior of an entire crowd.

The challenge with the DOP simulation workflow is getting precise control for a small number of agents. For example, if you want to change the path of one agent, you would have to think about how to change your crowd setup so that the behavior of the one agent is updated without affecting the other agents. This is difficult, because all the agents in a crowd simulation react to each other.

With SOP motion paths, users can quickly make changes to the motion path or animation of a small number of agents without the need to resimulate the entire crowd. The SOP motion path tools do not involve any simulation - it is not going one timestep forward, evaluating forces and triggers, and determining whether to switch agents to a different state. Instead, an agent’s motion path describes the overall position of the agent across time, and manipulations are performed on the path to determine where the agent will go.

SOP motion paths for a crowd of agents

The SOP motion path tools provide an alternative way for users to set up crowd shots. Mix and match the SOP motion path tools with the DOP simulation workflow to get the desired crowd behavior.

Basic setup

The starting point of the SOP crowds motion path toolset is the Crowd MotionPath SOP, which generates motion paths from a crowd of agents. The Crowd MotionPath Evaluate SOP is the companion node to the Crowd MotionPath SOP. It determines the agent’s position along the path at a particular frame, and plays back the animation on the agent.

Between the Crowd MotionPath and Crowd MotionPath Evaluate SOPs are operations that:

  • Manipulate the agents' paths, directing where the paths should go.

  • Transition between different animation clips based on various triggers.

Generate crowd motion paths

The input to the SOP crowds motion path tools is a crowd of agents.

Note

The same setup is used for creating the input crowd for both SOP motion paths and DOP simulations.

Below is one example of a basic setup for creating a crowd of agents. See Setup for more information on how these nodes are used in crowds.

Example of a basic setup for using SOP motion path tools

The motion paths generated by the Crowd MotionPath SOP are represented by curves that describe the agents' positions at each point in time within a specified frame range. The paths have the whole time range laid out in front of them. By default, the agents' paths are generated from the animation clip assigned to the agent. The motion data is taken from the animation clip and cycled forward to generate the agents' positions at each point in time.

Animation played back by Crowd MotionPath Evaluate SOP

Note

The Crowd MotionPath tools are similar to the MotionClip tools, where the poses of the skeleton are laid out across time.

To...Do this

Change the frame range used to generate the path

In the Crowd MotionPath SOP, change the Start/End/Inc values.

Change the animation clip(s) used to generate the agent paths

In the Clip Assignment section of the Crowd MotionPath SOP, set Clip Names to the name of the clip. If you have a library of animation clips, you can specify different clips to be randomly selected for agents to play.

  1. You can specify multiple clips in each Clip Names parameter.

    Note

    If you select a clip from the Clip Names drop-down menu, the clip name will be appended to the existing list of entries in Clip Names.

  2. Set the Weight for the group of clips in Clip Names. A higher weight value makes it more likely for agents to play those clips.

  3. Add clips with different weights by clicking beside Clip Groups.

Build the agent paths from a simulation

Instead of building the agent paths based on the motion in animation clips, the paths can also be generated from a simulation.

In the example below, the crowd simulation DOP network makes the agents wander around and avoid each other. To generate paths from the DOP simulation:

  1. Connect the DOP network to the Crowd MotionPath SOP.

    DOP simulation network to generate agent paths
  2. In the Crowd MotionPath SOP, set Source Mode to Simulation.

Using crowd simulation to generate agent paths

This example demonstrates how to generate motion paths from a simulated crowd.

Change the speed of the animation clip

In the Crowd MotionPath SOP, adjust the Clip Speed.

Vary the clip speed between different agents by selecting Set Varying in the the drop-down menu beside Clip Speed, and adjusting the Variance and Variance Seed values.

Show the agent position along the path at each point in time

Turn on Display points in the right viewport toolbar.

Manipulate agent paths

The following nodes change the paths that agents follow across time:

Crowd MotionPath Follow

Deforms the original agent paths to follow the curve(s) drawn in the viewport.

Crowd MotionPath Edit

Allows you to directly manipulate the paths to determine exactly where the agents should go. This offers a finer level of control than Crowd MotionPath Follow.

Crowd MotionPath Avoid

Performs collision detection and avoidance between agents.

Agent paths follow guiding curves

You can quickly draw guiding curves for agents to follow, which is useful, for example, if you want agents to follow along the path of a road. The Crowd MotionPath Follow SOP deforms the original agent paths to follow the curves drawn. It changes the position and orientation of the points along the path, but not the animation clip.

  1. Connect the Crowd MotionPath Follow SOP between the Crowd MotionPath and Crowd MotionPath Evaluate SOPs.

  2. Connect the Curve SOP to the Crowd MotionPath Follow SOP (3rd input).

  3. Draw a curve (or multiple curves) in the viewport using the Curve SOP. By default, agent paths follow the closest curve.

    Note

    Display the construction plane so that the curves automatically snap onto the construction plane. Click Display Construction Plane on the right viewport toolbar.

In the example below, the Crowd MotionPath Follow SOP is displayed while the curves are being drawn (Curve SOP is selected) so that you can see how the paths are being deformed. After the curves are drawn, the Crowd MotionPath Evaluate SOP is selected and displayed to show the animation of agents moving along the updated paths.

Agents follow curves drawn in the viewport

This examples demonstrates how to deform motion paths to follow guiding curves, along with more advanced options such as following closed loops and using attributes to control which curves are followed by each agent.

MotionPathFollowCurve

To...Do this

Remove all curves drawn using the Curve SOP

In the Curve SOP, click Reset Operations.

Directly manipulate agent paths

With the Crowd MotionPath Edit SOP, you can directly manipulate the paths to determine exactly where the agents should go. This node offers a finer level of control for manipulating paths than the Crowd MotionPath Follow SOP.

  1. Connect the Crowd MotionPath Edit SOP between the Crowd MotionPath and Crowd MotionPath Evaluate SOPs.

  2. Select and display the Crowd MotionPath Edit SOP.

  3. In the viewport, drag points along the curve to deform the path. These points are called pins.

Note

Turn on the construction plane so that when you drag points on a flat terrain, they will be dragged along the construction plane.

Directly edit agent paths

A few notes:

  • Each pinned point on the motion path has a weight, which determines how strongly the path is affected by the pin. You can change the weight of each pin with the Pin Weight parameter in the HUD slider.

  • When the deformed curve does not pass through the pinned point, a dotted line is displayed to show the relationship between the pin and its original point on the curve.

  • By default, the length of the curve is generally preserved as the motion path is changed.

This example demonstrates how to use the Crowd MotionPath Edit SOP to interactively adjust the paths of specific agents.

To...Do this

Drag multiple pins

  1. Box select or ⇧ Shift select multiple pins.

  2. drag.

Delete the selected pins

Press Delete.

Change the weight of the selected pins

Use or change the Pin Weight parameter in the HUD slider.

Set the default weight of new pins

Set the Default Pin Weight parameter.

Change the weight of the starting point of the motion paths

Set the Start Point Weight parameter.

Remove all edits on the selected paths

Press U to delete the edits on all paths with selected pins.

Remove all edits

Click Reset All Changes in the parameter editor.

Collision detection and avoidance

The Crowd MotionPath Avoid SOP performs collision detection and avoidance between agents.

  1. Connect the Crowd MotionPath Avoid SOP between the Crowd MotionPath and Crowd MotionPath Evaluate SOPs.

  2. Select and display the Crowd MotionPath Avoid SOP.

    By default, Visualize Collisions is turned on, which highlights the parts of the motion paths that have collisions. The sphere guide geometry shows the agent’s size that is used for collision detection.

    Visualize collisions
  3. Adjust the parameters in the Steering tab and the number of Iterations to try to resolve the collisions. Iterations is the number of avoidance passes that are made on the curves to try to resolve collisions. Later iterations may have little effect if the Steering parameters are too restrictive.

Note

If you want more control over where the agents should go, use the Crowd MotionPath Follow or Crowd MotionPath Edit SOPs.

To...Do this

View potential collisions

Turn on Visualize Collisions. The parts of the motion paths with collisions are highlighted.

Visualize Collisions is useful for determining where collisions occur even if Avoidance is turned off.

Perform collision avoidance on specific paths

  1. Click beside the Group parameter.

  2. In the viewport, select the paths to deform to avoid other agents and obstacles.

  3. Click Enter.

The agents specified in Group can still collide against agents that are not listed in Group.

Specify how far in advance agents start avoiding potential collisions

Adjust the Max Collision Time.

With a higher Max Collision Time, agents start trying to avoid potential collisions earlier.

Change the agent’s size for collision detection

Adjust the Particle Scale Multiplier to change the collision size for all agents.

Each agent can also inherit the attribute pscalemultiplier that is configured upstream, for example, using the Attribute Adjust Float SOP. The pscalemultiplier attribute is scaled by Particle Scale Multiplier.

Set the frame range to apply collision avoidance

Turn on and specify the Start Frame and End Frame.

Set the initial rotation angle at the start of the path

Turn on and set Max Initial Rotation.

This is useful if the agents are very close together at the start of the motion path and you want them to move away from each other. Max Initial Rotation allows you to configure the agents to immediately turn and face the other way only in the beginning. This avoids having to adjust the Max Turn Rate, which affects the turn rate for the entire time range.

Preserve the original end position of the paths

Increase the Goal Position Weight.

Avoid neighboring agents

  1. Turn on Neighbors.

  2. Increase Neighbor Distance to start avoiding agents earlier.

Avoid obstacles

  1. Connect the obstacle geometry to the 3rd input of the Crowd MotionPath Avoid SOP.

  2. Turn on Obstacles.

  3. Increase Obstacle Distance to start avoiding the obstacle earlier.

  4. Increase Collision Padding to make agents stay further away from the obstacle.

  5. Adjust the Horizontal FOV to change the viewing angle at which agents can see obstacles. To perform obstacle avoidance for only the agents who are on a collision path with the obstacle, decrease the Horizontal FOV.

No obstacle avoidance
Obstacle avoidance turned on

This example demonstrates how the Crowd MotionPath Avoid SOP can be used to avoid obstacles.

Specify that certain groups of agents ignore collisions with other groups

This example demonstrates how the Crowd MotionPath Avoid SOP can be used to apply avoidance between neighboring agents. The collisionignore and collisiongroup string attributes are used to build more complex avoidance rules and collision filtering between different groups of agents.

If an agent’s collisionignore string pattern matches the collisiongroup that a neighboring agent belongs to, the agent ignores the collision with the neighboring agent - it does not attempt to avoid the neighboring agent.

If an agent’s collisionignore pattern = *, the agent does not attempt to avoid any collisions. In this case, the Crowd MotionPath Avoidance SOP does not have any effect.

If an agent’s collisionignore string is empty, the agent does not ignore any collisions - it can collide against everything.

Set a path for agents to follow

The Crowd MotionPath Avoid SOP can be used to have agents follow a path by inputting line geometry as an obstacle, which will be treated as a tube shape that the agent tries to avoid.

Output a point group on geometry that contains the points with collisions

Turn on Collision Point Group and specify a name for the point group.

Transition between animation clips

The following nodes control the transition between animation clips:

Crowd MotionPath Transition

Switches to a different animation clip.

Crowd MotionPath Trigger

Sets the conditions that trigger a transition to another animation clip.

Crowd MotionPath Layer

Layers different animation clips on top of the agent’s base animation. Layered clips can be applied to specific parts of the skeleton.

Manually select clip transition point

Transition to a new animation clip using the Crowd MotionPath Transition SOP.

  1. Connect the Crowd MotionPath Transition SOP between the Crowd MotionPath and Crowd MotionPath Evaluate SOPs.

  2. In the Crowd MotionPath Transition SOP, set Clip Name to the new animation clip.

By default, Crowd MotionPath Transition switches the agents' animation clips at the beginning of the frame range.

Transition to new animation clip at beginning of frame range

To transition to the new animation clip at a later point on the path:

  1. In the Crowd MotionPath Transition SOP, click beside Trigger Group.

  2. In the viewport, select the points on the paths at which to start the transition. Hold SHIFT to select points on different paths. If multiple points are selected along a single path, the transition will occur on the first selected point on the path.

  3. Click ENTER. The Trigger Group parameter will be populated with the selected points.

Transition to new animation clip at manually selected points

This example demonstrates how to use the Crowd MotionPath Transition SOP to blend between animation clips, as well as how to use intermediate transition clips defined by a clip transition graph.

To...Do this

Switch to a new animation clip based on multiple triggers

In the Combine Triggers section, use boolean logic to specify different combinations of triggers.

Transition agents to the new animation clip at slightly different times

  1. Turn on Random Delay.

  2. In the Random Delay section, adjust the Max Random Delay and Random Seed parameters.

Transition to different animation clips

If you have a library of animation clips, you can specify different clips to be randomly selected as the next clip to transition to.

  1. Turn on Randomize Clips.

  2. Set the Clip Names to transition to. You can specify multiple clips in each Clip Names parameter.

  3. Set the Weight for the group of clips in Clip Names. A higher weight value makes it more likely for those clips to be selected as the next clip.

  4. Add clips with different weights by clicking beside Clip Groups.

Transition to a new clip through a sequence of transitions

Use a clip transition graph to have more control over the clip transitions. The clip transition graph automatically finds transition regions between pairs of clips to determine a point where the current clip blends nicely into the new clip. You can also specify a sequence of transitions from the current clip to the new clip.

  1. Add an Agent Clip Transition Graph SOP to the agent definition (place it anywhere after the Agent SOP and before the Crowd Source SOP).

  2. Specify the different transitions that the agents can take. In the Agent Clip Transition Graph SOP, click beside Filters to add a clip transition.

    For example, you could specify the following clip transitions:

    • Clip A: idle, Clip B: walk

    • Clip A: walk, Clip B: run

    • Clip A: run, Clip B: run_turn_left

    • Clip A: run, Clip B: run_turn_right

  3. Set the trigger conditions and clips to transition to. You can optionally specify a random collection of clips to transition to (see the “Transition to different animation clips” how-to).

  4. On the Crowd MotionPath Transition SOP, turn on Use Clip Transition Graph.

Using the clip transitions above as an example, if you specify:

  • idle and walk as the initial clips (in the Crowd MotionPath SOP)

  • run_turn_left and run_turn_right as the clips to transition to (in the Crowd MotionPath Transition SOP)

Then agents playing the initial idle clip would transition to, say, run_turn_left by following the below transitions in the clip transition graph:

  • idlewalk

  • walkrun

  • runrun_turn_left

Agents playing the initial walk clip would transition to, say, run_turn_right by also following the appropriate transitions in the clip transition graph:

  • walkrun

  • runrun_turn_right

Note

You can initialize clips in either the Crowd Source SOP or the Crowd MotionPath SOP. It is a workflow preference as to whether you want to assign clips when populating the crowd layout, or just before generating the agent paths.

Assigning clips in the Crowd MotionPath SOP is a bit more flexible since you can use the Group parameter to set up clip assignments for different groups of agents and override the clips for specific agents.

Transition to new animation clip based on trigger conditions

The Crowd MotionPath Trigger and Crowd MotionPath Transition SOPs work together to switch the agents' animation clips when certain conditions are met.

Crowd MotionPath Trigger sets the conditions that trigger a transition to another animation clip, and Crowd MotionPath Transition switches the agents' animation clips when the trigger conditions are met.

  1. Connect the Crowd MotionPath Trigger and Crowd MotionPath Transition SOPs between the Crowd MotionPath and Crowd MotionPath Evaluate SOPs.

    Crowd MotionPath Trigger and Transition network
  2. In the Crowd MotionPath Trigger SOP, the name of the trigger, Trigger Name, is set to the Crowd MotionPath Trigger node name by default, in our case, crowdmotionpathtrigger1. You can change Trigger Name to a more meaningful name, as it is used by subsequent nodes such as the Crowd MotionPath Transition SOP to reference the trigger.

  3. In the Crowd MotionPath Trigger SOP, set the trigger type in the Type parameter. To switch the animation clip at a particular frame:

    • Set Type to Time.

    • Set Frame to the frame at which to transition to a different animation clip.

    In the example below, the Crowd MotionPath Trigger SOP is selected and displayed. The points on the path that satisfy the trigger condition are highlighted.

    Trigger condition satified at highlighted points on the paths
  4. In the Crowd MotionPath Transition SOP:

    • Set Trigger Group to the name of the Crowd MotionPath Trigger SOP (in our example, crowdmotionpathtrigger1).

    • Set Clip Name to the new animation clip.

    In the example below, the Crowd MotionPath Transition SOP is selected and displayed. The points on the path that satisfy the trigger condition are transitioned to the new animation clip.

    Transition to new animation clip

Note

The Crowd MotionPath Trigger and Crowd MotionPath Transition nodes are the SOP-level equivalents to the Crowd Trigger and Crowd Transition DOPs in the crowd simulation network.

This example demonstrates how to use the Crowd MotionPath Transition SOP and Crowd MotionPath Trigger SOP to blend between animation clips.

To...Do this

Switch to a new animation clip when the agents are inside an area or geometry

  1. In the Crowd MotionPath Trigger SOP, set Type to Bounding Region.

  2. In the viewport, resize the box using the handles.

  3. Set Comparison to specify whether points that are inside, outside, entering, or leaving the box trigger a transition to the new animation clip.

  4. Select and display the Crowd MotionPath Trigger SOP to see the highlighted points that satisfy the trigger condition.

    Trigger a transition when inside the bounding region
  5. Select and display the Crowd MotionPath Transition SOP to see the updated agent paths.

    Updated paths using the bounding region trigger

The Comparison method of Incoming highlights the one point on each path where the transition is triggered.

Transition triggered at highlighted incoming point

You can also use other geometry as the bounding region that triggers a transition. In the example below, the rubber toy test geometry is used as the bounding region.

  1. Connect the rubber toy test geometry to the Crowd MotionPath Trigger SOP (3rd input).

  2. Set Type to Bounding Region.

  3. Set Bounding Type to Bounding Object.

  4. Set Comparison to Inside.

The transition to the new animation clip is triggered when the agents are inside the rubber toy geometry (the rubber toy geometry is templated below).

Trigger transition inside geometry

See the Crowd MotionPath Trigger node doc for other types of pre-built triggers that are available.

This example demonstrates how to layer a clip onto an agent and activate the clip when the agent is inside a bounding object.

MotionPathLayerClip

Layer animations

The Crowd MotionPath Layer SOP provides an easy way to add additional motion onto an agent like waving or turning the agent’s head, without having a whole new animation clip that performs the desired combination of different motions. Crowd MotionPath Layer is similar to Crowd MotionPath Transition, but instead of switching to a completely new animation clip, it layers different clips on top of the agent’s base animation. Layered clips can also be applied to specific parts of the skeleton.

  1. Connect the Crowd MotionPath Trigger and Crowd MotionPath Layer SOPs between the Crowd MotionPath and Crowd MotionPath Evaluate SOPs.

  2. Add an Agent Transform Group SOP when building the agent definition. Agent Transform Group creates a named group of joints which is used to determine the part of the skeleton to apply the layered clip to.

    Place the Agent Transform Group SOP anywhere in the agent definition after the Agent SOP and before the Crowd Source SOP.

  3. In the Agent Transform Group SOP, use the Transform Groups multi-parm to create new joint groups. For each group:

    • Set Name to the name of the joint group, for example, upper_body.

    • In Root Transforms, select the root joint(s) for the group. Each root joint and its descendants are added to the group.

    • To see the joints that are part of the group, turn on Show Guide Geometry, which displays spheres around the selected joints. Display the agent as Wireframe to more clearly see the guide geometry.

  4. In the Crowd MotionPath Layer SOP, set Transform Group to the joint group that will play the layered clip.

  5. Set Clip Name to the layered clip.

In the example below, the agents' upper bodies play the layered zombie clip starting at frame 100, while the lower bodies play the original walking clip. The following parameters are set in the Crowd MotionPath Layer SOP:

  • Trigger Group is set to the name of the Crowd MotionPath Trigger SOP, crowdmotionpathtrigger1. The Crowd MotionPath Trigger SOP triggers a transition at frame 100.

  • Transform Group is set to upper_body.

  • Clip Name is set to walk_zombie.

Layer animation on agents' upper bodies

This example demonstrates how to use the Crowd MotionPath Layer SOP to layer a clip onto the upper body of an agent. The clip is activated when the agent is inside a bounding object.

MotionPathLayerClip

To...Do this

Switch to a new animation clip based on multiple triggers

In the Combine Triggers section, use boolean logic to specify different combinations of triggers.

Transition to different animation clips

If you have a library of animation clips, you can specify different clips to be randomly selected as the next clip to transition to.

  1. Turn on Randomize Clips.

  2. Set the Clip Names to transition to. You can specify multiple clips in each Clip Names parameter.

  3. Set the Weight for the group of clips in Clip Names. A higher weight value makes it more likely for those clips to be selected as the next clip.

  4. Add clips with different weights by clicking beside Clip Groups.

Change how quickly the original clip blends into the layered clip

Adjust Blend In Frames and Blend Out Frames.

Partially blend the layered motion clip with the original animation

Adjust the Blend Ratio. A Blend Ratio of 1 fully uses the layered motion clip on top of the original animation clip.

Set the layered clip to play for only a few seconds

Adjust the Number of Loops parameter. If Number of Loops is set to 1, the layered clip plays back once before going back to the original animation clip.

Other operations

Crowd MotionPath Retime

Speeds up, slows down, crops or shifts the animation motion.

Crowd simulations

Getting started

  • Basics

    An overview of Houdini crowd simulation concepts.

  • Setup

    How to set up and edit a crowd simulation.

The moving parts

  • Agents

    About agents, the moving actors that make up a crowd simulation.

  • States

    About agent states, the virtual mood of each agent that controls the agent’s animation and the behaviors it runs.

  • Triggers

    How to specify conditions that cause agents to change from one state to another.

  • Caches

    Tips for efficiently caching and loading crowd sims.

Behavior

Appearance

  • Diversity

    How to create a more realistic crowd by making agents look and act differently.

  • Attaching cloth

    You can add and constrain vellum cloth as part of agent shape geometry, and then simulate the cloth based on agent movements.

Terrain

  • Foot planting

    How to set up agents to adapt their animation to terrain and prevent skating.

  • Terrain

    How to specify terrain geometry for agents to walk across.

  • Obstacles

    How to set up obstacles for agents to avoid.

SOP crowds

Crowd Procedural