particle_system

The particle_system object represents a particle system. By default, the particle system object serves as a preview and cannot be used any further. The particle_system declaration can however be combined with the keyword animation, making the render available as a texture in the remainder of the script, but forcing it to have a fixed resolution, specified by the dimensions modifier.

Its syntax can be one of:

particle_system <name> : <modifier1, modifier2, ...>;
particle_system animation <name> : <modifier1, modifier2, ...>;

The available modifiers are listed below.

Modifiers

You can specify a subset of the following modifiers. Only particle data specification, vertex and update functions, and particle count are mandatory.

  • count(<N>) – specifies how many particles to process and draw
  • particle_data(<type>) – specifies the data type that will be used to store the data of each individual particle. The type must consist of single-precision floating point elements only.
  • initialize(<function>) – specifies the function that computes the initial particle data. Its first parameter is the output particle data, and the second is an integer index of the particle. If no initialize function is specified, the particle data will be zero initialized.
    void initializeFunction(out ParticleDataType particleData, int particleIndex);
  • update(<function>) – specifies the function that updates the particle data in every frame. Its first argument is the input/output particle data parameter, and the second argument is the time elapsed between this frame and the previous frame.
    void updateFunction(inout ParticleDataType particleData, float deltaTime);
  • vertex(<function>, <primitive type>, <vertex count / list / generator>) – specifies the particles' vertex shader and source of vertex data. function is a GLSL function that receives the particle data and either the index of the current vertex as int, or a single vertex from the supplied vertex list or generated by a vertex generator, and returns that vertex's gl_Position (vec4) – meaning that any coordinate transformations must be applied in this function. The function may optionally output varying data for the subsequent shader stage through its first output argument. Otherwise, it may be absent. The possible primitive types are points, lines, line_strip, line_loop, triangles, triangle_strip, and triangle_fan.
    vec4 vertexFunction(out VaryingType outputData, in ParticleDataType particleData, int vertexIndex);
    vec4 vertexFunction(out VaryingType outputData, in ParticleDataType particleData, in VertexListType vertexData);
  • fragment(<function>) – specifies the function that computes the fragment color and returns it as vec4. If the preceding shader stage outputs varying data, the function should accept it as its argument. If no fragment function is specified, all particles will be rendered solid white.
    vec4 fragmentFunction(in VaryingType fragmentData);
    vec4 fragmentFunction(); // if no data output by preceding shader stage
  • geometry( ... ) – see geometry and tessellation shaders
  • tessellation( ... ) – see geometry and tessellation shaders
  • update_rate(<updates per second>) – sets how often the particles are updated. If unset, they will be updated every frame, which are synchronized with the monitor's refresh rate.
  • dimensions(<width, height>) – specifies the initial / fixed dimensions of the viewport
  • background(<color>) – specifies the background color, which is used to fill the viewport before drawing the particles. Black with zero alpha is the default
  • blend(<mode>) – specifies the blending mode to be used. The possible values are:
    • none
    • transparency
    • transparency_premultiplied
    • additive
    • multiplicative
    • min
    • max
  • depth(<true / false>) – enables or disables the depth buffer (disabled by default)
  • cull(<true / false>) – enables or disables backface culling (disabled by default)
  • wireframe(<true / false>) – enables or disables wireframe mode (disabled by default)
  • multisample(<factor>) – enables (>0) or disables (0) multisample anti-aliasing. The value of the argument is the maximum number of samples per pixel
  • srgb(<true / false>) – see animation srgb modifier

Animation modifiers

The following modifiers are only available with the animation keyword.