Rules
Particle system rules are used in llParticleSystem()
and llLinkParticleSystem()
to create particle emitters. Once set,
the particle system becomes a prim property and does not change on script resets.
System behavior rules
Note that the bitwise OR |
is an operator and should be used inside a function, otherwise the script
throws an error.
list behavior = [
PSYS_PART_FLAGS, (
// Comment unused masks
PSYS_PART_BOUNCE_MASK |
PSYS_PART_EMISSIVE_MASK |
PSYS_PART_FOLLOW_SRC_MASK |
PSYS_PART_FOLLOW_VELOCITY_MASK |
PSYS_PART_INTERP_COLOR_MASK |
PSYS_PART_INTERP_SCALE_MASK |
PSYS_PART_RIBBON_MASK |
PSYS_PART_TARGET_LINEAR_MASK |
PSYS_PART_TARGET_POS_MASK |
PSYS_PART_WIND_MASK
)
];
System presentation rules
float radius;
float angle_begin;
float angle_end;
key target;
// Pick only one pattern below:
// PSYS_SRC_PATTERN_DROP
// PSYS_SRC_PATTERN_EXPLODE
// PSYS_SRC_PATTERN_ANGLE_CONE
// PSYS_SRC_PATTERN_ANGLE
// PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY
integer pattern = PSYS_SRC_PATTERN_DROP;
list presentation = [
PSYS_PART_TARGET_LINEAR_MASK, pattern,
PSYS_SRC_BURST_RADIUS, radius,
PSYS_SRC_ANGLE_BEGIN, angle_begin,
PSYS_SRC_ANGLE_END, angle_end,
PSYS_SRC_TARGET_KEY, target
];
Particle appearance rules
vector color_start;
vector color_end;
float alpha_start;
float alpha_end;
vector scale_start;
vector scale_end;
string texture;
float glow_start;
float glow_end;
list appearance = [
PSYS_PART_START_COLOR, color_start,
PSYS_PART_END_COLOR, color_end,
PSYS_PART_START_ALPHA, alpha_start,
PSYS_PART_END_ALPHA, alpha_end,
PSYS_PART_START_SCALE, scale_start,
PSYS_PART_END_SCALE, scale_end,
PSYS_SRC_TEXTURE, texture,
PSYS_PART_START_GLOW, glow_start,
PSYS_PART_END_GLOW, glow_end
];
Particle blending rules
// Pick only one of the blend functions below:
// PSYS_PART_BF_ONE
// PSYS_PART_BF_ZERO
// PSYS_PART_BF_DEST_COLOR
// PSYS_PART_BF_SOURCE_COLOR
// PSYS_PART_BF_ONE_MINUS_DEST_COLOR
// PSYS_PART_BF_ONE_MINUS_SOURCE_COLOR
// PSYS_PART_BF_SOURCE_ALPHA
// PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA
integer bf_source = PSYS_PART_BF_SOURCE_ALPHA;
// Pick only one of the blend functions below:
// PSYS_PART_BF_ONE
// PSYS_PART_BF_ZERO
// PSYS_PART_BF_DEST_COLOR
// PSYS_PART_BF_SOURCE_COLOR
// PSYS_PART_BF_ONE_MINUS_DEST_COLOR
// PSYS_PART_BF_ONE_MINUS_SOURCE_COLOR
// PSYS_PART_BF_SOURCE_ALPHA
// PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA
integer bf_dest = PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA;
list blending = [
PSYS_PART_BLEND_FUNC_SOURCE, bf_source,
PSYS_PART_BLEND_FUNC_DEST, bf_dest
];
Particle flow rules
float duration_system;
float duration_particle;
float burst_sleep;
integer burst_particle_count;
list flow = [
PSYS_SRC_MAX_AGE, duration_system,
PSYS_PART_MAX_AGE, duration_particle,
PSYS_SRC_BURST_RATE, burst_sleep,
PSYS_SRC_BURST_PART_COUNT, burst_particle_count
];
Particle motion rules
vector acceleration;
vector omega;
float speed_min;
float speed_max;
list motion = [
PSYS_SRC_ACCEL, acceleration,
PSYS_SRC_OMEGA, omega,
PSYS_SRC_BURST_SPEED_MIN, speed_min,
PSYS_SRC_BURST_SPEED_MAX, speed_max
];
Template script
This particle system script includes all of the rules available for particle systems.
To create a specific particle effect, modify the script by removing unneeded rules in
createParticleSystem()
and adding values to variables.
PSYS_PART_FLAGS
PSYS_PART_FLAGS, integer mask
The mask value may be specified as a decimal or hex integer, or by performing the bitwise OR operation on one or more of the following flag constants:
PSYS_PART_BOUNCE_MASK
When set, specifies particles will bounce off a plane at the region Z height of the emitter. On "bounce", each particle reverses its Z-velocity. Particles spawned below the plane will reflect to an equivalent distance above the plane.
PSYS_PART_EMISSIVE_MASK
When set, particles are full-bright and are unaffected by global lighting. Otherwise, particles will be lit depending on the current global lighting conditions. Note that point lights do illuminate non-emissive particles.
PSYS_PART_FOLLOW_SRC_MASK
When set, particles move relative to the position of the emitter. Otherwise, particle position and movement are unaffected by the position/movement of the emitter. This flag disables the PSYS_SRC_BURST_RADIUS rule.
PSYS_PART_FOLLOW_VELOCITY_MASK
When set, particles rotate to orient their "top" towards the direction of movement or emission. Otherwise, particles are oriented vertically as their textures would appear (top of texture at top, left at left).
PSYS_PART_INTERP_COLOR_MASK
When set, particle color transitions from
PSYS_PART_START_COLOR
toPSYS_PART_END_COLOR
and alpha fromPSYS_PART_START_ALPHA
toPSYS_PART_END_ALPHA
during the particle's lifetime. The transition is a smooth interpolation.PSYS_PART_INTERP_SCALE_MASK
When set, particle size/scale transitions from its
PSYS_PART_START_SCALE
setting to itsPSYS_PART_END_SCALE
setting during the particle's lifetime.PSYS_PART_RIBBON_MASK
Joins a stream of particles together into a continuous strip. Particle textures are stretched (or squeezed) to join their right edges to their predecessor's left. Ribbon 'width' is controlled by the 'x' values of start and end scale. The 'y' values are used only for computing the maximum visibility distance of the particles, and the distance between particles controls the 'length' of each ribbon segment instead. Unlike other particle effects, ribbon segments are not rendered facing the viewer's camera. The Z axis of each new particle mimics the Z axis of the emitter prim. Ribbon segments will not render if they have no 'length' - this happens when particles move only 'up' or 'down' the local Z-axis of their emitter prim. PSYS_PART_FOLLOW_VELOCITY_MASK has no effect on ribbons. For a simple ribbon effect, try using the DROP pattern, TEXTURE_BLANK, ACCEL and/or WIND.
PSYS_PART_TARGET_LINEAR_MASK
When set, emitted particles move in a straight evenly-spaced line towards the target specified by the PSYS_SRC_TARGET_KEY rule. This option ignores all Non-DROP patterns and their dependent attributes (radius, burst speeds, angles, and omega). PSYS_SRC_ACCEL and PSYS_PART_WIND_MASK are ignored as well. Using PSYS_PART_BOUNCE_MASK while the target is 'below' the emitter will cause the linear particle stream to deflect upwards, terminating above the target.
PSYS_PART_TARGET_POS_MASK
When set, emitted particles change course during their lifetime, attempting to move towards the target specified by the PSYS_SRC_TARGET_KEY rule by the time they expire. Note that if no target is specified, the target moves out of range, or an invalid target is specified, the particles target the prim itself.
PSYS_PART_WIND_MASK
When set, particle movement is affected by the wind. It is applied as a secondary force on the particles.
PSYS_SRC_PATTERN
PSYS_SRC_PATTERN, integer pattern
Specifies the general emission pattern. Pattern can be one of the following values:
PSYS_SRC_PATTERN_EXPLODE
-
Sprays particles outwards in a spherical area. The Initial velocity of each particle is determined by PSYS_SRC_BURST_SPEED_MIN and PSYS_SRC_BURST_SPEED_MAX. The EXPLODE pattern ignores the ANGLE parameters.
PSYS_SRC_PATTERN_ANGLE_CONE
-
Sprays particles outwards in a spherical, sub-spherical, conical or ring shaped area, as defined by the ANGLE parameters PSYS_SRC_ANGLE_BEGIN and PSYS_SRC_ANGLE_END. The ANGLE_CONE pattern can be used to imitate the EXPLODE pattern by explicitly setting PSYS_SRC_ANGLE_BEGIN to 0.00000 and PSYS_SRC_ANGLE_END to 3.14159 (or PI) (or vice versa).
PSYS_SRC_PATTERN_ANGLE
-
Sprays particles outward in a flat circular, semi-circular, arc or ray shaped areas, as defined by PSYS_SRC_ANGLE_BEGIN and PSYS_SRC_ANGLE_END. The circular pattern radiates outwards around the prim's local X axis line.
PSYS_SRC_PATTERN_DROP
-
Creates particles with no initial velocity. The DROP pattern will override any values given for PSYS_SRC_BURST_RADIUS, PSYS_SRC_BURST_SPEED_MIN, and PSYS_SRC_BURST_SPEED_MAX, setting each to 0.00000. (All patterns will behave like the DROP pattern, if RADIUS, SPEED_MIN and SPEED_MAX are explicitly set to 0.0000.)
PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY
-
(incomplete implementation) acts the same as the PSYS_SRC_PATTERN_DROP pattern, it is believed that the original intention for this pattern was to invert the effect of the ANGLE parameters, making them delineate an area where particles were NOT to be sprayed. (effectively the inverse or opposite of the behavior of the ANGLE_CONE pattern).
PSYS_PART_BLEND_FUNC_SOURCE
PSYS_PART_BLEND_FUNC_SOURCE, integer bf_source
Specifies how blending function uses the incoming particle's color and alpha information to produce the rendered result. Defaults to PSYS_PART_BF_SOURCE_ALPHA. Blending function can be one of the following values:
PSYS_PART_BF_ONE
-
Do not scale the source or destination RGBA values.
PSYS_PART_BF_ZERO
-
Zero out the source or destination RGBA values.
PSYS_PART_BF_DEST_COLOR
-
Scale the RGBA values by the RGBA values of the destination.
PSYS_PART_BF_SOURCE_COLOR
-
Scale the RGBA values by the RGBA values of the particle source.
PSYS_PART_BF_ONE_MINUS_DEST_COLOR
-
Scale the RGBA values by the inverted RGBA values of the destination.
PSYS_PART_BF_ONE_MINUS_SOURCE_COLOR
-
Scale the RGBA values by the inverted RGBA values of the particle source.
PSYS_PART_BF_SOURCE_ALPHA
-
Scale the RGBA values by the alpha values of the particle source.
PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA
-
Scale the RGBA values by the inverted alpha values of the particle source.
PSYS_PART_BLEND_FUNC_DEST
PSYS_PART_BLEND_FUNC_DEST, integer bf_dest
Specifies how blending function uses the current framebuffer's color and alpha information to produce the rendered result. Defaults to PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA. To make particles blend with the background in a less opaque and more luminescent way use PSYS_PART_BF_ONE for dest and the default for source. The available blending functions are the same as those used for PSYS_PART_BLEND_FUNC_SOURCE.
PSYS_SRC_BURST_RADIUS
PSYS_SRC_BURST_RADIUS, float radius
Specifies the distance from the emitter where particles will be created. This rule is ignored when the PSYS_PART_FOLLOW_SRC_MASK flag is set.
PSYS_SRC_ANGLE_BEGIN
PSYS_SRC_ANGLE_BEGIN, float angle_begin
Specifies a half angle, in radians, of a circular or spherical "dimple" or conic section (starting from the emitter facing) within which particles will NOT be emitted. Valid values are the same as for PSYS_SRC_ANGLE_END, though the effects are reversed accordingly. If the pattern is PSYS_SRC_PATTERN_ANGLE, the presentation is a 2D flat circular section. If PSYS_SRC_PATTERN_ANGLE_CONE or PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY is used, the presentation is a 3D spherical section. Note that the value of this parameter and PSYS_SRC_ANGLE_END are internally re-ordered such that this parameter gets the smaller of the two values.
PSYS_SRC_ANGLE_END
PSYS_SRC_ANGLE_END, float angle_end
Specifies a half angle, in radians, of a circular or spherical "dimple" or conic section (starting from the emitter facing) within which particles WILL be emitted. Valid values are 0.0, which will result in particles being emitted in a straight line in the direction of the emitter facing, to PI, which will result in particles being emitted in a full circular or spherical arc around the emitter, not including the "dimple" or conic section defined by PSYS_SRC_ANGLE_BEGIN. If the pattern is PSYS_SRC_PATTERN_ANGLE, the presentation is a 2D flat circular section. If PSYS_SRC_PATTERN_ANGLE_CONE or PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY is used, the presentation is a 3D spherical section. Note that the value of this parameter and PSYS_SRC_ANGLE_BEGIN are internally re-ordered such that this parameter gets the larger of the two values.
PSYS_SRC_INNERANGLE
PSYS_SRC_INNERANGLE, float angle_inner
DEPRECATED: Use PSYS_SRC_ANGLE_BEGIN instead. Works similar to its replacement rule, except the edge of the section is aligned with the emitter facing, rather than its center.
PSYS_SRC_OUTERANGLE
PSYS_SRC_OUTERANGLE, float angle_outer
DEPRECATED: Use PSYS_SRC_ANGLE_END instead. Works similar to its replacement rule, except the edge of the section is aligned with the emitter facing, rather than the section's center.
PSYS_SRC_TARGET_KEY
PSYS_SRC_TARGET_KEY, key target
Specifies the key of a target object, prim, or agent towards which the particles will change course and move (if PSYS_PART_TARGET_POS_MASK is specified) or will move in a straight line (if PSYS_PART_TARGET_LINEAR_MASK is specified). They will attempt to end up at the geometric center of the target at the end of their lifetime. Requires the PSYS_PART_TARGET_POS_MASK or PSYS_PART_TARGET_LINEAR_MASK flag be set.
PSYS_PART_START_COLOR
PSYS_PART_START_COLOR, vector color_start
A vector specifying the color of the particles upon emission.
PSYS_PART_END_COLOR
PSYS_PART_END_COLOR, vector color_end
A vector specifying the color the particles transition to during their lifetime. Only used if the PSYS_PART_INTERP_COLOR_MASK flag is set.
PSYS_PART_START_ALPHA
PSYS_PART_START_ALPHA, float alpha_start
Specifies the alpha of the particles upon emission. Valid values are in the range 0.0 to 1.0. Lower values are more transparent; higher ones are more opaque.
PSYS_PART_END_ALPHA
PSYS_PART_END_ALPHA, float alpha_end
Specifies the alpha the particles transition to during their lifetime. Only used if the PSYS_PART_INTERP_COLOR_MASK flag is set. Valid values are the same as PSYS_PART_START_ALPHA.
PSYS_PART_START_SCALE
PSYS_PART_START_SCALE, vector scale_start
Specifies the scale or size of the particles upon emission. Valid values for each direction are 0.03125 to 4.0, in meters. The actual particle size is always a multiple of 0.03125. Smaller changes don't have any effect. Since particles are essentially 2D sprites, the Z component of the vector is ignored and can be set to 0.0.
PSYS_PART_END_SCALE
PSYS_PART_END_SCALE, vector scale_end
Specifies the scale or size the particles transition to during their lifetime. Only used if the PSYS_PART_INTERP_SCALE_MASK flag is set. Valid values are the same as PSYS_PART_START_SCALE.
PSYS_SRC_TEXTURE
PSYS_SRC_TEXTURE, string texture
Specifies the name of a texture in the emitter prim's inventory to use for each particle. Alternatively, you may specify an asset key UUID for a texture. If using llLinkParticleSystem and texture is not a UUID, texture must be in the emitter prim (not necessarily with the script).
PSYS_PART_START_GLOW
PSYS_PART_START_GLOW, float glow_start
Specifies the glow of the particles upon emission. Valid values are in the range of 0.0 (no glow) to 1.0 (full glow).
PSYS_PART_END_GLOW
PSYS_PART_END_GLOW, float glow_end
Specifies the glow that the particles transition to during their lifetime. Valid values are the same as PSYS_PART_START_GLOW.
PSYS_SRC_MAX_AGE
PSYS_SRC_MAX_AGE, float duration_system
Specifies the length of time, in seconds, that the emitter will operate upon coming into view range (if the particle system is already set) or upon execution of this function (if already in view range). Upon expiration, no more particles will be emitted, except as specified above. Zero will give the particle system an infinite duration.
PSYS_PART_MAX_AGE
PSYS_PART_MAX_AGE, float duration_particle
Specifies the lifetime of each particle emitted, in seconds. Maximum is 30.0 seconds. During this time, the particle will appear, change appearance and move according to the parameters specified in the other sections, and then disappear.
PSYS_SRC_BURST_RATE
PSYS_SRC_BURST_RATE, float burst_sleep
Specifies the time interval, in seconds, between "bursts" of particles being emitted. Specifying a value of 0.0 will cause the emission of particles as fast as the viewer can do so.
PSYS_SRC_BURST_PART_COUNT
PSYS_SRC_BURST_PART_COUNT, integer burst_particle_count
Specifies the number of particles emitted in each "burst".
PSYS_SRC_ACCEL
PSYS_SRC_ACCEL, vector acceleration
Specifies a directional acceleration vector applied to each particle as it is emitted, in meters per second squared. Valid values are 0.0 to 100.0 for each direction both positive and negative, as region coordinates.
PSYS_SRC_OMEGA
PSYS_SRC_OMEGA, vector omega
Sets how far to rotate the "pattern" after each particle burst. (Burst frequency is set with PSYS_SRC_BURST_RATE.) Omega values are approximately 'radians per burst' around the prim's global (not local) X,Y,Z axes. For precise and predictable pattern rotation, rotate the prim instead of using PSYS_SRC_OMEGA. Omega has no visible effect on drop, explode and certain specific angle and angle cone patterns, depending on prim orientation. Pattern rotation can be used with prim orientation and llTargetOmega() but won't produce consistent results.
PSYS_SRC_BURST_SPEED_MIN
PSYS_SRC_BURST_SPEED_MIN, float speed_min
Specifies the minimum value of a random range of values which is selected for each particle in a burst as its initial speed upon emission, in meters per second. Note that the value of this parameter and PSYS_SRC_BURST_SPEED_MAX are internally re-ordered such that this parameter gets the smaller of the two values.
PSYS_SRC_BURST_SPEED_MAX
PSYS_SRC_BURST_SPEED_MAX, float speed_max
Specifies the maximum value of a random range of values which is selected for each particle in a burst as its initial speed upon emission, in meters per second. Note that the value of this parameter and PSYS_SRC_BURST_SPEED_MIN are internally re-ordered such that this parameter gets the larger of the two values.