Note: Going back and forth between attribute nodes and the effect interface is currently pretty painful. The upcoming version 2.3 will fix most of these issues.
Each effect has an associated effect interface which describes its public properties, visible to the game engine:
The “Torch.pkfx” effect exposes some simple parameters
The effect interface can contain attributes, attribute samplers or events.
Attributes are vector values that can be accessed in nodegraphs anywhere in the effect. Those values can be set at runtime by the game engine at minimal cost, and are useful to drive dynamic particle effects behaviors, or create variations across various instances of the same effect in a level:
Attributes are retrieved like any constant nodes via the “input” node.
Attributes can be created from the effect interface panel, or declared from a nodegraph (template or particle graph). Placing an input node of type “attribute” automatically registers that attribute in the effect interface, once it has been properly named and typed.
Supported attribute types are:
- float, float2, float3, float4
- int, int2, int3, int4
- bool, bool2, bool3, bool4
Like any other property, they can have a default value, description, min/max value and semantic.
The target game engine can then retreive and expose all those informations:
Creating an attribute node in a node graph will insert that attribute in the effect interface if no matching attributes is found. If an existing attribute matches the one created (same name), they will be merged into a single reference:
The effect interface panel displays the various attribute references
Note: By default, attributes are evaluated once (see particle graph). The simulation state can be changed from Auto/Spawn to Evolve to make sure attribute values are retrieved each frame:
- Attribute values will be retrieved at particle spawn
- Attribute values will be retrieved every frame
Attribute samplers are samplers that can be accessed in node graphs or scripts anywhere in the effect. Those values can be set at runtime by the game engine at minimal cost, and are useful to drive dynamic particle effects behaviors, or create variations across various instances of the same effect in a level:
Shape attribute sampler
Supported attribute sampler types are:
- dataGeometry (shape sampler)
- dataImage (image sampler)
- dataCurve (curve sampler)
- dataAudio (audio sampler)
- dataVectorField (turbulence sampler)
- dataText (text sampler)
- dataAnimPath (animtrack sampler)
An attribute sampler must have a default value plugged in to work properly, as it is not guaranteed it will be set by the game engine.
Note: Even though the game engine can override any attribute sampler type, the editor can only currently bind shape attribute samplers to an animated mesh for preview, using the “Bind to backdrop” checkbox.
Events differ from attributes and attribute samplers as they cannot be set at runtime. They are designed to be exported to the game engine. They can be used to hook gameplay logic to effect events (see exporting events).