Houdini 16.5 Nodes Dynamics nodes

POP Grains dynamics node

A POP node that applies sand grain interaction to particles.

On this page

The POP Grains node treats the particles as small spheres and applies interaction between them. This allows for interpenetration prevention, cohesion, and even explicit constraints to be enforced.

Unlike POP Interact, which uses forces to prevent particles from penetrating, the POP Grains uses a Position Based Dynamics approach to directly move the particles apart. This approach allows for a more stable enforcement of the constraints without the sort of explosions that very high forces would induce.

This operator directly modifies the P attribute to move the points and the v attribute to reflect how they moved.

Particles under control of POP Grains have the ispbd attribute set to 1. This causes them to not perform normal movement update in the POP Solver, as the actual motion update is done in this node.

Note

If insufficient substeps or constraint iterations are performed, the solver reacts by under-enforcing constraints. This results in bouncy or collapsing behavior, as if the corresponding stiffness values were much lower. Thus, if stiffness is higher than supported, increasing substeps or constraint iterations will change the look and make the simulation stiffer.

An approximate maximum stiffness value is substeps times constraint iterations. To increase stiffness beyond this, more substeps or constraint iterations are required.

Note

Weights are in the 0 to 1 range. For the system to be guaranteed stable, the sum of all active weights should be 1. However, in practice, merely keeping each individual weight below one is effective and provides better behavior with fewer substeps.

Weights over 1 can be used to accelerate convergence, but are likely to cause particles to explode or jitter.

Controlling individual particle behavior through the weight attributes is faster than through the stiffness attributes, but is not scaled by timesteps nor iterations, so should usually only be done in an all-or-nothing manner. If not, behavior will change significantly with changing substeps or iterations.

Note

Friction is proportional to particle overlap. Thus smaller particles, with inherently smaller overlap, will have less friction effects.

This also means if the particle-particle constraint isn’t stiff, i.e. overlap is not resolved swiftly, friction will be considerably stronger.

Increasing constraint iterations can also increase the effective friction.

Note

If particles are highly stacked, it can take many iterations to resolve the pile. Too few iterations will result in the pile "bouncing". This also prevents the friction from triggering a stable stack. "Stacking height" in this case refers to how many particles are on top of each other, not the actual physical size of the stack.

Parameters

Activation

Turns this node on and off. The node is only active if this value is greater than 0. This is useful to control the effect of this node with an expression.

Note

This is activation of the node as a whole. You can’t use this parameter to deactivate the node for certain particles.

Group

Only affect a group of points (created with, for example, a Group POP or Collision Detection POP) out of all the points in the current stream.

Particle Separation

For the purpose of scaling parameters, this is taken to be the average diameter of all particles. Normally it can be linked to the particle creation code to provide a central control for scene scale.

The actual pscale attribute on particles trumps this value, this is mostly used as a hint for normalizing things like mass-shock scale.

Constraint Iterations

How many times to attempt to enforce the constraints in a single substep. Since all particles are enforced simultaneously, this must be around the diameter of the system - ie, the expected stacking height of the particles.

In each iteration, particles only inspect their immediate neighbors. Thus, if you have a pile ten particles high, the top particle will only learn about the ground plane after ten iterations, making ten the minimum usable constraint iteration value. In practice doubling this is often required.

Behavior

Assume Uniform Radius

The pscale attribute is used to determine the radius of each particle. If all particles have the same radius, faster acceleration structures can be used to find neighbors.

Friction

With Colliders

Particle-collider friction is scaled by this amount. A value of 0 will result in the particles not sticking, and a value of 1 will result in the particles trying to match velocity if contacting.

Scale with the friction point attribute.

Note

This does not respect the friction parameter or friction attributes on the collision object.

With Particles

Particle-particle friction is scaled by this amount. A value of 0 will result in the particles not sticking, and a value of 1 will result in the particles trying to match velocity if contacting.

Scale with the friction point attribute.

Accurate Friction

If set, friction is applied every iteration of the constraint loop. This makes for a stronger and more accurate friction that is better able to stack grains.

