Difference between revisions of "LlParticleSystem"

From Second Life Wiki
Jump to navigation Jump to search
m (Was about to add a change to my subpage on the crazy video particles, updating the description of the link to it so it more accurately describes what will be on the page.)
 
(78 intermediate revisions by 31 users not shown)
Line 1: Line 1:
{{LSL_Function|func_id=229|func_sleep=0.0|func_energy=10.0
{{LSL Function/Headless
|func=llParticleSystem
|default={{{default|}}}
|p1_type=list|p1_name=rules|p1_desc=Particle system rules list in the format [ rule1, data1, rule2, data2 . . . rulen, datan ]
|p1_type=list|p1_name=rules
|func_desc=Defines a particle system for the containing prim based on a list of '''rules'''.
|p1_desc=Particle system rules list in the format [ rule1, data1, rule2, data2 . . . rule'''n''', data'''n''' ]
|p1_hover=Particle system rules list in the format [ rule1, data1, rule2, data2 . . . rulen, datan ]
|inject-2={{LSL Function/link|link|mode=Set}}
|inject-4={{Issues/SVC-1640}}{{Issues/SVC-4897}}{{Issues/SVC-185}}{{LSL Function/ParticleSystem}}
|summary=These functions are almost entirely identical.
 
The big difference is that [[#llParticleSystem|llParticleSystem]] acts upon the prim the script is in, [[#llLinkParticleSystem|llLinkParticleSystem]] on the other hand can act upon any prim in the object.
|head={{LSL Function/Head
|func_id=229|func_sleep=0.0|func_energy=10.0|func=llParticleSystem|sort=ParticleSystem
|p1_type=list|p1_subtype=instructions|p1_name=rules
|func_desc=Defines a particle system for the containing prim based on a list of {{LSLP|rules}}.
|return_text
|return_text
|spec=
}}{{LSL Function/Head
Defines a particle system that sets the state of the {{LSLG|particle emitter}} within the {{LSLG|primitive|prim}} which the {{LSLG|script}} is contained. Any other scripts in the same prim which call this function will modify the state of the same particle emitter. As such, the particle system defined by this function is a {{LSLG|primitive property|prim property}}, just like its size, shape, color, et cetera.
|func_id=355|func_sleep=0.0|func_energy=10.0|func=llLinkParticleSystem|sort=LinkParticleSystem
Each prim has only '''one (1)''' particle emitter, located at its {{LSLG|geometric center}}, and aligned along the prim's local Z-axis, pointing in the positive Z direction.
|p1_type=integer|p1_subtype=link|p1_name=link
|p2_type=list|p2_subtype=instructions|p2_name=rules
|func_desc=A particle system defined by a list of {{LSLP|rules}} is set for the prim(s) {{LSLP|link}}.
|return_text
}}
|spec=Defines a particle system that sets the state of the [[particle emitter]] within the [[primitive|prim]] that contains the [[script]]. Any other scripts, in the same prim, that call this function will modify the state of the same particle emitter. As such, the particle system defined by this function is a [[primitive property|prim property]], just like its size, shape, color, etc.
 
Each prim has only '''one (1)''' particle emitter, located at its [[geometric center]], and aligned along the prim's [[Viewer coordinate frames#Local|local]] Z-axis, pointing in the positive Z direction.


This is the only function which alters the state of the prim's particle emitter; thus, if you wish to change the emitter to a different state (i.e., emitting a different particle system entirely, or shut off the emitter completely), just call this same function with the parameters of the new particle system you wish to render instead. Specifying an empty list (i.e., llParticleSystem([]); ) turns the emitter off.
This is the one of the only {{LSLGC|Particles|functions}} which alters the state of the prim's particle emitter; thus, if you wish to change the emitter to a different state (i.e., emitting a different particle system entirely, or shut off the emitter completely), just call the function with the parameters of the new particle system you wish to render instead. Specifying an empty list (i.e., <code>llParticleSystem([])</code>; ) turns the emitter off.


Particles are essentially 2D "sprites" and are always rendered facing the viewer's camera.
Particles are essentially 2D {{Wikipedia|Sprite (computer graphics)|sprites}} and are always rendered facing the viewer's camera (except when PSYS_PART_RIBBON_MASK is enabled).


The rule / data values are defined below.
The rule / data values are defined below.
|caveats=
|caveats=
# Due to a bug/limitation in the implementation of the particle system, any alpha change defined by setting PSYS_PART_END_ALPHA and the PSYS_PART_INTERP_COLOR_MASK flag '''always''' goes from a higher alpha value to a lower one. In other words, particles can only "fade-out" and can never "fade-in". This is true even if you specify it in the list where PSYS_PART_START_ALPHA is less than PSYS_PART_END_ALPHA, as the values will be re-ordered internally when the particle system is rendered.
#When using particle systems that have a non-zero emitter age (PSYS_SRC_MAX_AGE) setting, you may notice that the particle system may restart without any scripted trigger going off. This is due to a bug which causes the emitter to "reset" when any of the prim properties are updated or otherwise sent to the viewer. As a result, you may have to use a [[timer]] or a forced [[llSleep|sleep]] and then clear the particle system once the age has expired. Debbie Trilling has posted a work-around here: https://forums-archive.secondlife.com/54/fa/260031/1.html#post1996465
# When using particle systems that have a non-zero emitter age (PSYS_SRC_MAX_AGE) setting, you may notice that the particle system may restart without any scripted trigger going off. This is due to a bug which causes the emitter to "reset" when any of the prim properties are updated or otherwise sent to the viewer. As a result, you may have to use a {{LSLG|timer}} or a forced {{LSLG|llSleep|sleep}} and then clear the particle system once the age has expired.
#The spin defined by PSYS_SRC_OMEGA is relative to the [[Viewer coordinate frames#Region|region]] coordinate system, NOT the prim's [[Viewer coordinate frames#Local|local]] coordinate system.
# The spin defined by PSYS_SRC_OMEGA is relative to the global coordinate system, NOT the prim's local coordinate system.
#New non-zero vector values for PSYS_SRC_OMEGA will not re-align the emitter with the prim before they take effect.  The viewer will continue rotating the emitter with the new omega values, starting from the last known orientation of the emitter.  The emitter's current orientation is determined by the viewer, not the simulator, and two people looking at the same effect may see different results.  To re-align the emitter with the prim, create an effect with PSYS_SRC_OMEGA set to [[ZERO_VECTOR]] long enough for the viewer to have a chance to render it. 
# Particles moving towards a humanoid avatar, specified by PSYS_SRC_TARGET_KEY rule and setting the PSYS_PART_TARGET_POS_MASK flag, will end up at the geometric center of the avatar's bounding box which, unfortunately, make them appear to be striking the person in the groin area. If you want them to end up at another point on a target avatar, you instead have to place a target prim that is moved to the position where you wish them to end up, and use the key of that prim for the value of the PSYS_SRC_TARGET_KEY rule.
#Particles moving towards a humanoid avatar, specified by PSYS_SRC_TARGET_KEY rule and setting the PSYS_PART_TARGET_POS_MASK flag, will end up at the geometric center of the avatar's bounding box which, unfortunately, make them appear to be striking the person in the groin area. If you want them to end up at another point on a target avatar, you instead have to place a target prim that is moved to the position where you wish them to end up, and use the key of that prim for the value of the PSYS_SRC_TARGET_KEY rule.
# The Second Life viewer uses optimizations in culling objects which are too small to see at certain distances. If your emitter is very small, and is culled due to distance, the particle system associated with it will not be rendered either.
#The Second Life viewer uses optimizations in culling objects which are too small to see at certain distances. If your emitter is very small, and is culled due to distance, the particle system associated with it will not be rendered either.
|examples
#Particles will also be culled beyond a maximum distance depending on their own scale. If particles are desired to be visible from further away yet be visually smaller, a larger scale and a texture with empty padding space are needed. If using PSYS_PART_RIBBON_MASK, make sure the Y scale is set properly, as it is used for this calculation even the rendering of the ribbon particles themselves ignores it.
#When PSYS_PART_FOLLOW_VELOCITY_MASK is enabled, particles with zero velocity (e.g. generated by the DROP pattern, without acceleration, wind or target position following) are not rendered at all. Particles following their source via PSYS_PART_FOLLOW_SRC_MASK does not count as having a velocity, even if the source is moving.
|notes=
=== Other Notes ===
*The default particle count for the client is normally set at 4096. That is the max particle count the client will render for ALL active particle systems within view range. Good particle system design is key to avoid "spamming" everyone with your particles, and starving out other people's particle systems. As such, if you are experiencing trouble getting your particle emitter to emit as many particles as you like, it may be the victim of particle starvation. Client/viewer lag (low frame rates) can also cause this issue, as particles are a rather low priority for rendering. The best solution for this is to move to a less laggy environment relatively free of other particle systems when designing and testing your own.
*Once particles are emitted, their direction of motion can only be affected by PSYS_SRC_ACCEL, the PSYS_PART_TARGET_POS_MASK flag, or the PSYS_PART_FOLLOW_SRC_MASK flag. As such, there is no good way to create the "swirling vortex" effect (like the one used in the viewer to indicate an object talking, begin derezzed, or when an avatar leaves the sim/grid). The effect can be created with a moving particle source (E.G. An orbiting script.)
*Although the declared particle sizes are always in multiples of 0.03125 meters, PSYS_PART_INTERP_SCALE_MASK allows smooth transitions between the start and end values. This also applies to a size of [[ZERO_VECTOR]], e.g. scaling a particle from or to nothing.
*[[https://wiki.secondlife.com/wiki/User:Talia_Tokugawa/concept/CrazyParticle Something Talia realised that blew her mind]], Documenting experiments with particles, including tutorial of how to do video particles, and how to (disputably) massively exceed the 8192 Limit in terms of how many particles SL can render at one time. (Whilst rendering video on particles is not new just (until now) undocumented, I am fairly confident in saying the method to exceed the particle limit is new.)
 
|examples=
*[[Example Particle Script]]
*[[Neurocam Particle Engine]]
 
 
 
This example produces an effusion of glowing red spheres:
<syntaxhighlight lang="lsl2">llParticleSystem( [
        PSYS_PART_FLAGS,      PSYS_PART_WIND_MASK | PSYS_PART_EMISSIVE_MASK,
        PSYS_SRC_PATTERN,      PSYS_SRC_PATTERN_EXPLODE,
        PSYS_PART_START_COLOR, <1.0, 0.0, 0.0>
    ] );</syntaxhighlight>
|helpers=
|helpers=
'''Useful functions for storing/retrieving color and alpha values to/from integers:'''<br />
'''Useful functions for storing/retrieving color and alpha values to/from integers:'''<br />
<pre>
<syntaxhighlight lang="lsl2">integer ColorAlphatoRGBA(vector color, float alpha) {
integer ColorAlphatoRGBA(vector color, float alpha) {
    return (((integer)(alpha   * 255.0) & 0xFF) << 24) |
return (((integer)(alpha * 255.0) & 0xFF) << 24) |
          (((integer)(color.x * 255.0) & 0xFF) << 16) |
(((integer)(color.x * 255.0) & 0xFF) << 16) |
          (((integer)(color.y * 255.0) & 0xFF) << 8) |
(((integer)(color.y * 255.0) & 0xFF) << 8) |
            ((integer)(color.z * 255.0) & 0xFF);
((integer)(color.z * 255.0) & 0xFF);
}
}


vector RGBAtoColor(integer rgba) {
vector RGBAtoColor(integer rgba) {
return < ((rgba >> 16) & 0xFF) / 255.0, ((rgba >> 8) & 0xFF) / 255.0, (rgba & 0xFF) / 255.0 >;
    return < ((rgba >> 16) & 0xFF) / 255.0, ((rgba >> 8) & 0xFF) / 255.0, (rgba & 0xFF) / 255.0 >;
}
}


float RGBAtoAlpha(integer rgba) {
float RGBAtoAlpha(integer rgba) {
return ((rgba >> 24) & 0xFF) / 255.0;
    return ((rgba >> 24) & 0xFF) / 255.0;
}
}</syntaxhighlight>
</pre>
|deepnotes=
===Missing 14===
There is a missing constant which would have the value 14, the underlying enumeration {{SourceLink/github|viewer|indra/llmessage/llpartdata.h|rev=e45b615|line=51|text=LLPSScriptFlags}} has that as {{SourceLink/github|viewer|indra/llmessage/llpartdata.h|rev=e45b615|line=70|text=LLPS_SRC_BURST_DURATION}}, the value is used nowhere else in the client source. This isn't surprising considering that the burst duration is dependent on the values of PSYS_SRC_BURST_PART_COUNT and PSYS_SRC_BURST_RATE.
===Default texture===
At the time of writing, the default particle texture is actually loaded from the viewer's install directory and does not have its own UUID. The filepath is '''Viewer\skins\default\textures\''pixiesmall.j2c'''''
 
One historically used UUID for this asset is <code>"168e6813-096e-07ea-97ae-fd416826f627"</code> as [https://wiki.secondlife.com/wiki/User:Kizmut_Smit/ClientAssetKeys listed here.]
|also_articles
|also_articles
|also_events
|also_events
|also_functions
|also_functions
|sort=ParticleSystem
|cat1
|notes=
|cat2
* The default particle count for the client is normally set at 4096. That is the max particle count the client will render for ALL active particle systems within view range. Good particle system design is key to avoid "spamming" everyone with your particles, and starving out other people's particle systems. As such, if you are experiencing trouble getting your particle emitter to emit as many particles as you like, it may be the victim of particle starvation. Client/viewer lag (low frame rates) can also cause this issue, as particles are a rather low priority for rendering. The best solution for this is to move to a less laggy environment relatively free of other particle systems when designing and testing your own.
|cat3
* Once particles are emitted, their direction of motion can only be affected by PSYS_PART_ACCEL, the PSYS_PART_TARGET_POS_MASK flag, or the PSYS_PART_FOLLOW_SRC_MASK flag. As such, there is no good way to create the "swirling vortex" effect (like the one used in the viewer to indicate an object talking, begin derezzed, or when an avatar leaves the sim/grid).
|cat4
|constants={{{!}} {{prettytable}}
|cat5
{{!}}{{Hl2}}{{!}}
|cat6
{{!}}{{Hl2}}{{!}} Rule / Value Constant
|location
{{!}}{{Hl2}}{{!}} Type
|haiku={{Haiku|Cherry blossom sprites|alight upon fickle breezes|to fall through the ground.}}
{{!}}{{Hl2}}{{!}} Description
|history = *Date of release llParticleSystem [[ Release_Notes/Second_Life_Release/1.13#Release_Notes_for_Second_Life_1.13.4.281.29_February_21.2C_2007 | 21-02-2007 ]] or [[ Release_Notes/Second_Life_Release/1.14 | 14-03-2007 ]]
{{!}}{{Hl2}}{{!}} Value
*Date of release llLinkParticleSystem[[ Release_Notes/Second_Life_Server/1.38#New_Features | 29-03-2010 ]]
{{!}}- style="background-color:#ccffcc;"
{{!}} colspan="5" align="left"{{!}}'''System Behavior'''
{{!}}-
{{!}}colspan="2"{{!}}PSYS_PART_FLAGS{{!}}{{!}}{{LSLG{{!}}integer}}{{!}}{{!}}Various flags controlling the behavior of the particle system. The value may be specified as an integer in decimal or {{LSLG{{!}}hexadecimal{{!}}hex}} format, or by ORing together (using the <nowiki>|</nowiki> operator) one or more of the following flag constants:{{!}}{{!}}align="center"{{!}}0
{{!}}- style="background-color:#e0e0e0;"
{{!}}rowspan="12" style="background-color:#c0c0c0;" align="center" valign="center"{{!}}'''V<br />a<br />l<br />u<br />e<br />s'''{{!}}{{!}}colspan="2"{{!}}PSYS_PART_BOUNCE_MASK{{!}}{{!}}When set, specifies particles will bounce off a plane at the global Z height of the emitter. On "bounce", each particle reverses velocity and angle. This only works for particles above the plane falling down on it.{{!}}{{!}}align="center"{{!}}{{LSL_Hex|0x004|4}}
{{!}}- style="background-color:#e0e0e0;"
{{!}} colspan="2"{{!}}PSYS_PART_EMISSIVE_MASK{{!}}{{!}}When set, particles are full-bright and are unaffected by global lighting (sunlight). Otherwise, particles will be lit depending on the current global lighting conditions. Note that point lights '''do''' illuminate non-emissive particles.{{!}}{{!}}align="center"{{!}}{{LSL_Hex|0x100|256}}
{{!}}- style="background-color:#e0e0e0;"
{{!}} colspan="2"{{!}}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.{{!}}{{!}}align="center"{{!}}{{LSL_Hex|0x010|16}}
{{!}}- style="background-color:#e0e0e0;"
{{!}} colspan="2"{{!}}PSYS_PART_FOLLOW_VELOCITY_MASK{{!}}{{!}}When set, particles rotate to orient their "top" towards the direction of movement or emission. Otherwise, particles are always emitted based on the current rotation of the emitter.{{!}}{{!}}align="center"{{!}}{{LSL_Hex|0x020|32}}
{{!}}- style="background-color:#e0e0e0;"
{{!}} colspan="2"{{!}}PSYS_PART_INTERP_COLOR_MASK{{!}}{{!}}When set, particle color and alpha transition from their START settings to their END settings during the particle's lifetime. The transition is a smooth interpolation.{{!}}{{!}}align="center"{{!}}{{LSL_Hex|0x001|1}}
{{!}}- style="background-color:#e0e0e0;"
{{!}} colspan="2"{{!}}PSYS_PART_INTERP_SCALE_MASK{{!}}{{!}}When set, particle size/scale transitions from its START setting to its END setting during the particle's lifetime.{{!}}{{!}}align="center"{{!}}{{LSL_Hex|0x002|2}}
{{!}}- style="background-color:#e0e0e0;"
{{!}} colspan="2"{{!}}PSYS_PART_TARGET_LINEAR_MASK{{!}}{{!}}(''not officially documented'') When set, emitted particles move in a straight line towards the target specified by the PSYS_SRC_TARGET_KEY rule. In this mode, PSYS_SRC_ACCEL, PSYS_SRC_BURST_RADIUS, and possibly other rules are ignored.{{!}}{{!}}align="center"{{!}}{{LSL_Hex|0x080|128}}
{{!}}- style="background-color:#e0e0e0;"
{{!}} colspan="2"{{!}}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.{{!}}{{!}}align="center"{{!}}{{LSL_Hex|0x040|64}}
{{!}}- style="background-color:#e0e0e0;"
{{!}} colspan="2"{{!}}PSYS_PART_WIND_MASK{{!}}{{!}}When set, particle movement is affected by the {{LSLG{{!}}llWind{{!}}wind}}. It is applied as a secondary force on the particles.{{!}}{{!}}align="center"{{!}}{{LSL_Hex|0x008|8}}
{{!}}- style="background-color:#e0e0e0;"
{{!}} colspan="2"{{!}}PSYS_PART_RANDOM_ACCEL_MASK{{!}}{{!}}(''unimplemented'') Presumed to be used to apply random acceleration to the particles.{{!}}{{!}}align="center"{{!}} -
{{!}}- style="background-color:#e0e0e0;"
{{!}} colspan="2"{{!}}PSYS_PART_RANDOM_VEL_MASK{{!}}{{!}}(''unimplemented'') Presumed to be used to specify random velocity for the particles upon emission.{{!}}{{!}}align="center"{{!}} -
{{!}}- style="background-color:#e0e0e0;"
{{!}} colspan="2"{{!}}PSYS_PART_TRAIL_MASK{{!}}{{!}}(''unimplemented'') Presumed to be used for implementing "trails" via emitting more particles at shorter bursts.{{!}}{{!}}align="center"{{!}} -
{{!}}- style="background-color:#ccffcc;"
{{!}} colspan="5" align="left"{{!}}'''System Presentation'''
{{!}}-
{{!}} colspan="2"{{!}}PSYS_SRC_PATTERN{{!}}{{!}}{{LSLG{{!}}integer}}{{!}}{{!}}Specifies the general emission pattern.{{!}}{{!}}align="center"{{!}}9
{{!}}- style="background-color:#e0e0e0;"
{{!}}rowspan="5" style="background-color:#c0c0c0;" align="center" valign="center"{{!}}'''V<br />a<br />l<br />u<br />e<br />s'''{{!}}{{!}} colspan="2"{{!}}PSYS_SRC_PATTERN_ANGLE{{!}}{{!}}Present particles in a 2-dimensional circular section as defined by PSYS_SRC_ANGLE_BEGIN and PSYS_SRC_ANGLE_END. The orientation of the particle plane is at X=0 relative to the emitter's global rotation.{{!}}{{!}}align="center"{{!}}{{LSL_Hex|0x04|4}}
{{!}}- style="background-color:#e0e0e0;"
{{!}}colspan="2"{{!}}PSYS_SRC_PATTERN_ANGLE_CONE{{!}}{{!}}Present particles in a 3-dimensional spherical section, as defined by PSYS_SRC_ANGLE_BEGIN and PSYS_SRC_ANGLE_END.{{!}}{{!}}align="center"{{!}}{{LSL_Hex|0x08|8}}
{{!}}- style="background-color:#e0e0e0;"
{{!}}colspan="2"{{!}}PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY{{!}}{{!}}(''not officially documented; appears to be non-functional'') Present particles in a 3-dimensional spherical section, as defined by PSYS_SRC_ANGLE_BEGIN and PSYS_SRC_ANGLE_END, but inversely compared to the ANGLE_CONE pattern (i.e., where there were voids in ANGLE_CONE, there are particles in ANGLE_CONE_EMPTY, and vice-versa.{{!}}{{!}}align="center"{{!}}{{LSL_Hex|0x10|16}}
{{!}}- style="background-color:#e0e0e0;"
{{!}}colspan="2"{{!}}PSYS_SRC_PATTERN_DROP{{!}}{{!}}Present particles by dropping them at the emitter position with no force. Ignores the PSYS_SRC_BURST_RADIUS, PSYS_SRC_BURST_SPEED_MIN, and PSYS_SRC_BURST_SPEED_MAX rules.{{!}}{{!}}align="center"{{!}}{{LSL_Hex|0x01|1}}
{{!}}- style="background-color:#e0e0e0;"
{{!}}colspan="2"{{!}}PSYS_SRC_PATTERN_EXPLODE{{!}}{{!}}Present particles by shooting them out in all directions according to the burst motion rules.{{!}}{{!}}align="center"{{!}}{{LSL_Hex|0x02|2}}
{{!}}-
{{!}}colspan="2"{{!}}PSYS_SRC_BURST_RADIUS{{!}}{{!}}{{LSLG{{!}}float}}{{!}}{{!}}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.{{!}}{{!}}align="center"{{!}}16
{{!}}-
{{!}}colspan="2"{{!}}PSYS_SRC_ANGLE_BEGIN{{!}}{{!}}{{LSLG{{!}}float}}{{!}}{{!}}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_PART_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_PART_ANGLE_END are internally re-ordered such that this parameter gets the smaller of the two values.{{!}}{{!}}align="center"{{!}}22
{{!}}-
{{!}}colspan="2"{{!}}PSYS_SRC_ANGLE_END{{!}}{{!}}{{LSLG{{!}}float}}{{!}}{{!}}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 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_PART_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_PART_ANGLE_BEGIN are internally re-ordered such that this parameter gets the larger of the two values.{{!}}{{!}}align="center"{{!}}23
{{!}}-
{{!}}colspan="2"{{!}}<del>PSYS_SRC_INNERANGLE</del>{{!}}{{!}}{{LSLG{{!}}float}}{{!}}{{!}}'''DEPRECATED: Use PSYS_PART_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.{{!}}{{!}}align="center"{{!}}10
{{!}}-
{{!}}colspan="2"{{!}}<del>PSYS_SRC_OUTERANGLE</del>{{!}}{{!}}{{LSLG{{!}}float}}{{!}}{{!}}'''DEPRECATED: Use PSYS_PART_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.{{!}}{{!}}align="center"{{!}}11
{{!}}-
{{!}}colspan="2"{{!}}PSYS_SRC_TARGET_KEY{{!}}{{!}}{{LSLG{{!}}key}}{{!}}{{!}}Specifies the key of a target object, prim, or agent towarads which the particles will change course and move. 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 flag be set. [[#Caveats{{!}}caveat 4]]{{!}}{{!}}align="center"{{!}}20
{{!}}- style="background-color:#ccffcc;"
{{!}}colspan="5" align="left"{{!}}'''Particle Appearance'''
{{!}}-
{{!}}colspan="2"{{!}}PSYS_PART_START_COLOR{{!}}{{!}}{{LSLG{{!}}vector}}{{!}}{{!}}A {{LSLG{{!}}unit vector}} specifying the {{LSLG{{!}}color}} of the particles upon emission.{{!}}{{!}}align="center"{{!}}1
{{!}}-
{{!}}colspan="2"{{!}}PSYS_PART_END_COLOR{{!}}{{!}}{{LSLG{{!}}vector}}{{!}}{{!}}A {{LSLG{{!}}unit vector}} specifying the {{LSLG{{!}}color}} the particles transition to during their lifetime. Only used if the PSYS_PART_INTERP_COLOR_MASK flag is set.{{!}}{{!}}align="center"{{!}}3
{{!}}-
{{!}}colspan="2"{{!}}PSYS_PART_START_ALPHA{{!}}{{!}}{{LSLG{{!}}float}}{{!}}{{!}}Specifies the {{LSLG{{!}}alpha}} of the particles upon emission. Valid values are in the range 0.0 to 1.0. Higher values are more opaque; lower ones are more transparent.{{!}}{{!}}align="center"{{!}}2
{{!}}-
{{!}}colspan="2"{{!}}PSYS_PART_END_ALPHA{{!}}{{!}}{{LSLG{{!}}float}}{{!}}{{!}}Specifies the {{LSLG{{!}}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. ([[#Caveats{{!}}caveat 1]]){{!}}{{!}}align="center"{{!}}4
{{!}}-
{{!}}colspan="2"{{!}}PSYS_PART_START_SCALE{{!}}{{!}}{{LSLG{{!}}vector}}{{!}}{{!}}Specifies the {{LSLG{{!}}scale}} or size of the particles upon emission. Valid values for each direction are 0.04 (0.03125) to 4.0, in meters. Since particles are essentially 2D sprites, the Z component of the vector is ignored and can be set to 0.0.{{!}}{{!}}align="center"{{!}}5
{{!}}-
{{!}}colspan="2"{{!}}PSYS_PART_END_SCALE{{!}}{{!}}{{LSLG{{!}}vector}}{{!}}{{!}}Specifies the {{LSLG{{!}}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.{{!}}{{!}}align="center"{{!}}6
{{!}}-
{{!}}colspan="2"{{!}}PSYS_SRC_TEXTURE{{!}}{{!}}{{LSLG{{!}}string}}{{!}}{{!}}Specifies the name of a texture in the prim's inventory to use for each particle. Alternatively, you may specify an asset key UUID for a texture.{{!}}{{!}}align="center"{{!}}12
{{!}}- style="background-color:#ccffcc;"
{{!}}colspan="5" align="left"{{!}}'''Particle Flow'''
{{!}}-
{{!}}colspan="2"{{!}}PSYS_SRC_MAX_AGE{{!}}{{!}}{{LSLG{{!}}float}}{{!}}{{!}}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). Maximum is 60.0 seconds. Upon expiration, no more particles will be emitted, except as specified above. ([[#Caveats{{!}}caveat 2]]){{!}}{{!}}align="center"{{!}}19
{{!}}-
{{!}}colspan="2"{{!}}PSYS_PART_MAX_AGE{{!}}{{!}}{{LSLG{{!}}float}}{{!}}{{!}}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.{{!}}{{!}}align="center"{{!}}7
{{!}}-
{{!}}colspan="2"{{!}}PSYS_SRC_BURST_RATE{{!}}{{!}}{{LSLG{{!}}float}}{{!}}{{!}}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.{{!}}{{!}}align="center"{{!}}13
{{!}}-
{{!}}colspan="2"{{!}}PSYS_SRC_BURST_COUNT{{!}}{{!}}{{LSLG{{!}}integer}}{{!}}{{!}}Specifies the number of particles emitted in each "burst".{{!}}{{!}}align="center"{{!}}15
{{!}}- style="background-color:#ccffcc;"
{{!}}colspan="5" align="left"{{!}}'''Particle Motion'''
{{!}}-
{{!}}colspan="2"{{!}}PSYS_SRC_ACCEL{{!}}{{!}}{{LSLG{{!}}vector}}{{!}}{{!}}Specifies a directional acceleration vector applied to each particle as it is emitted, in meters per second. Valid values are 0.0 to 100.0 for each direction, as global coordinates.{{!}}{{!}}align="center"{{!}}8
{{!}}-
{{!}}colspan="2"{{!}}PSYS_SRC_OMEGA{{!}}{{!}}{{LSLG{{!}}vector}}{{!}}{{!}}Specifies the rotational spin of the emitter in radians per second along each axis. This "unsticks" the emitter facing from the prim's positive Z axis and is noticeable in directional presentations. Prim spin (via {{LSLG{{!}}llTargetOmega}}) has no effect on emitter spin. ([[#Caveats{{!}}caveat 3]]){{!}}{{!}}align="center"{{!}}21
{{!}}-
{{!}}colspan="2"{{!}}PSYS_SRC_BURST_SPEED_MIN{{!}}{{!}}{{LSLG{{!}}float}}{{!}}{{!}}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_PART_BURST_SPEED_MAX are internally re-ordered such that this parameter gets the smaller of the two values.{{!}}{{!}}align="center"{{!}}17
{{!}}-
{{!}}colspan="2"{{!}}PSYS_SRC_BURST_SPEED_MAX{{!}}{{!}}{{LSLG{{!}}float}}{{!}}{{!}}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_PART_BURST_SPEED_MIN are internally re-ordered such that this parameter gets the larger of the two values.{{!}}{{!}}align="center"{{!}}18
{{!}}}
}}
}}

Latest revision as of 00:00, 14 April 2024

Summary

Summary: llParticleSystem, llLinkParticleSystem

These functions are almost entirely identical.

The big difference is that llParticleSystem acts upon the prim the script is in, llLinkParticleSystem on the other hand can act upon any prim in the object.

llParticleSystem

Function: llParticleSystem( list rules );
0.0 Forced Delay
10.0 Energy

Defines a particle system for the containing prim based on a list of rules.

• list rules Particle system rules list in the format [ rule1, data1, rule2, data2 . . . rulen, datan ]

llLinkParticleSystem

Function: llLinkParticleSystem( integer link, list rules );
0.0 Forced Delay
10.0 Energy

A particle system defined by a list of rules is set for the prim(s) link.

• integer link Link number (0: unlinked, 1: root prim, >1: child prims and seated avatars) or a LINK_* flag
• list rules Particle system rules list in the format [ rule1, data1, rule2, data2 . . . rulen, datan ]

Specification

Defines a particle system that sets the state of the particle emitter within the prim that contains the script. Any other scripts, in the same prim, that call this function will modify the state of the same particle emitter. As such, the particle system defined by this function is a prim property, just like its size, shape, color, etc.

Each prim has only one (1) particle emitter, located at its geometric center, and aligned along the prim's local Z-axis, pointing in the positive Z direction.

This is the one of the only functions which alters the state of the prim's particle emitter; thus, if you wish to change the emitter to a different state (i.e., emitting a different particle system entirely, or shut off the emitter completely), just call the function with the parameters of the new particle system you wish to render instead. Specifying an empty list (i.e., llParticleSystem([]); ) turns the emitter off.

Particles are essentially 2D "Wikipedia logo"sprites and are always rendered facing the viewer's camera (except when PSYS_PART_RIBBON_MASK is enabled).

The rule / data values are defined below.

Flag Description
LINK_ROOT 1 refers to the root prim in a multi-prim linked set[1]
LINK_SET -1 refers to all prims
LINK_ALL_OTHERS -2 refers to all other prims
Flag Description
LINK_ALL_CHILDREN -3 refers to all children, (everything but the root)
LINK_THIS -4 refers to the prim the script is in
Rule / Value Constant Rule Parameter Description Value
System Behavior
PSYS_PART_FLAGS integer flags Various flags controlling the behavior of the particle system. The value may be specified as an integer in decimal or hex format, or by ORing together (using the | operator) one or more of the following flag constants: 0
V
a
l
u
e
s
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. 0x004
PSYS_PART_EMISSIVE_MASK When set, particles are full-bright and are unaffected by global lighting (sunlight). Otherwise, particles will be lit depending on the current global lighting conditions. Note that point lights do illuminate non-emissive particles. 0x100
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. 0x010
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). 0x020
PSYS_PART_INTERP_COLOR_MASK When set, particle color and alpha transition from their START settings to their END settings during the particle's lifetime. The transition is a smooth interpolation. 0x001
PSYS_PART_INTERP_SCALE_MASK When set, particle size/scale transitions from its START setting to its END setting during the particle's lifetime. 0x002
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. 0x400
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. 0x080
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. 0x040
PSYS_PART_WIND_MASK When set, particle movement is affected by the wind. It is applied as a secondary force on the particles. 0x008
PSYS_PART_BEAM_MASK (unimplemented) mask but in the enum 0x200
LL_PART_HUD Used by the viewer to keep HUD and World particle sources separate. 0x40000000
LL_PART_DEAD_MASK Removes particles, not compatible with any other PSYS_PART_*_MASK 0x80000000
System Presentation
PSYS_SRC_PATTERN integer pattern Specifies the general emission pattern. 9
V
a
l
u
e
s
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. 0x02
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). 0x08
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. 0x04
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.) 0x01
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). 0x10
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. A test in http://forums-archive.secondlife.com/327/f5/226722/1.html indicates that the maximum value is 50.00 16
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. 22
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. 23
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. 10
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. 11
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. caveat 4 20
Particle Appearance
PSYS_PART_START_COLOR vector color_start A vector specifying the color of the particles upon emission. 1
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. 3
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. 2
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. 4
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. 5
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. 6
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). 12
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). 26
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. 27
Particle Blending
Note: The particle system blend parameters wrap directly to OpenGL's glBlendFunc. Detailed documentation for glBlendFunc, including formulas, can be found in the official glBlendFunc documentation
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. 24
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. Most other blending combinations will render the invisible/alpha portion of your particle texture, unless the invisible area of your texture is all black (or, in some cases, unless it is all white). 25
V
a
l
u
e
s
PSYS_PART_BF_ONE Do not scale the source or destination RGBA values. 0x0
PSYS_PART_BF_ZERO Zero out the source or destination RGBA values. 0x1
PSYS_PART_BF_DEST_COLOR Scale the RGBA values by the RGBA values of the destination. 0x2
PSYS_PART_BF_SOURCE_COLOR Scale the RGBA values by the RGBA values of the particle source. 0x3
PSYS_PART_BF_ONE_MINUS_DEST_COLOR Scale the RGBA values by the inverted RGBA values of the destination. 0x4
PSYS_PART_BF_ONE_MINUS_SOURCE_COLOR Scale the RGBA values by the inverted RGBA values of the particle source. 0x5
PSYS_PART_BF_SOURCE_ALPHA Scale the RGBA values by the alpha values of the particle source. 0x7
PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA Scale the RGBA values by the inverted alpha values of the particle source. 0x9
Particle Flow
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. (caveat 1) 19
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. 7
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. 13
PSYS_SRC_BURST_PART_COUNT integer burst_particle_count Specifies the number of particles emitted in each "burst". 15
Particle Motion
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. 8
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. (caveat 2 and caveat 3) 21
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. 17
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. 18

Caveats

  1. When using particle systems that have a non-zero emitter age (PSYS_SRC_MAX_AGE) setting, you may notice that the particle system may restart without any scripted trigger going off. This is due to a bug which causes the emitter to "reset" when any of the prim properties are updated or otherwise sent to the viewer. As a result, you may have to use a timer or a forced sleep and then clear the particle system once the age has expired. Debbie Trilling has posted a work-around here: https://forums-archive.secondlife.com/54/fa/260031/1.html#post1996465
  2. The spin defined by PSYS_SRC_OMEGA is relative to the region coordinate system, NOT the prim's local coordinate system.
  3. New non-zero vector values for PSYS_SRC_OMEGA will not re-align the emitter with the prim before they take effect. The viewer will continue rotating the emitter with the new omega values, starting from the last known orientation of the emitter. The emitter's current orientation is determined by the viewer, not the simulator, and two people looking at the same effect may see different results. To re-align the emitter with the prim, create an effect with PSYS_SRC_OMEGA set to ZERO_VECTOR long enough for the viewer to have a chance to render it.
  4. Particles moving towards a humanoid avatar, specified by PSYS_SRC_TARGET_KEY rule and setting the PSYS_PART_TARGET_POS_MASK flag, will end up at the geometric center of the avatar's bounding box which, unfortunately, make them appear to be striking the person in the groin area. If you want them to end up at another point on a target avatar, you instead have to place a target prim that is moved to the position where you wish them to end up, and use the key of that prim for the value of the PSYS_SRC_TARGET_KEY rule.
  5. The Second Life viewer uses optimizations in culling objects which are too small to see at certain distances. If your emitter is very small, and is culled due to distance, the particle system associated with it will not be rendered either.
  6. Particles will also be culled beyond a maximum distance depending on their own scale. If particles are desired to be visible from further away yet be visually smaller, a larger scale and a texture with empty padding space are needed. If using PSYS_PART_RIBBON_MASK, make sure the Y scale is set properly, as it is used for this calculation even the rendering of the ribbon particles themselves ignores it.
  7. When PSYS_PART_FOLLOW_VELOCITY_MASK is enabled, particles with zero velocity (e.g. generated by the DROP pattern, without acceleration, wind or target position following) are not rendered at all. Particles following their source via PSYS_PART_FOLLOW_SRC_MASK does not count as having a velocity, even if the source is moving.

Examples


This example produces an effusion of glowing red spheres:

llParticleSystem( [
        PSYS_PART_FLAGS,       PSYS_PART_WIND_MASK | PSYS_PART_EMISSIVE_MASK,
        PSYS_SRC_PATTERN,      PSYS_SRC_PATTERN_EXPLODE, 
        PSYS_PART_START_COLOR, <1.0, 0.0, 0.0>
    ] );

Useful Snippets

Useful functions for storing/retrieving color and alpha values to/from integers:

integer ColorAlphatoRGBA(vector color, float alpha) {
    return (((integer)(alpha   * 255.0) & 0xFF) << 24) |
           (((integer)(color.x * 255.0) & 0xFF) << 16) |
           (((integer)(color.y * 255.0) & 0xFF) <<  8) |
            ((integer)(color.z * 255.0) & 0xFF);
}

vector RGBAtoColor(integer rgba) {
    return < ((rgba >> 16) & 0xFF) / 255.0, ((rgba >> 8) & 0xFF) / 255.0, (rgba & 0xFF) / 255.0 >;
}

float RGBAtoAlpha(integer rgba) {
    return ((rgba >> 24) & 0xFF) / 255.0;
}

Notes

Link Numbers

Each prim that makes up an object has an address, a link number. To access a specific prim in the object, the prim's link number must be known. In addition to prims having link numbers, avatars seated upon the object do as well.

  • If an object consists of only one prim, and there are no avatars seated upon it, the (root) prim's link number is zero.
  • However, if the object is made up of multiple prims or there is an avatar seated upon the object, the root prim's link number is one.

When an avatar sits on an object, it is added to the end of the link set and will have the largest link number. In addition to this, while an avatar is seated upon an object, the object is unable to link or unlink prims without unseating all avatars first.

Counting Prims & Avatars

There are two functions of interest when trying to find the number of prims and avatars on an object.

integer GetPrimCount() { //always returns only the number of prims
    if(llGetAttached())//Is it attached?
        return llGetNumberOfPrims();//returns avatars and prims but attachments can't be sat on.
    return llGetObjectPrimCount(llGetKey());//returns only prims but won't work on attachments.
}
See llGetNumberOfPrims for more about counting prims and avatars.

Errata

If a script located in a child prim erroneously attempts to access link 0, it will get or set the property of the linkset's root prim. This bug (BUG-5049) is preserved for broken legacy scripts.

Other Notes

  • The default particle count for the client is normally set at 4096. That is the max particle count the client will render for ALL active particle systems within view range. Good particle system design is key to avoid "spamming" everyone with your particles, and starving out other people's particle systems. As such, if you are experiencing trouble getting your particle emitter to emit as many particles as you like, it may be the victim of particle starvation. Client/viewer lag (low frame rates) can also cause this issue, as particles are a rather low priority for rendering. The best solution for this is to move to a less laggy environment relatively free of other particle systems when designing and testing your own.
  • Once particles are emitted, their direction of motion can only be affected by PSYS_SRC_ACCEL, the PSYS_PART_TARGET_POS_MASK flag, or the PSYS_PART_FOLLOW_SRC_MASK flag. As such, there is no good way to create the "swirling vortex" effect (like the one used in the viewer to indicate an object talking, begin derezzed, or when an avatar leaves the sim/grid). The effect can be created with a moving particle source (E.G. An orbiting script.)
  • Although the declared particle sizes are always in multiples of 0.03125 meters, PSYS_PART_INTERP_SCALE_MASK allows smooth transitions between the start and end values. This also applies to a size of ZERO_VECTOR, e.g. scaling a particle from or to nothing.
  • [Something Talia realised that blew her mind], Documenting experiments with particles, including tutorial of how to do video particles, and how to (disputably) massively exceed the 8192 Limit in terms of how many particles SL can render at one time. (Whilst rendering video on particles is not new just (until now) undocumented, I am fairly confident in saying the method to exceed the particle limit is new.)

See Also

Functions

•  llGetLinkNumber Returns the link number of the prim the script is in.

Articles

•  Color in LSL
•  Translucent Color

Deep Notes

Missing 14

There is a missing constant which would have the value 14, the underlying enumeration LLPSScriptFlags has that as LLPS_SRC_BURST_DURATION, the value is used nowhere else in the client source. This isn't surprising considering that the burst duration is dependent on the values of PSYS_SRC_BURST_PART_COUNT and PSYS_SRC_BURST_RATE.

Default texture

At the time of writing, the default particle texture is actually loaded from the viewer's install directory and does not have its own UUID. The filepath is Viewer\skins\default\textures\pixiesmall.j2c

One historically used UUID for this asset is "168e6813-096e-07ea-97ae-fd416826f627" as listed here.

History

Footnotes

  1. ^ LINK_ROOT does not work on single prim objects. Unless there is an avatar sitting on the object.

Signature

function void llParticleSystem( list rules );
function void llLinkParticleSystem( integer link, list rules );


integer PSYS_PART_FLAGS = 0;
integer PSYS_PART_BOUNCE_MASK = 0x004;
integer PSYS_PART_EMISSIVE_MASK = 0x100;
integer PSYS_PART_FOLLOW_SRC_MASK = 0x010;
integer PSYS_PART_FOLLOW_VELOCITY_MASK = 0x020;
integer PSYS_PART_INTERP_COLOR_MASK = 0x001;
integer PSYS_PART_INTERP_SCALE_MASK = 0x002;
integer PSYS_PART_RIBBON_MASK = 0x400;
integer PSYS_PART_TARGET_LINEAR_MASK = 0x080;
integer PSYS_PART_TARGET_POS_MASK = 0x040;
integer PSYS_PART_WIND_MASK = 0x008;
integer PSYS_SRC_PATTERN = 9;
integer PSYS_SRC_PATTERN_EXPLODE = 0x02;
integer PSYS_SRC_PATTERN_ANGLE_CONE = 0x08;  
integer PSYS_SRC_PATTERN_ANGLE = 0x04;
integer PSYS_SRC_PATTERN_DROP = 0x01;
integer PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY = 0x10;
integer PSYS_SRC_BURST_RADIUS = 16;
integer PSYS_SRC_ANGLE_BEGIN = 22;
integer PSYS_SRC_ANGLE_END = 23;
integer PSYS_SRC_INNERANGLE = 10;//deprecated
integer PSYS_SRC_OUTERANGLE = 11;//deprecated
integer PSYS_SRC_TARGET_KEY = 20;
integer PSYS_PART_START_COLOR = 1;
integer PSYS_PART_END_COLOR = 3;
integer PSYS_PART_START_ALPHA = 2;
integer PSYS_PART_END_ALPHA = 4;
integer PSYS_PART_START_SCALE = 5;
integer PSYS_PART_END_SCALE = 6;
integer PSYS_SRC_TEXTURE = 12;
integer PSYS_PART_START_GLOW = 26;
integer PSYS_PART_END_GLOW = 27;
integer PSYS_SRC_MAX_AGE = 19;
integer PSYS_PART_MAX_AGE = 7;
integer PSYS_SRC_BURST_RATE = 13;
integer PSYS_SRC_BURST_PART_COUNT = 15;
integer PSYS_SRC_ACCEL = 8;
integer PSYS_SRC_OMEGA = 21;
integer PSYS_SRC_BURST_SPEED_MIN = 17;
integer PSYS_SRC_BURST_SPEED_MAX = 18;

Poetry

Cherry blossom sprites
alight upon fickle breezes
to fall through the ground.