Houdini 20.0 Crowd simulations

Setting up a crowd simulation

How to set up and edit a crowd simulation.

On this page

Overview

Crowd simulations require both a geometry (SOP) network and a simulation (DOP) network:

  • A geometry (SOP) network is used to create and define the agents. The full power of Houdini’s SOP nodes can be used to create agent positions from existing models such as terrain.

  • A simulation (DOP) network is used to run the actual crowd simulation. The DOP crowd simulation network holds the logic that controls the movement of each particle (and in turn, the agent that is attached to it). Within the DOP network, agents can interact with other dynamic (DOPs) elements.

Quick start

Use the Simulate shelf tool to quickly get a basic crowd simulation scene up. Then tweak the network for your purposes.

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

    Object level network created from the Simulate shelf tool

    The crowd simulation network (crowd_sim) created by the Simulate shelf tool:

    Crowd simulation DOP network
  2. If you have terrain geometry you want the agents to walk across, select the terrain geometry and click Terrain Foot Planting on the Crowds shelf tab. The terrain object will be added as an input to the static solver.

    Terrain object in the crowd simulation network
  3. Play the simulation by clicking Play on the playbar. The agents will stand, and then walk.

Define an agent

An agent is defined in an agent definition network, a geometry (SOP) network where you (or the shelf tools) can add nodes to modify the agent before the crowd simulation. Modifications can include adding layers, and adding collision and rotation information for a ragdoll simulation.

The Simulate shelf tool sets up the below agent definition network in mocapbiped1_setup.

Agent definition network in mocapbiped1_setup

Agent

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

Agent Clip

Adds one or more animation clips to the agent definition.

AGENT_DEFINITION

A reference used by the crowd simulation network to grab the agents (using a POP Source node).

Agent Definition Cache

Writes out the agent definition to disk, and in subsequent cooks, reads the definition from the cached files instead of the input. 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 the transforms to use for the different limbs. If you are going to do terrain adaptation (adjust the agent’s animation so that its feet plant properly on the terrain geometry), look ats (edit the agent’s neck joint to point its head at something), or other features that require Houdini to know the joints that represent each body part, the crowd solver uses the information from the Agent Prep SOP to perform foot placement and other procedural changes.

This node comes after the Agent Definition Cache, because the Agent Prep SOP is always fast to compute, and so it doesn’t need to be cached.

Agent Collision Layer

Used for ragdoll simulations. Defines simple geometry around the agent’s skeleton that are used to determine the surfaces to collide against when the agent becomes a ragdoll.

Agent Configure Joints

Used for ragdoll simulations. Specifies the range of motion for each agent joint.

OUT

Marker for the end of the “cache-able” section of the agent definition. A convenient node that can be referenced for importing the final agent definition into other networks.

Adding animation clips to an agent

A clip is a bit of animation on a character (for example, standing, walking, or running). 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, if you have an agent, character1, that has animations for walking and running, you would set up an instance of character1 performing the walk animation (character1_walk), and another instance performing the run animation (character1_run).

The Simulate shelf tool creates Mocap Biped characters with rest, stand, and walk animations.

Animation clips created by the Simulate shelf tool

Add an animation clip to an agent using the shelf tool

  1. Display the agent you would like to add the animation clip to by turning on the display flag of the geometry object containing the agent definition network.

    In the Simulate shelf tool example, the agent definition network is in mocapbiped1_setup.

    Display the geometry object (agent)
  2. On the Crowds shelf tab, click Add Clip.

  3. In the viewport, select the agent displayed. This is the geometry object containing the agent definition network.

  4. 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.

The new animation clip will be added to the Agent Clip SOP in the agent definition network.

Note

In previous versions of Houdini’s crowd system where agent information was always baked to disk, you would 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 crowd system is much more convenient and no longer requires baking files to disk; the crowd 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.

Crowd source

To create a crowd, you need a crowd source network that creates a crowd of agents. The crowd source network is a geometry (SOP) network that scatters points over a given area, and attaches agents onto the points.