Static Threshold

The speed-vs-collision depth ratio at which particles will try to come fully to rest within a constraint iteration.

Multiply the depth a particle has sunk into a neighboring particle by the speed the particle is going. If the result is less than this threshold, the particle is brought to rest (relative to the other particle)

Scale Kinetic

When outside of the static threshold, the relative velocity is canceled proportional to this and the collision depth. Higher numbers will cause particles to swiftly lose tangential relative motion if overlapping.

Internal Collisions

Weight

A weighting for how much the particle collision forces are weighted. A value of zero will disable particle collision.

Scale with the repulsionweight point attribute.

OpenCL does not support the repulsionweight attribute.

Stiffness

How strongly particles are kept apart. Higher values result in less bouncy repulsion.

Scale with the repulsionstiffness point attribute.

OpenCL does not support the repulsionstiffness attribute.

Enable Mass-Shock Scaling

Artificially scales the mass of particles according to their position with respect to gravity. By making particles higher up lighter, stacks of particles will converge faster and be more stable.

The Global method will add a shockmass attribute which stores the virtual mass of all particles prior to iterating. It requires a properly set origin to avoid overflow.

The Local method will compute a relative mass scale on a just-in-time basis. The extra computation time is often made up for by not having to read the attribute values. Because of the approximation of the exponential used, the effective shock scaling power is clamped to approximately seven.

Shock Scaling Power

The amount of scaling to perform. Higher numbers increase the contrast between successive particles. A value of 0 will cause no ratio between particles, a value of 1 a 15% ratio between two particles stacked vertically.

Too high a number makes higher particles extremely light and destabilizes the system.

Shock Axis

The up-vector used to define a gradient of particle masses.

Should be in the direction of stacking, so usually is opposite to that of gravity.

Shock Origin

The rough center of the sand system. Due to limits of floating point representation, particles too far from this origin will be clamped to min/maximum mass values. A lower scaling power allows for a larger range.

The default values give a range of +/-580 particle separations in the shock axis direction.

Clumping

Weight

A weighting for how much the particles will naturally stick together when close. A value of zero will disable particle clumping.

Scale with the attractionweight point attribute.

Stiffness

How strongly nearby particles stick to each other. Higher values result in a less bouncy adhesion.

Scale with the attractionstiffness point attribute.

OpenCL does not support the attractionstiffness attribute.

Explicit Constraints

Weight

If particles are connected by polylines (polygons of two points) they will be forced to maintain the distance specified by the restlength attribute on the primitive.

This controls the weighting given to that constraint, a value of zero will disable the constraint. Setting this to zero will speed up the simulation as it will not have to copy connectivity information into an attribute every substep.

Scale, on a per-particle basis (not per constraint!) with the constraintweight point attribute.

OpenCL does not support the constraintweight attribute.

Stiffness

If particles are connected by polylines (polygons of two points) they will be forced to maintain the distance specified by the restlength attribute on the primitive.

This controls the stiffness given to that constraint, higher values will be less bouncy.

Scale, on a per-particle basis (not per constraint!) with the constraintstiffness point attribute.

OpenCL does not support the constraintstiffness attribute.

Collide Mutually Constrained Particles

If two particles have an explicit constraint between them, this option will allow them to collide. This is useful if working with breaking constraints as it can ensure there isn’t a sudden force when the constraint breaks. It requires that the initial particles be separated, however, so does not work if packing density is greater than one.

Enable Rigid Shape Matching

Connected groups of particles will be identified and constrained to a rigid transform. This greatly improves the stiffness of rigid components, but involves expensive SOP operations.

OpenCL does not suppport shape matching.

Instantaneous Strain

The strain primitive attribute is computed fresh every iteration and not allowed to accumulate.

Strain Decay

The rate at which the strain attribute on the primitives of the constraints decays over time.

Break Constraints

If the strain exceeds the strength of the constraint times the Break Threshold, the constraint is removed from the simulation. This allows dynamic tearing of the constraints. The strength primitive attribute on the constraints is used.

Break Threshold

