для этой страницы,
отображается код на другом
A particle system is a really versatile technique that allows creating complex moving structures that produce dynamic and "fuzzy" effects. These structures are used for simulation of abstract effects of fire, smoke, explosions, electricity, fountains, rocket trails, flocking, magic, and many many more. All these effects are hard to reproduce using traditional rigid objects: particles are represented not by a set of primitive surface elements, but by point masses forming the volume of particle primitives. Another distinctive feature is that particles are not static — they may change not only their position, but also the form with the time.
A particle system consists of three main entities:
- Emitter — the source that emits particles according to the values set in the Emitter parameters.
- Particles themselves, which are emitted according to the predefined behavior after emission.
- Additional physical effects applied to the particles that affect their behavior.
- The particles_base material to adjust the particles appearance
- The ObjectParticles class to manage particles via API
- A set of samples located in the data/samples/objects/ directory:
To create particles, perform the following steps:
- On the Menu bar, click Create -> Particle System -> Particles.
- Place the Particles object somewhere in the world.
- Specify the particles parameters.
The particles emitter's behaviour is set via the Emitter parameters.
|Clear On Enable||Enables re-initialization of the particle system each time it is enabled. When this option is disabled, turning on the particle system restores the state it had before it was turned off.|
|Emitter Enabled||Enables the emitter.|
|Emitter Sync||Enables synchronization of the child particle system with the parent one, even if the child particle system has the Emitter enabled option disabled.|
|Emitter Shape||The shape of the volume within which the particles are generated:|
|Emitter Size||The size of the particles source. The number of fields (whether it is radius or boundary dimensions) depend on the chosen shape.|
|Sequence Order||the order of rendering for particle systems, especially when creating a complex effects like shots (with muzzle flash, smoke and the shot itself, each rendered with different particle systems). This parameter is very much the same as Rendering Order option in the Materials Settings. But it allows setting a rendering sequence inside of the particle system hierarchy, to avoid such situations when the smoke from a distant shot is rendered atop of the fire of the foreground shot.
|Emitter Shift||Enabling this checkbox makes the emitter generate particles only when the Particle System is moving.|
|Emitter Continuous||Enables continuous particles that follow the shift of the emitter.|
|Texture Atlas||Enabling this feature makes the following: a random image from the albedo texture is picked up for every particle.
For using this option, Animation of the texture should be disabled.
|Texture Atlas Size||The size of the texture atlas.|
|Random Flip X||Flipping of random emitted particles horizontally (along the X axis).
|Random Flip Y||Flipping of random emitted particles vertically (along the Y axis).
|Warming On Start||Toggles on and off the particle system initialization with the illusion of prior activity.
The particle system evolves with time, so after encountering it in the virtual world, the system only starts to be generated, particle by particle, until the whole system gains the intended look. When the character comes out on a glade, we will see a fire gradually burn up. Warm start for the particles enables rendering the full-grown particle system straight away.
The technical realization of warm start is the following: when the particle system is initialized on the encounter, its life is computed starting from the generation of the first particle to its disappearance. After that, the particle system is considered evolved and is rendered in this state. The calculations are taken at a fixed frame rate of 25 fps, which is the minimum required for the correct simulation of particle systems (see also information about correlation between framerates).
Warm start can be enabled without any detrimental effect for any particles systems, except for huge ones.
|Max Warming Time (Sec)||Maximum time of the particle system warmup.|
|Spawn Rate||Number of spawn actions per second. The value defines how many times a certain number of particles will be spawned in one second. For example, the value set to 5 equals to 5 spawn actions per second. 0 results in no particles at all.|
|Number Per Spawn||Number of particles to be spawned simultaneously each time according to the Spawn Rate.|
|Spawn Threshold||Threshold of the number of particles depending on the velocity of the parent particles.
This parameter is used to additionally synchronize the number of particles spawned by spark and random emitters with the parent particle system.
Threshold for random emitter functions only with a particle system as a parent node.
|Limit Per Spawn||The total maximum number of particles emitted per spawn. This parameter specifies the number of particles that can simultaneously exist in the world. In other words, the number of particles existing in the world cannot exceed the limit value. For example, if the Number per Spawn value is 10, and the Limit Per Spawn value is 5, 5 particles will be emitted. And no particles will be spawned until the previous ones exist.|
|Life Time (Sec)||Duration of the particles existence after emission in seconds. This parameter also has the Spread value that creates the variety of the Life Time value, in seconds.|
|Delay||Delay option defines the time to pass between the parent system initialization and initialization of the child node. If any delay is set, the parent system starts emitting particles, and after the delay, the generation of child particles is activated. If a particle system doesn't have children, the delay defines the time after which the particles are emitted. This parameter also has the Spread value that creates the variety of delay of particle initialization, in seconds.|
|Period||Duration of a pause between generation cycles, in seconds.
|Duration||Duration of generation cycle, within which emission occurs, in seconds.
|Spread (+/-)||Spread option introduces additional modulation of the corresponding parameter. It represents the range of values that can be randomly added to or subtracted from the specified parameter value.|
Behavior After Emission#
This set of parameters defines how the particles behave after they are emitted:
Value Setting Options#
Most parameters in this section have multiple options for setting a value:
- Const — the value is precise and unchanged over time.
- Between Const — an interval is set, from which a random value is selected for each instance.
- Curve — the parameter value changes over time based on the curve defined in Curve Editor.
- Between Curve — there are two curves set in Curve Editor that define the limits, and a random value is taken at every moment of time within these limits. The parameter value changes over time based on this randomly generated set of values.
To select a desired value type, use the gear button.
|Depth Sort||Depth sorting is required, if particles use alpha blending (except for the additive one). If not enabled, then based on the depth buffer data, opaque objects positioned farther can be wrongly rendered in front of transparent particles. With depth sorting, geometry is rendered in the order from back to front, which rules out visual artifacts.|
|Emitter Based||Enabling this option makes particles move along with the emitter.|
|Position||Particle position coordinates relative to the emitter along X, Y and Z axes.|
|Gravity||Gravity force affecting particles along the X, Y and Z axes.
|Direction||Direction in which all emitted particles move forming a flow, specified along the X, Y and Z axes.|
|Velocity||The speed of particles movement in the set direction, in units per second. To grant the natural-looking flow, the final velocity of each separate particle can differ, if the range of values is set.|
|Linear Damping||The decrease in particles linear velocity over time. This parameter is used to simulate effect of friction of the medium for particles.|
|Angle||Angle of particles orientation in space, in degrees.
If the angle value is set to 180 degrees, the particles will be randomly oriented in all directions.
|Rotation Speed||Angular velocity of particles, in degrees per second.
|Radius||Radius (half-size) of the particle.|
|Increase In Radius||Increment of the size of a particle, in units per second.
|Length Stretch||Stretching of a particle billboard, available for the Length Particles. With the value of 0, the length particle is simply a square billboard. Increasing the value stretches particles in the direction of their movement. The result is calculated by multiplying the stretch value by the particle velocity value. So, the higher the velocity is, the more stretched the particles are in the direction of their movement, while the other side remains of the same width.
|Length Flattening||Makes the Length Particles not camera-oriented as usual billboard particles, but more perpendicular to the Z axis. With the value of 0, the particles are not flattened. With the maximum value of 1, the particles will be flat (perpendicular to the Z axis) when they are emitted.
Interaction of the particles is limited to the application of forces and collisions with external objects. There are two methods to detect the collision with external objects: by using the Physics Intersection parameter or the Collision parameter.
|Physical Mask||For a more selective interaction of the particles systems with physical nodes, the physical bit mask is used. This bit mask is set for both the particles system and the force. These masks should have at least one bit matching, otherwise there would be no interaction. The other bits of the mask can match masks of other forces, thus providing perfect control over the scene integration.|
|Physical Mass||To participate in the scene dynamics, particles should have a certain mass in kilograms. This value defines the intensity of the physical node's influence on the particles flow.
The Physical Mass parameter doesn't affect other calculations.
|Restitution||Strength of particles bouncing off an obstacle. This option is very convenient for simulation of some water effects that include splashes. The strength the bouncing effect depends on both the restitution parameter of particles and the value of the restitution surface parameter set for the colliding object (Properties ->Parameters tab -> Restitution).
|Roughness||Roughness of the surface of an obstacle the particle collides with. It determines whether the particles scatter in different directions or react as a uniformly directed flow.
|Collision||Enables collision detection with the whole shape of a particle.
If particles are big enough, this method is more preferable than Intersection, as it provides a higher degree of visual realism: particles react according to the set parameters, when their edge or vertex comes in contact with an object. Collision calculations are more expensive, so big particles systems should use this option carefully.
|Intersection||Enables intersection detection with the center of a particle.
Physics intersection may look a bit unnatural as the physical reaction starts only when the half of the particle has already penetrated the mesh, but it is perfectly suitable if there are a lot of small particles. The main advantage of this method is that it is fast and cheap in performance.
Physics intersections are detected for matching physics intersection bit masks.
|Destroy In Collision/Intersection||Toggles on and off culling of particles that have already undergone either collision or intersection.|
Render To Texture#
The following settings are available:
|Rendering||Enables rendering of particles to a procedural texture.|
|Positioning||Defines positioning mode to be used for child nodes (decal or field) using the procedural texture, to which the particle system is rendered. The following values are available:
Takes effect only when Procedural Parenting is set to Children.
|Parenting||Defines relationship between the particle system and a decal/field node, that uses the procedural texture into which the particle system is rendered:
|Resolution||Specifies resolution of the procedural texture into which particles are rendered.
Additional Physical Effects#
More intricate changes in further movement of the particles may be performed by applying the additional physical effects. They have influence on the particles flow in the desired direction or on the contrary deflect it. The effects can be of three general types:
There is no limitation to the number of additional physical effects applied to one particle system and they can freely overlap, enabling to constitute complex trajectories easily and fast.
Forces represent a force concentrated in a point, application of which is limited by the sphere. The force sphere can be placed anywhere in the scene and rotated, if necessary. However, for the force to affect the particles movement, it should include these particles in its radius.
A physical noise is a cuboid shaped area that adds a distribution flow based on a volumetric noise texture.
Deflector is a surface field that has no visual representation, but physically interacts with the particle system (no other objects are influenced, of course). Depending on the specified size, it can be either rectangular or square, plus arbitrarily positioned or rotated to cover the necessary area.
Deflectors are one-sided, meaning the particles can freely penetrate them through one side, and interact only with the opposite one, for example, when having fallen on it from above.
Particles Node Hierarchy#
To create complex effects, it is necessary that all particles systems are synchronized in time. Setting a particle system as a parent node results in the following:
- All particles systems that are child nodes are synchronized relative to their parent particle systems. If the children have children of their own, they still are synchronized with the main parent system, which is the highest in the hierarchy.
- When creating a new child particle system, it should be synchronized with the parent one by disabling and again enabling the parent emitter (Node tab -> Enabled box). At this moment, each of the child systems is initialized with its Emitter parameters (such as generation duration, period of generation pause, and delay of initialization).
- Disabling or enabling the parent emitter (Node tab -> Enabled box) affects all child particle systems: they synchronously stop or start emitting particles (emitted particles still live out their time).
- Disabling or enabling the parent node (Node tab -> Enabled box) also affects all children: all particle systems in the hierarchy are turned off and on — and preserve the same state as was at the moment of their disabling.
Synchronizing Several Particle Systems#
To synchronize several particle systems, for example, to create a shot effect (with three particle systems: muzzle flash, smoke and the bullet), you can do the following:
- Create the parent particle system that will be used as a dummy one, purely for synchronization purposes (you can even disable its surface). Its Duration time interval should cover all duration intervals and delay intervals (if any) of the children particle systems. Other parameters (Spawn Rate, etc.) do not matter.
- Add the child particle systems. They can have any Duration time required (but it should be smaller than the one of the parent). For example, to synchronize all child particle systems at once and spawn only one particle, you can set the following:
Updating each frame a huge number of objects located far away from the camera that are hardly distinguishable or observed as a mass is a waste of resources.
To improve performance and avoid the excessive load, particle systems simulation can be updated with a reduced framerate. When a particle system is out of the area specified by the Update Distance Limit, particles stop to be updated and freeze statically.
The set of frame rates given below enables you to specify how often the particles simulation should be updated when the particle system is visible, when only its shadow is visible, or when it is not visible at all.
This feature is enabled with default settings ensuring optimum performance and can be adjusted per-object in the UnigineEditor or via API at run time.
If your project, for example, contains an invisible particle system (e.g., using the viewport mask) and some logic attached to its update (e.g. spawning some visible particles on collision with objects) this logic won't work, as the particle system might be updated with a reduced rate or might not be updated at all. To enable updating such objects regardless of their visibility you can set the Update Distance Limit and corresponding update rate values for it to infinity.
It is possible to create mesh-based particle systems. For that, Mesh Cluster should be added as a child node of ObjectParticles. After that, meshes are automatically spawned by the emitter.