particle_system

The particle_system section represents a particle system. By default, the particle system object serves as a preview and cannot be used any further. The particle_system section 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 data of each individual particle. The type can only be float, vec2, vec3, vec4, or a simple structure consisting of these types.
  • fragment_data(<type>) – specifies the data type that will be used to transfer data between the vertex and fragment shader. The type can only be float, vec2, vec3, vec4, or a simple structure consisting of these types. The value passed to the fragment function will be interpolated based on proximity to each vertex like OpenGL varyings.
  • 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 / vertex list>) – specifies the particles' vertex shader. 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. If fragment_data has been specified (as non-void), the function's first argument must be an output parameter of fragment data type. The possible primitive types are points, lines, line_strip, line_loop, triangles, triangle_strip, and triangle_fan.
    vec4 vertexFunction(out FragmentDataType fragmentData, in ParticleDataType particleData, int vertexIndex);
    vec4 vertexFunction(out FragmentDataType fragmentData, in ParticleDataType particleData, in VertexListType vertexData);
  • fragment(<function>) – specifies the function that computes the fragment color and returns it as vec4. If fragment_data has been specified (as non-void), the function has one parameter – the fragment data. Otherwise it has no parameters. If no fragment function is specified, all particles will be rendered solid white.
    vec4 fragmentFunction(in FragmentDataType fragmentData);
    vec4 fragmentFunction(); // if no fragment data type set
  • geometry(<function>, <emitted primitive type>, <maximum emitted vertices>) – specifies the optional geometry shader that consumes vertices from the vertex shader, and may emit a different set of actual vertices. function is the body of the geometry shader that receives the data of a single point, line, or triangle as input array arguments:
    vec4 geometryFunction(in vec4[N] vertexPosition, in FragmentData[N] fragmentData);
    vec4 geometryFunction(in vec4[N] vertexPosition); // if no fragment data type set
    N is exactly the number of vertices of an input primitive (1 for points, 2 for lines, line_strip, line_loop, etc.). Within this function, two special calls are permitted:
    shadron_EmitVertex(emittedVertexPosition, fragmentData);
    shadron_EmitVertex(emittedVertexPosition); // if no fragment data type set
    shadron_EndPrimitive();
    shadron_EmitVertex emits an output vertex, and shadron_EndPrimitive separates individual primitives. Vertices must be emitted using these functions, or the output will be empty. shadron_EmitVertex may be called at most maximum emitted vertices times. emitted primitive type must be points, line_strip, or triangle_strip.
  • 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 model. 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.