A scale factor for the amount of strain to break the constraints, which can be applied globally. In instantaneous mode, it is approximately the ratio of deformation allowed: 0.05 means a 5% deformation from rest length will trigger a break.

Decreasing particle sizes will decrease bond lengths, and thereby affect the rate of breaking.

Remove Strands

When simulating a solid with explicit constraints, it can often unravel into chains of particles. These stop having strong force as they no longer have a rigid connection. This option will destroy any constraint that is a simple chain constraint.

Targets (Pins)

Weight

Particles are constrained to their targetP location. The weight is controlled by this times the targetweight attribute, allowing per particle variation.

Note

targetP is not in the original SOPs space when sourcing an object with a transform.

Scale with the targetweight point attribute.

Stiffness

The stiffness with which particles are fixed to their targetP attribute.

Note

targetP is not in the original SOPs space when sourcing an object with a transform.

Scale with the targetstiffness point attribute.

Note

If no targetstiffness point attribute is present, it is treated as zero, ie, no pins will be performed.

Solver

Max Neighbors

The maximum number of particles that will be considered when searching for potential collisions over the substep. Capping this is useful to avoid excessive computations, if too many particles are created at one spot.

Neighbor Query Scale

Potential intersection particles are any within this scaled distance of the average of the two particles pscale attribute. This is an overestimate because usually collisions are not updated during the constraint iterations, so it needs to record not just the currently colliding particles, but those that may start to collide due to the earlier iterations.

This also effects the range of the attraction force in clumping.

Max Speed

A speed limit on the resulting velocity. If a particle had to perform a very large motion to follow the constraint, it gains the velocity that corresponds to that motion. This can result in explosions if too much energy is imparted, so this can be used to limit the velocity seen next frame. However, it does not actually control how far the particle will move in a frame, just the reported v attribute.

OpenCL does not support maximum speed constraints.

Max Acceleration

Caps the change in v attribute that can be performed as a result of constraint enforcement. This caps the amount of energy that can be put into the system by constraints.

Drift Threshold

If a particle is moving slower than this speed, it is reverted to its previous position. This avoids slow settling of stacks that might be visually unappealing without actually deactivating the particles. This is measured as a velocity, so as substeps increase force effects may fall within this threshold. Particles will then stop responding to forces.

Velocity Blend

After constraint validation, velocity is defined to be the difference between the new and old points. Instead, velocity blend can be used to blend this with the old velocity, again minimizing the rate of change and smoothing out the velocity history of the particle.

Over Relaxation

Constraint averaging can slow down convergence. By boosting this above one, the collision constraint is increased. Too high, however, and it can become unstable.

Use OpenCL

Run the constraint iteration on the configured OpenCL device.

Note

The OpenCL code path only supports a subset of features, but in exchange for a faster constraint iteration process.

Note

The OpenCL code path operates on all PBD particles, not just the ones in this stream. (This is only an issue if you have more than one POP Grains node in your network)

Update Collisions During Iterations

A single collision per particle is determined, which gives a plane of collision. During the constraint iteration this is used, even though the particle may run into another collision face during the iteration. This option will recollide the particles for every iteration, at significant cost.

Update Neighbors During Iterations

Normally the potential colliders of a particle is computed once and reused for the iterations. This will recompute it each iteration, at considerable cost.

Final Collision Test

Because the constraint enforcement is only partial, particles may still be passing through objects after the constraint loop. This performs a final collision pass to prevent any particles from leaking through objects, and is essential for thin surfaces or moving objects.

Add Impact Data

Enables the addition of Impact data onto the particles. Normally these are not added to save memory, and particle collision attributes are more easily created by enabling the Add Hit Attributes parameter on the POP Solver DOP.

Enable Collision Feedback

Enables the addition of Feedback impacts onto colliding objects, which are required for two-way interaction.

Disable Constraint Averaging

