|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.
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
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.
Make sure the bottom is flush with the ground plane.
Go back up to the object level, select the tube object, and click the Dry Sand tool on the Grains shelf.
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.
Create a flat Ground Plane for your base using the tool on the Rigid Bodies shelf.
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=0before creating the ground plane.
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.
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.
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_updatenode’s Behavior tab to
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.
Go back to
/obj/tube_object1/grainsource1and 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.
Set the following expression in the Scale Kinetic parameter:
if($T<1, 0.8, 0.1). This will evaluate to a very high
0.8during the first second, and to a more realistic value of
Change the Drift Threshold value to
0.01on the Solver tab, .
Press again. The particles should stay close to the original shape again and settle quickly.
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.
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.