Houdini 19.5 Crowd simulations

Setting up a crowd simulation

How to set up and edit a crowd simulation.

On this page

Overview

Crowd simulations require a few different node networks to set up. Most of these have shelf tools that set up the networks for you.

  • A geometry network to define agent primitives.

  • A simulation network to run the crowd simulation.

Quick start

It’s possible to use the Simulate shelf tool to get a “demo” crowd simulation quickly in one scene. This is useful for getting a feel for the different networks involved in crowd simulations.

  1. Press ⌃ Ctrl + LMB on the Simulate tool on the Crowds shelf tab. The tool will automatically build agents and a crowd source networks using the mocapbiped1 character built into Houdini.

  2. If you have terrain geometry you want the agents to walk across, select it and click Terrain on the Crowds shelf tab.

Define an agent

Crowds assume your character is encapsulated as a digital asset or in an FBX file.

To...Do this

Create an agent from a character using the shelf tool

  1. At the Object level, select the character asset you want to turn into an agent.

  2. On the Crowds shelf tab, click the Agent tool.

    A dialog box appears asking for additional information about the new agent:

    • Choose whether you are importing from a character rig asset, FBX file, USD file, or LOP node.

    • Specify the character asset node’s path (or the file path of the FBX / USD file).

    • Set the Agent name.

    • Set the Clip name for the character’s animation. If you are importing the rest pose, you can use a clip name such as rest.

Set up an agent network manually

  1. At the Object level, create a Geometry object for the agent.

  2. Inside the geometry network, create an Agent node.

    • Set the Agent name.

    • Set the Input to “Character Rig”, then set the Character rig field to the path to your character node.

    • Click OK.

  3. Add a Null. Name this node AGENT_DEFINITION.

  4. If you want the option to eventually cache the agent definition to disk to speed it up, you can append an Agent Definition Cache node.

  5. If you're going to do terrain adaptation (where Houdini adjusts the agent’s animation so its feet plant properly on the terrain geometry), or look at (where Houdini edits the agent’s neck joint to point its head at something), or other features that require Houdini know which joints represent which body parts, you need to append an Agent Prep node.

    In the Agent Prep parameters, you can associate joints in the character with specific body parts.

  6. If you're going to do ragdoll simulation of agents, you need to set up collision geometry and joint limits on the agent. See how to set up agents for ragdoll.

  7. Finally, append another Null at the end of the network and give it the display flag. This will serve as a convenient node to reference for the output of the network which doesn’t change even if you add other nodes before it.

    The usual convention is to name this node OUT.

Agent definition network

This network is where you (or the shelf tools) add nodes to modify the agent primitive before simulation, such as adding layers, and adding collision and rotation information for ragdoll simulation.

Agent node

Creates an agent primitive, and sets basic information such as its name, the current layer, and the current animation clip.

Agent Clip node

Adds one or more animation clips to the agent definition.

AGENT_DEFINITION node

This node exists as a reference target for the simulation network to grab the agents using a POP Source node.

Agent Definition Cache

Can write out the agent definition to disk and then in subsequent cooks read the definition from the cached files instead of the input. You can use this to speed up the agent definition network if cooking the character is slow.

Agent Prep

Sets up additional information on the agent, such as the names of important joints and specifies transforms to use for different limbs, so the solver knows how to do foot placement and other procedural changes. This is after the Agent Definition Cache node, because it’s always fast to compute so it doesn’t need to be cached.

OUT node

Marker for the end of the “cache-able” section of the agent definition. A convenient target for importing the final agent definition into other networks.

Adding animation clips to an agent

A clip is a bit of animation (for example, standing, walking, running) on a character. You can add clips to the agent definition, so the agent can perform different animations in different states.

To...Do this

Set up animation sources

Before you can add clips to an agent, you need to set up individual instances of the source character performing each animation.

For example, say you have an agent based on character1 which has animations for walking and running. You would set up an instance of character1 performing the walk (called, for example, character1_walk), and another instance performing the run (character1_run).

The most convenient way to do this is if your character has embedded animation you can switch to using a pop-up menu on the character asset itself. Then you can simply create as many instances as you need and set the menu differently on each one.

Add an animation clip to an agent using the shelf tool

  1. Select the Geometry object containing the agent definition network (see above).

  2. A dialog box appears asking for information about the clip:

    • Choose whether you are importing animation from a character rig asset, FBX file, USD file, or LOP node.

    • Specify the character asset node’s path (or the file path of the FBX / USD file).

    • Set the Clip name for this animation.

    • Click OK.

Add an animation clip to an agent manually

  1. Go into the geometry network containing the agent definition SOP chain.

  2. After the Agent/Agent Prep node(s), add an Agent Clips node.

Note

In previous versions of Houdini’s crowd system, where agent information was always baked to disk, you could have a single instance of your character, set it to play an animation clip, bake out that clip, edit the same instance to play a different clip, bake out that clip, and so on.

The current system is much more convenient and no longer requires baking files to disk. The system simply cooks the character information it needs directly in Houdini. However, this means you need separate instances of the character asset performing each animation clip, so the crowd system can cook them when necessary.

Create a crowd source