When multiple particles collide at the same time, by default the constraints to seperate them are averaged out. This is effective in ensuring stability, but does not preserver momentum. Thus, when combined with internal forces, such as clumping, bunches of particles may accelerate under their own force. Disabling this averaging will avoid these ghost forces, but require that the Friction With Particles, Internal Weight, and Clumping Weight all be reduced to at least 0.5, and possibly farther for stability.

Inputs

First Input

This optional input has two purposes.

First, if it is wired to other POP nodes, they will be executed prior to this node executing. The chain of nodes will be processed in a top-down manner.

Second, if the input chain has a stream generator (such as POP Location, POP Source, or POP Stream), this node will only operate on the particles in that stream.

Outputs

First Output

The output of this node should be wired into a solver chain.

Merge nodes can be used to combine multiple solver chains.

The final wiring should go into one of the purple inputs of a full-solver, such as POP Solver or FLIP Solver.

Locals

channelname

This DOP node defines a local variable for each channel and parameter on the Data Options page, with the same name as the channel. So for example, the node may have channels for Position (positionx, positiony, positionz) and a parameter for an object name (objectname).

Then there will also be local variables with the names positionx, positiony, positionz, and objectname. These variables will evaluate to the previous value for that parameter.

This previous value is always stored as part of the data attached to the object being processed. This is essentially a shortcut for a dopfield expression like:

dopfield($DOPNET, $OBJID, dataName, "Options", 0, channelname)

If the data does not already exist, then a value of zero or an empty string will be returned.

DATACT

This value is the simulation time (see variable ST) at which the current data was created. This value may not be the same as the current simulation time if this node is modifying existing data, rather than creating new data.

DATACF

This value is the simulation frame (see variable SF) at which the current data was created. This value may not be the same as the current simulation frame if this node is modifying existing data, rather than creating new data.

RELNAME

This value will be set only when data is being attached to a relationship (such as when Constraint Anchor DOP is connected to the second, third, of fourth inputs of a Constraint DOP).

In this case, this value is set to the name of the relationship the data to which the data is being attached.

RELOBJIDS

This value will be set only when data is being attached to a relationship (such as when Constraint Anchor DOP is connected to the second, third, of fourth inputs of a Constraint DOP).

In this case, this value is set to a string that is a space separated list of the object identifiers for all the Affected Objects of the relationship to which the data is being attached.

RELOBJNAMES

This value will be set only when data is being attached to a relationship (such as when Constraint Anchor DOP is connected to the second, third, of fourth inputs of a Constraint DOP).

In this case, this value is set to a string that is a space separated list of the names of all the Affected Objects of the relationship to which the data is being attached.

RELAFFOBJIDS

This value will be set only when data is being attached to a relationship (such as when Constraint Anchor DOP is connected to the second, third, of fourth inputs of a Constraint DOP).

In this case, this value is set to a string that is a space separated list of the object identifiers for all the Affector Objects of the relationship to which the data is being attached.

RELAFFOBJNAMES

This value will be set only when data is being attached to a relationship (such as when Constraint Anchor DOP is connected to the second, third, of fourth inputs of a Constraint DOP).

In this case, this value is set to a string that is a space separated list of the names of all the Affector Objects of the relationship to which the data is being attached.

ST

This value is the simulation time for which the node is being evaluated.

This value may not be equal to the current Houdini time represented by the variable T, depending on the settings of the DOP Network Offset Time and Time Scale parameters.

This value is guaranteed to have a value of zero at the start of a simulation, so when testing for the first timestep of a simulation, it is best to use a test like $ST == 0 rather than $T == 0 or $FF == 1.

SF

This value is the simulation frame (or more accurately, the simulation time step number) for which the node is being evaluated.

This value may not be equal to the current Houdini frame number represented by the variable F, depending on the settings of the DOP Network parameters. Instead, this value is equal to the simulation time (ST) divided by the simulation timestep size (TIMESTEP).

TIMESTEP

This value is the size of a simulation timestep. This value is useful to scale values that are expressed in units per second, but are applied on each timestep.

SFPS

This value is the inverse of the TIMESTEP value. It is the number of timesteps per second of simulation time.

SNOBJ

