Granular simulations include scenarios where grains of solid material can flow. In addition to sand and snow, the granular framework is also used for gel and rubber.
Instead of building an MPM simulation graph from scratch, check out the sample graphs available in the Bifrost Browser. If one of them is similar to the effect you want to achieve, you can import it and then adapt it to your needs or simply study how it works.
For sand and snow, another alternative is to add a basic_mpm_sand_graph
or basic_mpm_snow_graph
node and then explode it to get a graph with a few basic connections and setting already made.
To set up a granular simulation:
Prepare the meshes to use as emitters for the granular materials, as well as the meshes to use as objects to collide with (including receptacles to hold the materials if required). These meshes can be input from the scene or created in the graph. For best results:
Add one of the following nodes to the graph, set its parameters, and connect the output of an emitter mesh into its geometry
input.
source_mpm_sand
source_mpm_snow
source_mpm_gel
source_mpm_rubber
Note that by default, the source node is set to create a one-time emission on frame 1, which is appropriate for something like a snow bank or sandy beach. If you want a continuous emission instead, turn off use_end_frame
on the source node.
Repeat the previous step for additional emitters. You can combine different materials in the same simulation.
Connect the outputs from the source nodes into the sources
port of a simulate_mpm
node.
Connect the ouput of an mpm_solver_settings
node into the settings
port of the simulate_mpm
node, and set its properties.
Connect the meshes that you want to use as obstacles into collider
nodes. As with sources, you can have multiple geometries connected to a single collider
node, and multiple colliders
nodes connected to the simulate_mpm
node. For example to make footprints, you need a collider for the ground that prevents the snow or sand from falling away, as well as colliders for the people walking.
Connect the outputs of the collider
nodes into the colliders
input of the simulate_mpm
node.
Optionally, connect influence nodes, such as wind_influence
, turbulence_influence
, or ground_plane_influence
into the influences
input of the simulate_mpm
node.
At this point, you can preview the flow of particles by toggling the P (proxy) or D (diagnostic) flag on the simulate_mpm
node and playing through from the first frame. Adjust the simulation parameters as desired.
If you experience problems with collisions (such as particles leaking through colliders, or offset collisions), try setting the method
on the collider
node to Volume
. This is more accurate but takes longer to compute. You can also try turning on lag_colliders
on the mpm_solver_settings
node.
For the final rendering, it's best to cache the particles to files on disk. Rendering typically takes longer than the simulation and can be easily resumed (unlike the simulation). There are many ways to cache, but here are some suggestions:
granular_particles
output of simulate_mpm
is an array (one points object for each material type), first connect it into split_points_by_material
. Connect each of the outputs that you want (such as sand_particles
) into an erase_component_properties
node, and then connect that into an output
node at the top level of the graph or a terminal
node. Add a watchpoint on those final connections to see the list of properties, and enter any properties that you don't want to cache into the properties
parameter of erase_component_properties
. erase_component_properties
(or the granular_particles
output of simulate_mpm
if you are not using erase_component_properties
) to a file_cache
node, and connect its output to an output
node at the top level of the graph or a terminal
node. Enter a file name and location, set the file_cache
node's mode
to Write Mode
, and play through the full simulation from the start frame. When you are finished, don't forget to set the file_cache
node's mode
to Read Mode
.In some situations, especially for gel or rubber simulations, you may want to mesh the output.
points_to_volume
followed by volume_to_mesh
. set_geo_property
to adjust point_size
before points_to_volume
.smooth_voxel_property
to adjust volume properties afterwards — the details depend on what you are trying to simulate and how you want it to look.Here are some tips for emulating different sand and snow conditions with the parameters on the source node:
cohesion
controls how strongly the grains stick together, so use higher values for wetter sand or snow.friction
.initial_firmness
controls how packed it is. Use low values for light, fluffy snow.The yield_stress
property on the source_mpm_gel
node controls the overall behavior — the larger the value, the more the gel will clump together and resist yielding under shear force.