Houdini 20.5 Grains

How to simulate a stable pile of sand without grid patterns

On this page

This tutorial explains how to get a pile of sand to keep it’s original shape, while avoiding regular patterns in the particle distribution. Our goal is to let the particles keep the initial shape, while allowing them to react properly to additional collisions and forces.

Note

In addition to the tips on this page, you may need to increase your Constraint Iterations on the POP Grains node when moving to higher particle counts. This is especially true with higher stacks of particles.

The sand tools on the Grains shelf set up particle sources in a regular grid pattern. This ensures a stable simulation with nice stacking and fast settling, when you have a flat ground plane.

Creating the pile of sand

  1. Create a closed cone that you will eventually fill with sand. You can do this by clicking the Tube tool on the Create shelf and pressing Enter to place it at the origin. Set the following parameters on your tube geometry to make a cone.

    • End Caps: on

    • Radius: 0.0, 0.8

    • Radius Scale:1.0

    • Center: 0, 0.25 or 0.5*ch("height"), 0

    • Height: 0.5

    Note

    Make sure the bottom is flush with the ground plane.

  2. Go back up to the object level, select the tube object, and click the Dry Sand tool on the Grains shelf.

    Note

    For best results, make sure the particles are sitting right on the ground at y=0. In this case, the shelf tools should have taken care of this for you by setting an expression in the Grid Offset parameter on the Grain Source node.

  3. Create a flat Ground Plane for your base using the tool on the Rigid Bodies shelf.

    Note

    The solver will push up the particles on the first frame, so it is important to make sure that the particles are flush with Y=0 before creating the ground plane.

  4. On the Solver tab of the POP Grains node, turn on Drift Threshold. This is critical to getting a pile like this to rest perfectly.

    Tip

    If you have the necessary hardware and drivers, you may also want to turn on Use OpenCL at this point in order to speed up the computation.

  5. Press on the playbar to run the simulation. The particles should stay very close to the original shape. If some particles are slighting off the sides, you can increase the Scale Kinetic parameter on sand_update node’s Behavior tab to 0.15 or 0.2.

Getting rid of the regular pattern

Getting rid of the regular pattern, makes it a bit harder for the particles to settle as well as before.

  1. Go back to /obj/tube_object1/grainsource1 and turn on the toggle to the left of Jitter Scale. This randomizes the particles positions, but created some overlap between particles, which would cause an initial explosion in the simulation. Which is why Relax Iterations is activated. This ensures that particles don’t overlap and stay inside the cone, at the cost of some additional cook time.

    If you run the simulation now, you will see the pile flattening a lot. It also takes a long time to stop moving. This is mostly because particles aren’t packed quite as perfectly.

    The best way to counter this is to again increase the kinetic friction scale (Scale Kinetic). We’ll need a much higher value though, which would lead to unnaturally sluggish behavior during the main part of the simulation. To get around this, we’ll use an expression to set a higher friction value while the particles settle.

  2. Set the following expression in the Scale Kinetic parameter: if($T<1, 0.8, 0.1). This will evaluate to a very high 0.8 during the first second, and to a more realistic value of 0.1 afterward.

  3. Change the Drift Threshold value to 0.01 on the Solver tab, .

  4. Press again. The particles should stay close to the original shape again and settle quickly.

Note

It’s generally best to leave the Drift Threshold as low as possible. Raising it should only be necessary with relatively steep slopes. Unfortunately, using an expression like in Scale Kinetic doesn’t tend to work quite as well here, since particles will start to drop again after the value goes down.

Tip

Grain Source's Relax Iterations can take a substantial amount of time to cook with millions of particles. An alternative is to turn it off and use a POP Drag node activated only on the first few frames (put $T<1 in the Activation parameter). This will stop particles from flying too far during the initial explosion.

Grains

Getting Started

Next Steps