This is the number of objects in the simulation. For nodes that create objects such as the Empty Object node, this value will increase for each object that is evaluated.

A good way to guarantee unique object names is to use an expression like object_$SNOBJ.

NOBJ

This value is the number of objects that will be evaluated by the current node during this timestep. This value will often be different from SNOBJ, as many nodes do not process all the objects in a simulation.

This value may return 0 if the node does not process each object sequentially (such as the Group DOP).

OBJ

This value is the index of the specific object being processed by the node. This value will always run from zero to NOBJ-1 in a given timestep. This value does not identify the current object within the simulation like OBJID or OBJNAME, just the object’s position in the current order of processing.

This value is useful for generating a random number for each object, or simply splitting the objects into two or more groups to be processed in different ways. This value will be -1 if the node does not process objects sequentially (such as the Group DOP).

OBJID

This is the unique object identifier for the object being processed. Every object is assigned an integer value that is unique among all objects in the simulation for all time. Even if an object is deleted, its identifier is never reused.

The object identifier can always be used to uniquely identify a given object. This makes this variable very useful in situations where each object needs to be treated differently. It can be used to produce a unique random number for each object, for example.

This value is also the best way to look up information on an object using the dopfield expression function. This value will be -1 if the node does not process objects sequentially (such as the Group DOP).

ALLOBJIDS

This string contains a space separated list of the unique object identifiers for every object being processed by the current node.

ALLOBJNAMES

This string contains a space separated list of the names of every object being processed by the current node.

OBJCT

This value is the simulation time (see variable ST) at which the current object was created.

Therefore, to check if an object was created on the current timestep, the expression $ST == $OBJCT should always be used. This value will be zero if the node does not process objects sequentially (such as the Group DOP).

OBJCF

This value is the simulation frame (see variable SF) at which the current object was created.

This value is equivalent to using the dopsttoframe expression on the OBJCT variable. This value will be zero if the node does not process objects sequentially (such as the Group DOP).

OBJNAME

This is a string value containing the name of the object being processed.

Object names are not guaranteed to be unique within a simulation. However, if you name your objects carefully so that they are unique, the object name can be a much easier way to identify an object than the unique object identifier, OBJID.

The object name can also be used to treat a number of similar objects (with the same name) as a virtual group. If there are 20 objects named "myobject", specifying strcmp($OBJNAME, "myobject") == 0 in the activation field of a DOP will cause that DOP to operate only on those 20 objects. This value will be the empty string if the node does not process objects sequentially (such as the Group DOP).

DOPNET

This is a string value containing the full path of the current DOP Network. This value is most useful in DOP subnet digital assets where you want to know the path to the DOP Network that contains the node.

Note

Most dynamics nodes have local variables with the same names as the node’s parameters. For example, in a Position node, you could write the expression:

$tx + 0.1

…to make the object move 0.1 units along the X axis at each timestep.

Examples

BaconDrop Example for POP Grains dynamics node

This example demonstrates dropping slices of bacon onto a torus. It shows how to extract a 2d object from a texture map and how to repeatedly add the same grain-sheet object to DOPs.

KeyframedGrains Example for POP Grains dynamics node

This example demonstrates keyframing the internal grains of a solid pighead to create an animated puppet.

TargetSand Example for POP Grains dynamics node

This example demonstrates attracting grain simulations to points on the surface of a model.

VaryingGrainSize Example for POP Grains dynamics node

This example demonstrates interacting grain simulations of very different sizes.

The following examples include this node.

BaconDrop Example for POP Grains dynamics node

This example demonstrates dropping slices of bacon onto a torus. It shows how to extract a 2d object from a texture map and how to repeatedly add the same grain-sheet object to DOPs.

KeyframedGrains Example for POP Grains dynamics node

This example demonstrates keyframing the internal grains of a solid pighead to create an animated puppet.

TargetSand Example for POP Grains dynamics node

This example demonstrates attracting grain simulations to points on the surface of a model.

VaryingGrainSize Example for POP Grains dynamics node

This example demonstrates interacting grain simulations of very different sizes.

See also

Dynamics nodes