User Tools

Site Tools


gamedev:particleemitters

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
gamedev:particleemitters [2011/09/18 00:20] – [Parameters] dragonlordgamedev:particleemitters [2019/05/24 23:43] (current) – ↷ Links adapted because of a move operation dragonlord
Line 1: Line 1:
-====== Particle Emitters ======+{{tag>particle graphic physics collision}} 
 +<WRAP youarehere> 
 +[[:start|Start Page]] >> [[:gamedev|Game Development with the Drag[en]gine]] >> **Particle Emitters** 
 +</WRAP> 
 Particle emitters allow to create particles in the game world influenced by physics. Physical behavior is not mandatory but the default behavior. Particle systems are split into two individual components to simplify the process of defining and using particles. Particle emitters are defined once and are then reused multiple times using instances. Emitters support both continuous and burst like emission of particles. For fine grained control over the properties of generated particles controllers are used. These work similar to controllers in [[gamedev:animators|animators]]. Furthermore emitters support collision emitters to simplify creating cascaded emitters like rain drops hitting the floor bursting into smaller drops upon impact. Emitters can also be set to self-destroy after the last particle has died. This allows to use particles in a deploy-and-forget manner. Particle emitters allow to create particles in the game world influenced by physics. Physical behavior is not mandatory but the default behavior. Particle systems are split into two individual components to simplify the process of defining and using particles. Particle emitters are defined once and are then reused multiple times using instances. Emitters support both continuous and burst like emission of particles. For fine grained control over the properties of generated particles controllers are used. These work similar to controllers in [[gamedev:animators|animators]]. Furthermore emitters support collision emitters to simplify creating cascaded emitters like rain drops hitting the floor bursting into smaller drops upon impact. Emitters can also be set to self-destroy after the last particle has died. This allows to use particles in a deploy-and-forget manner.
  
 ====== Emitters ====== ====== Emitters ======
-Emitters contain the definition of a single particle system. Emitters are non-resource objects hence they are not loaded from a file but build at run-time. This allows the user to use his own way of storing particle systems. An emitter should not be changed after it has been initialized and is in use by instances. Emitters can emit particles either continuously or in bursts. The default behavior is to emit particle continuously. In this mode the interval parameter is used to determine the time until the next particle is emitted. The number of particle emitted each time the interval elapses is defined using the particle count parameter. In burst mode particles are emitted once only. In burst mode the particle count parameter is also evaluated over the burst lifetime of the emitter. This lifetime defines the length of a burst. Using the progress curve of the particle parameter multiple emissions of particles can be defined along the burst lifetime. Thus it is possible to fine tune the emission behavior of particles in a burst if required. More information about this can be found in the particle count parameter section.+Emitters contain the definition of a single particle system. Emitters are non-resource objects hence they are not loaded from a file but build at run-time. This allows the user to use his own way of storing particle systems. An emitter should not be changed after it has been initialized and is in use by instances. Emitters can emit particles either continuously or in bursts. The default behavior is to emit particle continuously. In this mode the interval parameter is used to determine the time until the next particle is emitted. The number of particle emitted each time the interval elapses is defined using the particle count parameter. In burst mode particles are emitted once only. In burst mode the particle count parameter is also evaluated over the burst lifetime of the emitter. This lifetime defines the length of a burst. Using the progress curve of the particle parameter multiple emissions of particles can be defined along the burst lifetime. Thus it is possible to fine tune the emission behavior of particles in a burst if required. More information about this can be found in the particle count parameter section. The layer mask and group number are set to each instance the emitter is assigned to. This is required for cascaded emitters since the game code does not have access to the created instances. You can still though change the layer mask and group number in instances you have access to after you set an emitter.
  
 ^Name^Description^Type^Default^ ^Name^Description^Type^Default^
 |Emit Burst|Determines if particles are emitted continuously or in bursts|Boolean|False| |Emit Burst|Determines if particles are emitted continuously or in bursts|Boolean|False|
 |Burst Lifetime|The life time in seconds of the emitter if using burst mode|Float|1.0| |Burst Lifetime|The life time in seconds of the emitter if using burst mode|Float|1.0|
 +|Layer Mask|Collision mask.|LayerMask|(empty)|
 +|Group Number|Collision group number|Int|0|
 |Controllers|Controller definitions.|ParticleEmitterController[]| | |Controllers|Controller definitions.|ParticleEmitterController[]| |
 |Types|Particle type definitions.|ParticleEmitterType[]| | |Types|Particle type definitions.|ParticleEmitterType[]| |
