particle_process_material_2d.rst 8.3 KB

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