Справка Houdini на русском Nodes Dynamics nodes

Gas OpenCL dynamics node

Executes the provided kernel with the given paramters

On this page

This DOP provides a general interface to creating and running OpenCL kernels using a variable number of parameters. It also provides users with a way to automatically generate kernel headers from their list of parameters.

Parameters

Kernel

Kernel Name

The name of the OpenCL kernel to execute with the loaded program.

Use Code Snippet

Use the code provided in the Kernel Code parameter rather than an external disk file. This makes for quicker editing and creation of OpenCL microsolvers.

Kernel File

The path to OpenCL program file to compile. This can include a path to an on disk file or asset.

Kernel Options

Specify any desired compile flags for the kernel.

Note

The Apple OSX OpenCL compiler requires only a single space between kernel options!

Generate Kernel

Creates a prototype for the required kernel function taking all of your current selected parameters into account. This can be used as a starting point or to update your interface when new parameters are added or removed.

Recompile Kernel

When loading kernels from disk the kernel is cached to avoid regenerating it every solve. Turning this on forces the re-loading and recompiling of the kernel. This is useful if #include files refer to code that has changed, or the kernel file is changed in an external text editor.

It should always be disabled when protoyping is complete.

Options

Run Over

The provided OpenCL kernel is invoked once. The number of global ids, however, is controlled by this setting. First Writeable attribute sets it to the size of the first bound attribute that is marked writeable. All fields sets it to the total voxels of the fields.

The Worksets method will use a specified detail attribute to specify a list of begin values and length values. The kernel will be invoked once per non-zero length. The global id will vary from 0 to the length-1 on each invocation, and the begin value can be used to find an offset inside your bound attributes.

Note

The global ids will be rounded up to ensure efficient processing on the GPU, so you should always compare the get_global_id(0) with the actual length of the bound attribute.

Force Align

Force the specified fields alignment to match the output grid. By selecting this option, each grid has its values interpolated to match the alignment of the output grid and allows the kernel to execute independent of field alignment.

Include Origin

Include the origin of the input/output grids.

Include Size

Include the size of the input/output grids.

Include Voxel Size

Include the size of the voxels.

Flush Attributes

After writing to attributes, the new values are left on the GPU until another solver requests the geometry attributes. This lets the attributes stay there and provides the most efficiency. Turning on flush attributes forces them to be copied back from the GPU into geometry memory explicitly. This should not be required.

Finish Kernels

When Finish Kernels is disabled, no attempt is to wait for the OpenCL kernels to complete before continuing the next solver. This lets them run in the background until their results are actually needed. To simplify debugging, it is useful to ensure kernels are finished to make sure errors are detected in the right spot.

Include Time

Include the current simulation time as a parameter.

Include Timestep

Include the current timestep as a parameter. This is useful as if the OpenCL node is triggered from a Gas Substep it may be less than the full timestep.

Timescale

For some operations you may wish to know the power of the timestep. Rather than recomputing in the kernel, you can set this to e^Timestep and have the exponentiation pre-computed.

Include Simplex Noise Data

Include an opaque pointer that can be passed to the simplex noise functions in <xnoise.h> to generate simplex noise and curlnoise from OpenCL kernels.

Worksets Geometry

Which DOP Geometry data to look for the workset detail attributes on.

Worksets Begin Attr.

An integer array detail attribute storing the start values for each workset.

Worksets Length Attr.

An integer array detail attribute storing the length of each workset. Worksets of zero length will not be invoked.

Note it is your responsibility to validate that the workset length and begin values provided by the detail attributes are legitimate offsets into the bound attributes. If these do not come from your control, you should validate them before dereferencing.

Bindings

OpenCL Parameters

The number of extra parameters within the OpenCL kernel.

Each parameter can either be a fixed constant value, evaluated during DOP network traversal, or read/write from a field or geometry attribute.

Parameter Name

The name of the parameter. This is used in the Generate Kernel button, but is otherwise only present as a comment. The actual binding to an OpenCL kernel is done by parameter order, not by the name.

Parameter Type

The type of parameter to create and bind.

Integer

A constant integer value, allowing you to bind channel references and expressions that are pre-computed.

Float

A constant float value. Optionally you can scale it by the timestep.

Float Vec4

A constant tuple of four floats, binding to a float4 OpenCL parameter.

Scalar Field

A floating point valued scalar field. The field name is a Scalar Field Data that will be bound. The writeable flag controls whether the pointer is marked as const in OpenCL.

Note

If the field is writeable, the next time it is needed by Houdini it will be copied back.

Vector Field

A vector valued field. The field name is a Vector Field Data that will be bound.

Matrix Field

A matrix valued field. The field name is a Matrix Field Data that will be bound.

Ramp

A scalar ramp. Because evaluating a spline-based ramp inside of an OpenCL kernel is complex, the ramp is instead sampled into a uniform

array of floats. The Ramp Size parameter controls the number of samples used.

Attribute:

Field

The name of the DOP data to bind as a field.

Present for Fields.

Geometry

The name of the DOP data to bind as geometry.

Present for Attributes.

Attribute

Which attribute to bind. It is an error if it is missing, unless the optional flag is set.

Present for Attributes.

Class

The type of the attribute. Since the first writeable attribute can determine the iteration order, this can determine the number of global ids processed by the OpenCL solver.

Not all bound attributes need to be the same type, or even come from the same geometry data.

Present for Attributes.

Type

What sort of attribute to bind. Float and integer attributes are bound as single arrays containing all element values in order. Tuples are interleaved, ie, P will be bound as xyzxyzxyz.

Array attributes are bound as two arrays. One array contains the offsets of each element’s array data. Thus, the difference of a pair of offsets provides the elements array length. The second array is the data of all elements' arrays concatenated into a single array.

Present for Attributes.

Size

Tuple size of the attribute to bind. If greater than zero, the attribute must be able to provide this tuple size. If zero, it will bind automatically and an extra parameter will be generated storing the tuplesize.

Present for Attributes.

Readable

Determines if the OpenCL kernel will read from this attribute. If not set, the attributes values will not be copied onto the GPU. This is useful for write-only attributes as it avoids an unnecessary copy, but requires care as uninitialized data will be present.

Present for Attributes.

Writeable

Determines if the OpenCL kernel will write back to this attribute or field. Causes the CPU version of the attribute or field to be marked out of date so the next time it is needed it will be copied back from the GPU.

Present for Fields and Attributes.

Optional

Marks the attribute as not necessary. If the attribute isn’t present in the geometry, rather than erroring, a #define is set in the kernel options to disable the attribute. Note that this also changes the parameter signature, so the Generate Code button should be used to verify the syntax.

Note

The parameter name is used in the #define, so changing the parameter name requires changing the code.

Present for Attributes.

Ramp Size

Present for ramps.

Outputs

First Output

The operation of this output depends on what inputs are connected to this node. If an object stream is input to this node, the output is also an object stream containing the same objects as the input (but with the data from this node attached).

If no object stream is connected to this node, the output is a data output. This data output can be connected to an Apply Data DOP, or connected directly to a data input of another data node, to attach the data from this node to an object or another piece of data.

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.

Dynamics nodes