Line 46: Line 52:
 Particles collide with objects using the **Layer Mask** and **Group Number** of the parent instance. The **Collision Response** parameter defines the reaction of particles to collisions. If **Destroy** is set particles are destroy upon collision. If **Physical** is chosen particles bounce of the surface they hit using physical simulation. The **elasticity** and **roughness** parameter governs this behavior. If **Custom** is chosen the game scripts are used to determine what to do. This works similar to the callback in [[gamedev:colliders|colliders]]. Additionally upon impact new child instances can be produced. This allows to create cascading particle effects. Care has to be taken to not produce loops or producing too many particles. An emitter can be specified using **Collision Emitter**. To avoid creating too many particles in the case of **Physical** for **Collision Response** the impulse of the impact is used to limit the cases where instances are produced. Only if the impulse of the impacting particle exceeds Emit Min Impulse an instance is created. This value should be kept large to produce only instances upon heavy impacts. Once created particle parameters can be transfered to the controllers of the created instance. This allows to influence the child particles using impact properties. You can set a controller index for the lifetime, mass, linear and angular velocity of the impacting particle. If the controller is set to a valid controller in the created child instance the given particle property is set as the controller value. Particles collide with objects using the **Layer Mask** and **Group Number** of the parent instance. The **Collision Response** parameter defines the reaction of particles to collisions. If **Destroy** is set particles are destroy upon collision. If **Physical** is chosen particles bounce of the surface they hit using physical simulation. The **elasticity** and **roughness** parameter governs this behavior. If **Custom** is chosen the game scripts are used to determine what to do. This works similar to the callback in [[gamedev:colliders|colliders]]. Additionally upon impact new child instances can be produced. This allows to create cascading particle effects. Care has to be taken to not produce loops or producing too many particles. An emitter can be specified using **Collision Emitter**. To avoid creating too many particles in the case of **Physical** for **Collision Response** the impulse of the impact is used to limit the cases where instances are produced. Only if the impulse of the impacting particle exceeds Emit Min Impulse an instance is created. This value should be kept large to produce only instances upon heavy impacts. Once created particle parameters can be transfered to the controllers of the created instance. This allows to influence the child particles using impact properties. You can set a controller index for the lifetime, mass, linear and angular velocity of the impacting particle. If the controller is set to a valid controller in the created child instance the given particle property is set as the controller value.
  
-Trails can be added to all particles of a type using the **Trail Emitter** parameter. The set emitter should be a continuous emitting particle emitter. Upon emitting a particle an instance of this emitter is created and attached to the particle in reverse. Hence the orientation of the instance is opposite direction than the one the particle is traveling. As soon as the particle dies the trail instance is set to remove itself one the last particle died. Trail emitters and collision emitters can be used together if required. Here too make sure to not create too many particles.+Trails can be added to all particles of a type using the **Trail Emitter** parameter. The set emitter should be a continuous emitting particle emitter. Upon emitting a particle an instance of this emitter is created and attached to the particle in reverse. Hence the orientation of the instance is opposite direction than the one the particle is traveling. As soon as the particle dies the trail instance is set to remove itself one the last particle died. You can set a controller index for the lifetime, mass, linear and angular velocity of the trail emitter. If the controller is set to a valid controller in the created child instance the given particle property is set as the controller value. Trail emitters and collision emitters can be used together if required. Here too make sure to not create too many particles
 + 
 +<WRAP center round info 90%> 
 +If the particle is moving at different velocities the density of the trail emitter varies. You can create a trail emitting the right amount of particles depending on the velocity using the **Trail Controllers**. Simply create a trail emitter with a single controller and set in the **Trail Controller** for **linear velocity** to the index of this controller (0 in this example). The value of the trail controller is now always set to the linear velocity of the particle it is attached to. Now use this controller on the **interval** parameter and you can control precisely the density of your trail or any other parameter as you see fit. The required interval can be easily calculated using overlap*(size/velocity). **Value** of the parameter acts as the overlap value which makes it easy to adjust the overall density. Calculate a bunch of values for different velocities inside the controller range and you have a basic curve keeping density equal. 
 +</WRAP> 
 + 
 +Types can have different simulation types. Using **particle** as **Simulation Type** simulates particles the default way. Using **ribbon** all generated particles are connected using a ribbon in the order they have been cast. Use [[gamedev:skinproperties|Skin Texture Properties]] to alter how the rendering is done. In general there is a strict separation between properties affecting rendering only and properties affecting also the physics part of particles. Later ones only are stored in the emitter types. Last simulation type is **beam** which renders a beam for each particle between the cast position and the final position which is the particle simulated over the entire lifetime. 
 + 
 +Using **Interval As Time** the usage of the **interval** parameter can be modified. By default the interval is used over time. Hence if the interval parameter for example resolves to 0.1 then a particle would be cast after 0.1 seconds. If **Interval As Time** is set to true though the usage changes to over distance instead of time. Hence with an interval value of 0.1 a particle would be cast after the emitter instance displaced by 0.1 meters from the last time a particle has been cast. This can be used for trail particles to have better control as well as for ribbons in connection with dynamically moving emitter instances.
  
 ^Name^Description^Type^Default^ ^Name^Description^Type^Default^