To create a crowd, you need a crowd source network that creates a crowd of agent primitives. This network scatters points and then instances agent primitives onto the points.

  1. On the Crowds shelf tab, click Populate.

  2. Select the agent setup object, then press Enter.

  3. If you have terrain geometry, select it and press Enter, or just press Enter if you don’t have terrain.

    (With no terrain geometry, the node will simply scatter agents across an area defined by parameters on the node).

Tip

You can edit the resulting network and use whatever SOPs you want to set up the points before copying agents onto them. For example, instead of scatting the points, you could use SOPs to set them up in ordered rows if that’s what you need.

Crowd source network

Object merge

These nodes “import” the agent primitive from a setup networks.

Crowd Source node

This node copies agent primitives onto points. It has options for automatically scattering agents across a surface or within a defined area, as well as for randomizing their initial states.

Agent Constraint Network

This node sets up the constraint networks between agent parts, for ragdoll simulation.

merge_crowdsources

This node merges the separate import → crowd source → constraints branches for each agent class in the simulation.

Below this is a null node to act as a target for importing the agents into the crowd simulation DOP network. You can wire nodes you want to apply to all agents between these two nodes.

crowd_sim_import

This DOP IO node node imports the results of the DOP crowd simulation back into this object so it can be rendered.

You can wire geometry into the second input of the crowd source node to control the scattering of agents.

  • If you wire in point geometry, it will create agents at those points.

    If the input points have agent related attributes on them, the attributes will be copied onto the new agent primitives. This is a very effective way of manually or randomly specifying different starting conditions, looks, etc. across agents.

  • If you wire in surface geometry, it will use the dimensions of the of the surface as the area across which to randomly scatter a number of agents controlled by a parameter.

    If the surface has a density attribute, the node will only create agents where the attribute is non-zero.

  • If you don’t wire in any geometry, it will use its parameters to decide the area and number of agents to randomly scatter.

Create a crowd simulation

The crowd source network generates agent primitives representing the individual agents in the crowd. To make the crowd move and execute behaviors, you need a crowd simulation network.

  1. Select the crowd source object.

  2. On the Crowds shelf tab, click Simulate.

    The tool will build a dynamics network the loads the crowd source and applies a few default behaviors. You can edit the nodes in this network to set up the crowd behaviors you want.

    See dynamics network below for information on the general structure of this network.

DOP network

The Simulate shelf tool creates the geometry network above as well as a simulation network with some sample nodes for simulating the crowd.

States and behaviors

Each branch leading into the merge_states node starts with a Crowd State node, which specifies the state name.

The state node is followed by behavior nodes specific to that state, between the state node and the merge_states node. These behaviors do not execute in sequence, they are normalized and applied simultaneously to the agents in that state.

You can wire behavior nodes after the merge_states node. Those behaviors will apply to all states. This is useful for things like avoiding obstacles.

The state name should correspond to an animation clip of the same name that agents will play while in that state.

Triggers and transitions

Each branch leading into the merge_transitions starts with a Crowd Trigger node specifying a condition that will cause an agent to change state. You can combine multiple conditions using the Crowd Trigger Logic node, which lets you specify “And”, “Or”, and “Not” relations between two triggers.

The trigger node(s) is/are followed by a Crowd Transition node which specifies that agents in one state should switch to another state when the trigger condition is met.

(You can wire multiple Transition nodes between a trigger and the merge_transitions if you want a trigger to cause multiple state changes.)

Crowd source

This is a POP Source DOP that references agent primitives created in the crowd source network.

Crowd solver node

Implements the crowd system. The solver has controls for several optional default behaviors that can apply to all agents, such as agent-to-agent collision avoidance, and terrain following.

Crowd Object and POP solver

These nodes are used by the particle (POP) foundation on which the crowd system is built. You will not usually need to modify these nodes.

Tip

Houdini automatically color codes certain nodes to make it easier to keep them straight in the network editor (Crowd State pink, Crowd Trigger orange, Crowd Trigger Logic green). If you want to, you can change a node’s color after it is created.

Shelf tools

The following tools are on the Crowds tab of the shelf.

Add Clip

Add an animation clip to an agent definition by referencing a character instance performing that animation.

Collision Layer

Set up simple collision geometry around an agent character’s skeleton.

Configure Joints

Set up joint rotation limits on an agent character, for use in ragdoll simulation.

Populate

Create a network to scatter agents across the selected geometry, but do not create the simulation network. This may be useful for layout artists who don’t want to create a simulation.

Paint density

Paint density attributes on terrain geometry to control the random distribution of generated agents.

Simulate

Set up geometry and simulation networks with sample animated agents and sample behaviors. This is useful for setting up the networks quickly, and you can then modify them to suit your needs.

Terrain

Set the selected geometry as terrain for the current crowd simulation.

Obstacle

Add the selected geometry as an obstacle for the current crowd simulation.

Path

Create a POP Steer Path node to make all agents follow the selected path. If you want only agents in a certain state to follow the path, you need to rewire the POP Steer Path node. See the simulation network overview and states and behaviors.

Look At

Have agents keep their head turned toward the selected object.

Target Position

Have agents chase the selected object.

Agent Cam

Create an attach cameras to the head transform of the selected agents.

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 which controls the agent’s animation and which 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.