The Simulate shelf tool sets up the below crowd source network in crowdsource.

Crowd source network

Object Merge

“Imports” the agent from an agent definition network.

Crowd Source

Copies agents 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.

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, the Crowd Source node will create agents at those points.

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

  • If you wire in surface geometry, the Crowd Source node will use the dimensions of the surface as the area onto which to randomly scatter a number of agents. 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, the Crowd Source node will use its parameters to decide the area and the number of agents to randomly scatter.

Agent Constraint Network

Used for ragdoll simulations. Sets up the constraint networks between agent parts.

merge_crowdsources

Merges the separate Object Merge → Crowd Source → Agent Constraint Network branches for each class of agents in the crowd simulation.

OUT

A convenient node that can be referenced for importing the agents into the crowd simulation network. Wire any nodes that you want to apply to all agents between merge_crowdsources and this null node.

crowd_sim_import

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

To...Do this

Create a crowd source network using the shelf tool

  1. Display the agent by turning on the display flag of the geometry object containing the agent definition network.

  2. On the Crowds shelf tab, click Populate.

  3. In the viewport, select the agent and press Enter.

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

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

Tip

You can edit the resulting network and use various SOPs to set up the points before copying agents onto them. For example, instead of scattering the points, you could use SOPs to set up the points in ordered rows.

Crowd simulation

The crowd source SOP network creates a crowd of agents. To make the crowd move and execute behaviors, you need a crowd simulation DOP network.

The Simulate shelf tool creates the below crowd simulation network in crowd_sim.

Crowd simulation DOP network

Some components of a crowd simulation network are highlighted below.

Components of a crowd simulation network

States and behaviors

Each branch leading into the merge_states node starts with a Crowd State node that specifies the state name. The state name should match the name of an animation clip that agents will play while in that state.

The state node is followed by behavior nodes that affect the agent’s motion, as well as other nodes that affect the agent’s skeletal animation. When these nodes are wired between the state node and the merge_states node, their effects are applied to agents in that state. When wired after the merge_states node, the effects of the nodes are applied to agents in all states. This is useful for behaviors like avoiding obstacles.

The effects of multiple behaviors are normalized, and the weighted average of the behaviors are applied to the agents by the crowd solver.

Triggers and transitions

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

Trigger nodes are followed by Crowd Transition nodes, which switch the agents from one state to another when the trigger condition is met. You can wire multiple Crowd Transition nodes between a Crowd Trigger node and merge_transitions if you want a trigger to cause multiple state changes.

Crowd source

This is a POP Source DOP that references the agents created in the crowd source network. It contains the particles that represent the agents.

Crowd solver

Implements the crowd system. The crowd solver has controls for default behaviors that can apply to all agents or a subgroup of agents, such as agent collision avoidance and terrain following.

Crowd object

Data is attached to this object for the crowd system to process. You usually don’t need to modify this node.

Tip

Houdini automatically color codes certain nodes to make it easier to keep them organized in the network editor (Crowd State pink, Crowd Trigger orange, Crowd Transition blue). You can change a node’s color after it is created.

Shelf tools

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

Agent

Creates an agent definition network based on a character.

Add Clip

Adds an animation clip to an agent definition by referencing an instance of the character performing the animation.

Collision Layer

Sets up simple collision geometry around an agent character’s skeleton. For use in ragdoll simulations.

Configure Joints

Sets up joint rotation limits on an agent character. For use in ragdoll simulations.

Populate

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

Paint density

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

Simulate

Sets up geometry (SOP) and simulation (DOP) networks with sample animated agents and behaviors. This is useful for quickly setting up the various crowd networks. You can then modify them to suit your needs.

Terrain Foot Planting

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

Obstacle

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

Path

Creates a POP Steer Path node to make all the agents follow the selected path. If you want only agents in a certain state to follow the path, rewire the POP Steer Path node.

Look At

Have agents keep their head turned toward the selected object.

Target Position

Have agents chase the selected object.

Agent Cam

Creates and attaches 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 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.

SOP crowds

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.