Custom Particle Attributes
Arbitrary data for particles is crucial for flexible simulations. While the main properties of particles, such as position, velocity, mass, etc., are common to (almost) every particle system, more complex effects will inevitably need a way to generate and store custom attributes. Before going into detail, here are some (random) examples:
- Color: Particles receive a color at emission time based on their direction. This can then be used by a customized render node.
- States: Particles get a state value (integer number or enum). When some condition is met (collide with an object, age > X, etc.) the particles change their state. Physical behavior, rendering, etc. can be completely or partially different based on that state.
- Physical variables: In addition to the standard physical parameters (position, velocity, etc.) there can be uncommon values that influence behavior.
For instance, each particle could implement some kind of rocket system, where each rocket particle carries a certain amount of fuel (a simple float number). As long as fuel is available the rockets are accelerated in their forward direction, while at the same time depleting their fuel storage.
The dynamic buffer system will allow storage of any kind of data, it is completely agnostic toward the type of the data (except for the size of elements it needs for allocation). There are two different ways that custom data can be introduced:
- New node types work on (more or less) complex data. They can define this as a C struct type and attach it to the particle data. The data may or may not be accessible to nodes other than the original feature that introduced it. E.g. a fire simulation could add a set of internal physical values and expose a temperature value, but hide other internal values that are of no use outside this system.
- Generic properties can be added by the user at runtime. A minor disadvantage is that the types of data that can be created this way need to be defined in advance in C code and are therefore limited to primitive types, such as integers, floating point numbers, strings and simple collections (arrays and groups). See also ID properties for comparison.
TODO more details on attribute nodes