Line 53: Line 67:
 |Model Skin|Skin for the model to use. Allows to alter emission parameters depending on where a particle is emitted.|Skin|null| |Model Skin|Skin for the model to use. Allows to alter emission parameters depending on where a particle is emitted.|Skin|null|
 |Cast From|Determines from what element of the Model (if set) particles are emitted from.|{Vertex, Face, Volume}|Vertex| |Cast From|Determines from what element of the Model (if set) particles are emitted from.|{Vertex, Face, Volume}|Vertex|
 +|Simulation Type|How to simulate the particle emitter. Also defines how it is rendered.|{Particle, Ribbon, Beam}|Particle|
 +|Interval As Distance|Determines if the interval parameter is used over time (seconds) or over distance (meters).|boolean|False|
 |Trail Emitter|Emitter to use as the trail for particles.|ParticleEmitter|null| |Trail Emitter|Emitter to use as the trail for particles.|ParticleEmitter|null|
 +|Trail Controllers|Defines which controller (if any) in the trail emitter instance is set with particle parameters.|Int[]|-1|
 |Physics Size|Size in meters of the particle sphere used during physics.|Float|0.1| |Physics Size|Size in meters of the particle sphere used during physics.|Float|0.1|
 |Collision Response|Determines how particles react to collisions.|{Destroy, Physical, Custom}|Physical| |Collision Response|Determines how particles react to collisions.|{Destroy, Physical, Custom}|Physical|
Line 73: Line 90:
 EmitValue = ParamValue + ParamSpread * 0.5 * random() EmitValue = ParamValue + ParamSpread * 0.5 * random()
 RenderValue = EmitValue * CurveProgress( particle.lifetime )</code> RenderValue = EmitValue * CurveProgress( particle.lifetime )</code>
-This looks complex but is quite simple. Upon emitting a particle a random value between (**Value** - **Spread**/2)-(**Value** + **Spread**/2) is chosen whereas the value for **Value** and **Spread** are either the static values or sampled from **CurveValue** or **CurveSpread** depending if they have curve points and if **ControllerValue** or **ControllerSpread** points to a valid controller. During each update step this **EmitValue** is then multiplied by progress curve sampled over the particle lifetime. If there are no curve points in **Curve Progress** then 1 is used as the multiplication factor. Using controllers thus the user can influence the **Value** and **Spread** of individual particle parameters. See the listing of particle parameters for more information.+This looks complex but is quite simple. Upon emitting a particle a random value between (**Value** - **Spread**/2)-(**Value** + **Spread**/2) is chosen whereas the value for **Value** and **Spread** are either the static values or sampled from **CurveValue** or **CurveSpread** depending if they have curve points and if **ControllerValue** or **ControllerSpread** points to a valid controller. During each update step this **EmitValue** is then multiplied by **Curve Progress** sampled over the particle lifetime. If there are no curve points in **Curve Progress** then 1 is used as the multiplication factor. Using controllers thus the user can influence the **Value** and **Spread** of individual particle parameters. See the listing of particle parameters for more information.
  
 Curves are 2 dimensions bezier curves hence each point composes of 3 Vector2 values (point, left handle, right handle). Points are required to be sorted which the **CurveBezier** class takes care of. Curves are 2 dimensions bezier curves hence each point composes of 3 Vector2 values (point, left handle, right handle). Points are required to be sorted which the **CurveBezier** class takes care of.
Line 145: Line 162:
 Defines the emit direction for particles creating instances upon impact. If set to 0 the created instance is oriented along the normal of the impact surface. If set to 1 the created instance is oriented along the repel direction as calculated using roughness. Defines the emit direction for particles creating instances upon impact. If set to 0 the created instance is oriented along the normal of the impact surface. If set to 1 the created instance is oriented along the repel direction as calculated using roughness.
  
-====== Links ====== +====== Examples ====== 
-  * [[gamedev:main|Game Development Informations]] +{{ youtube>6rdYWmf1yZc?600x450 |Particle Beams Example Video}}
-  * [[:start|Main page]]+
gamedev/particleemitters.1316305202.txt.gz · Last modified: 2011/09/18 00:20 by dragonlord