particle_process_material_2d.rst 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. .. _doc_particle_process_material_2d:
  2. ParticleProcessMaterial 2D Usage
  3. ================================
  4. Process material properties
  5. ---------------------------
  6. The properties in this material control how particles behave and change over their lifetime.
  7. A lot of them have ``Min``, ``Max``, and ``Curve`` values that allow you to fine-tune
  8. their behavior. The relationship between these values is this: When a particle is spawned,
  9. the property is set with a random value between ``Min`` and ``Max``. If ``Min`` and ``Max`` are
  10. the same, the value will always be the same for every particle. If the ``Curve`` is also set,
  11. the value of the property will be multiplied by the value of the curve at the current point
  12. in a particle's lifetime. Use the curve to change a property over the particle lifetime. Very
  13. complex behavior can be expressed this way.
  14. .. note::
  15. This page covers how to use ParticleProcessMaterial for 2D scenes specifically.
  16. For information on how to use it in a 3D scene see :ref:`doc_process_material_properties`.
  17. Lifetime Randomness
  18. ~~~~~~~~~~~~~~~~~~~
  19. The ``Lifetime Randomness`` property controls how much randomness to apply to each particle's
  20. lifetime. A value of ``0`` means there is no randomness at all and all particles live for
  21. the same amount of time, set by the :ref:`Lifetime <doc_3d_particles_properties_time>` property. A value of ``1`` means
  22. that a particle's lifetime is completely random within the range of [0.0, ``Lifetime``].
  23. Particle Flags
  24. --------------
  25. Spawn
  26. -----
  27. Angle
  28. ~~~~~
  29. Determines the initial angle of the particle (in degrees). This parameter
  30. is mostly useful randomized.
  31. .. image:: img/paranim11.gif
  32. Velocity
  33. ~~~~~~~~
  34. Direction
  35. ^^^^^^^^^
  36. This is the base direction at which particles emit. The default is
  37. ``Vector3(1, 0, 0)`` which makes particles emit to the right. However,
  38. with the default gravity settings, particles will go straight down.
  39. .. image:: img/direction1.png
  40. For this property to be noticeable, you need an *initial velocity* greater
  41. than 0. Here, we set the initial velocity to 40. You'll notice that
  42. particles emit toward the right, then go down because of gravity.
  43. .. image:: img/direction2.png
  44. Spread
  45. ^^^^^^
  46. This parameter is the angle in degrees which will be randomly added in
  47. either direction to the base ``Direction``. A spread of ``180`` will emit
  48. in all directions (+/- 180). For spread to do anything the "Initial Velocity"
  49. parameter must be greater than 0.
  50. .. image:: img/paranim3.gif
  51. Flatness
  52. ^^^^^^^^
  53. This property is only useful for 3D particles.
  54. Initial Velocity
  55. ^^^^^^^^^^^^^^^^
  56. Initial velocity is the speed at which particles will be emitted (in
  57. pixels/sec). Speed might later be modified by gravity or other
  58. accelerations (as described further below).
  59. .. image:: img/paranim4.gif
  60. Animated Velocity
  61. -----------------
  62. Angular Velocity
  63. ~~~~~~~~~~~~~~~~
  64. Angular velocity is the speed at which particles rotate around their center
  65. (in degrees/sec).
  66. .. image:: img/paranim5.gif
  67. Orbit Velocity
  68. ~~~~~~~~~~~~~~
  69. Orbit velocity is used to make particles turn around their center.
  70. .. image:: img/paranim6.gif
  71. Accelerations
  72. -------------
  73. Gravity
  74. ~~~~~~~
  75. The gravity applied to every particle.
  76. .. image:: img/paranim7.gif
  77. Linear Acceleration
  78. ~~~~~~~~~~~~~~~~~~~
  79. The linear acceleration applied to each particle.
  80. Radial Acceleration
  81. ~~~~~~~~~~~~~~~~~~~
  82. If this acceleration is positive, particles are accelerated away from
  83. the center. If negative, they are absorbed towards it.
  84. .. image:: img/paranim8.gif
  85. Tangential Acceleration
  86. ~~~~~~~~~~~~~~~~~~~~~~~
  87. This acceleration will use the tangent vector to the center. Combining
  88. with radial acceleration can do nice effects.
  89. .. image:: img/paranim9.gif
  90. Damping
  91. ~~~~~~~
  92. Damping applies friction to the particles, forcing them to stop. It is
  93. especially useful for sparks or explosions, which usually begin with a
  94. high linear velocity and then stop as they fade.
  95. .. image:: img/paranim10.gif
  96. Display
  97. -------
  98. Scale
  99. ~~~~~
  100. Determines the initial scale of the particles.
  101. .. image:: img/paranim12.gif
  102. Color Curves
  103. ~~~~~~~~~~~~
  104. Color
  105. ^^^^^
  106. Used to change the color of the particles being emitted.
  107. Hue Variation
  108. ~~~~~~~~~~~~~
  109. The ``Variation`` value sets the initial hue variation applied to each
  110. particle. The ``Variation Random`` value controls the hue variation
  111. randomness ratio.
  112. .. _doc_particle_systems_2d_animation:
  113. Animation
  114. ~~~~~~~~~
  115. .. note::
  116. Particle flipbook animation is only effective if the CanvasItemMaterial used
  117. on the GPUParticles2D or CPUParticles2D node has been
  118. :ref:`configured accordingly <doc_particle_systems_2d_using_flipbook>`.
  119. To set up the particle flipbook for linear playback, set the **Speed Min** and **Speed Max** values to 1:
  120. .. figure:: img/particles_flipbook_configure_animation_speed.webp
  121. :align: center
  122. :alt: Setting up particle animation for playback during the particle's lifetime
  123. Setting up particle animation for playback during the particle's lifetime
  124. By default, looping is disabled. If the particle is done playing before its
  125. lifetime ends, the particle will keep using the flipbook's last frame (which may
  126. be fully transparent depending on how the flipbook texture is designed). If
  127. looping is enabled, the animation will loop back to the first frame and resume
  128. playing.
  129. Depending on how many images your sprite sheet contains and for how long your
  130. particle is alive, the animation might not look smooth. The relationship between
  131. particle lifetime, animation speed, and number of images in the sprite sheet is
  132. this:
  133. .. note::
  134. At an animation speed of ``1.0``, the animation will reach the last image
  135. in the sequence just as the particle's lifetime ends.
  136. .. math::
  137. Animation\ FPS = \frac{Number\ of\ images}{Lifetime}
  138. If you wish the particle flipbook to be used as a source of random particle
  139. textures for every particle, keep the speed values at 0 and set **Offset Max**
  140. to 1 instead:
  141. .. figure:: img/particles_flipbook_configure_animation_offset.webp
  142. :align: center
  143. :alt: Setting up particle animation for random offset on emission
  144. Setting up particle animation for random offset on emission
  145. Note that the GPUParticles2D node's **Fixed FPS** also affects animation
  146. playback. For smooth animation playback, it's recommended to set it to 0 so that
  147. the particle is simulated on every rendered frame. If this is not an option for
  148. your use case, set **Fixed FPS** to be equal to the effective framerate used by
  149. the flipbook animation (see above for the formula).
  150. Emission Shapes
  151. ---------------
  152. ParticleProcessMaterials allow you to set an Emission Mask, which dictates
  153. the area and direction in which particles are emitted.
  154. These can be generated from textures in your project.
  155. Ensure that a ParticleProcessMaterial is set, and the GPUParticles2D node is selected.
  156. A "Particles" menu should appear in the Toolbar:
  157. .. image:: img/emission_shapes1.webp
  158. Open it and select "Load Emission Mask":
  159. .. image:: img/emission_shapes2.webp
  160. Then select which texture you want to use as your mask:
  161. .. image:: img/emission_shapes3.webp
  162. A dialog box with several settings will appear.
  163. Emission Mask
  164. ~~~~~~~~~~~~~
  165. Three types of emission masks can be generated from a texture:
  166. - Solid Pixels: Particles will spawn from any area of the texture,
  167. excluding transparent areas.
  168. .. image:: img/emission_mask_solid.gif
  169. - Border Pixels: Particles will spawn from the outer edges of the texture.
  170. .. image:: img/emission_mask_border.gif
  171. - Directed Border Pixels: Similar to Border Pixels, but adds extra
  172. information to the mask to give particles the ability to emit away
  173. from the borders. Note that an ``Initial Velocity`` will need to
  174. be set in order to utilize this.
  175. .. image:: img/emission_mask_directed_border.gif
  176. Emission Colors
  177. ~~~~~~~~~~~~~~~
  178. ``Capture from Pixel`` will cause the particles to inherit the color of the mask at their spawn points.
  179. Once you click "OK", the mask will be generated and set to the
  180. ParticleProcessMaterial, under ``Spawn`` and then ``Position``
  181. .. image:: img/emission_shapes4.webp
  182. All of the values within this section have been automatically generated by the
  183. "Load Emission Mask" menu, so they should generally be left alone.
  184. .. note:: An image should not be added to ``Point Texture`` or ``Color Texture`` directly.
  185. The "Load Emission Mask" menu should always be used instead.