class_particles.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Particles.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Particles:
  6. Particles
  7. =========
  8. **Inherits:** :ref:`GeometryInstance<class_GeometryInstance>` **<** :ref:`VisualInstance<class_VisualInstance>` **<** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. GPU-based 3D particle emitter.
  10. Description
  11. -----------
  12. 3D particle node used to create a variety of particle systems and effects. ``Particles`` features an emitter that generates some number of particles at a given rate.
  13. Use the ``process_material`` property to add a :ref:`ParticlesMaterial<class_ParticlesMaterial>` to configure particle appearance and behavior. Alternatively, you can add a :ref:`ShaderMaterial<class_ShaderMaterial>` which will be applied to all particles.
  14. **Note:** ``Particles`` only work when using the GLES3 renderer. If using the GLES2 renderer, use :ref:`CPUParticles<class_CPUParticles>` instead. You can convert ``Particles`` to :ref:`CPUParticles<class_CPUParticles>` by selecting the node, clicking the **Particles** menu at the top of the 3D editor viewport then choosing **Convert to CPUParticles**.
  15. **Note:** After working on a Particles node, remember to update its :ref:`visibility_aabb<class_Particles_property_visibility_aabb>` by selecting it, clicking the **Particles** menu at the top of the 3D editor viewport then choose **Generate Visibility AABB**. Otherwise, particles may suddenly disappear depending on the camera position and angle.
  16. Tutorials
  17. ---------
  18. - :doc:`../tutorials/3d/vertex_animation/controlling_thousands_of_fish`
  19. - `Third Person Shooter Demo <https://godotengine.org/asset-library/asset/678>`_
  20. Properties
  21. ----------
  22. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  23. | :ref:`int<class_int>` | :ref:`amount<class_Particles_property_amount>` | ``8`` |
  24. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  25. | :ref:`DrawOrder<enum_Particles_DrawOrder>` | :ref:`draw_order<class_Particles_property_draw_order>` | ``0`` |
  26. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  27. | :ref:`Mesh<class_Mesh>` | :ref:`draw_pass_1<class_Particles_property_draw_pass_1>` | |
  28. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  29. | :ref:`Mesh<class_Mesh>` | :ref:`draw_pass_2<class_Particles_property_draw_pass_2>` | |
  30. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  31. | :ref:`Mesh<class_Mesh>` | :ref:`draw_pass_3<class_Particles_property_draw_pass_3>` | |
  32. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  33. | :ref:`Mesh<class_Mesh>` | :ref:`draw_pass_4<class_Particles_property_draw_pass_4>` | |
  34. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  35. | :ref:`int<class_int>` | :ref:`draw_passes<class_Particles_property_draw_passes>` | ``1`` |
  36. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  37. | :ref:`bool<class_bool>` | :ref:`emitting<class_Particles_property_emitting>` | ``true`` |
  38. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  39. | :ref:`float<class_float>` | :ref:`explosiveness<class_Particles_property_explosiveness>` | ``0.0`` |
  40. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  41. | :ref:`int<class_int>` | :ref:`fixed_fps<class_Particles_property_fixed_fps>` | ``0`` |
  42. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`fract_delta<class_Particles_property_fract_delta>` | ``true`` |
  44. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  45. | :ref:`float<class_float>` | :ref:`lifetime<class_Particles_property_lifetime>` | ``1.0`` |
  46. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  47. | :ref:`bool<class_bool>` | :ref:`local_coords<class_Particles_property_local_coords>` | ``true`` |
  48. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  49. | :ref:`bool<class_bool>` | :ref:`one_shot<class_Particles_property_one_shot>` | ``false`` |
  50. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  51. | :ref:`float<class_float>` | :ref:`preprocess<class_Particles_property_preprocess>` | ``0.0`` |
  52. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  53. | :ref:`Material<class_Material>` | :ref:`process_material<class_Particles_property_process_material>` | |
  54. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  55. | :ref:`float<class_float>` | :ref:`randomness<class_Particles_property_randomness>` | ``0.0`` |
  56. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  57. | :ref:`float<class_float>` | :ref:`speed_scale<class_Particles_property_speed_scale>` | ``1.0`` |
  58. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  59. | :ref:`AABB<class_AABB>` | :ref:`visibility_aabb<class_Particles_property_visibility_aabb>` | ``AABB( -4, -4, -4, 8, 8, 8 )`` |
  60. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  61. Methods
  62. -------
  63. +-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`AABB<class_AABB>` | :ref:`capture_aabb<class_Particles_method_capture_aabb>` **(** **)** |const| |
  65. +-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`Mesh<class_Mesh>` | :ref:`get_draw_pass_mesh<class_Particles_method_get_draw_pass_mesh>` **(** :ref:`int<class_int>` pass **)** |const| |
  67. +-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`restart<class_Particles_method_restart>` **(** **)** |
  69. +-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  70. | void | :ref:`set_draw_pass_mesh<class_Particles_method_set_draw_pass_mesh>` **(** :ref:`int<class_int>` pass, :ref:`Mesh<class_Mesh>` mesh **)** |
  71. +-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  72. Enumerations
  73. ------------
  74. .. _enum_Particles_DrawOrder:
  75. .. _class_Particles_constant_DRAW_ORDER_INDEX:
  76. .. _class_Particles_constant_DRAW_ORDER_LIFETIME:
  77. .. _class_Particles_constant_DRAW_ORDER_VIEW_DEPTH:
  78. enum **DrawOrder**:
  79. - **DRAW_ORDER_INDEX** = **0** --- Particles are drawn in the order emitted.
  80. - **DRAW_ORDER_LIFETIME** = **1** --- Particles are drawn in order of remaining lifetime.
  81. - **DRAW_ORDER_VIEW_DEPTH** = **2** --- Particles are drawn in order of depth.
  82. Constants
  83. ---------
  84. .. _class_Particles_constant_MAX_DRAW_PASSES:
  85. - **MAX_DRAW_PASSES** = **4** --- Maximum number of draw passes supported.
  86. Property Descriptions
  87. ---------------------
  88. .. _class_Particles_property_amount:
  89. - :ref:`int<class_int>` **amount**
  90. +-----------+-------------------+
  91. | *Default* | ``8`` |
  92. +-----------+-------------------+
  93. | *Setter* | set_amount(value) |
  94. +-----------+-------------------+
  95. | *Getter* | get_amount() |
  96. +-----------+-------------------+
  97. The number of particles emitted in one emission cycle (corresponding to the :ref:`lifetime<class_Particles_property_lifetime>`).
  98. **Note:** Changing :ref:`amount<class_Particles_property_amount>` will reset the particle emission, therefore removing all particles that were already emitted before changing :ref:`amount<class_Particles_property_amount>`.
  99. ----
  100. .. _class_Particles_property_draw_order:
  101. - :ref:`DrawOrder<enum_Particles_DrawOrder>` **draw_order**
  102. +-----------+-----------------------+
  103. | *Default* | ``0`` |
  104. +-----------+-----------------------+
  105. | *Setter* | set_draw_order(value) |
  106. +-----------+-----------------------+
  107. | *Getter* | get_draw_order() |
  108. +-----------+-----------------------+
  109. Particle draw order. Uses :ref:`DrawOrder<enum_Particles_DrawOrder>` values.
  110. ----
  111. .. _class_Particles_property_draw_pass_1:
  112. - :ref:`Mesh<class_Mesh>` **draw_pass_1**
  113. +----------+---------------------------+
  114. | *Setter* | set_draw_pass_mesh(value) |
  115. +----------+---------------------------+
  116. | *Getter* | get_draw_pass_mesh() |
  117. +----------+---------------------------+
  118. :ref:`Mesh<class_Mesh>` that is drawn for the first draw pass.
  119. ----
  120. .. _class_Particles_property_draw_pass_2:
  121. - :ref:`Mesh<class_Mesh>` **draw_pass_2**
  122. +----------+---------------------------+
  123. | *Setter* | set_draw_pass_mesh(value) |
  124. +----------+---------------------------+
  125. | *Getter* | get_draw_pass_mesh() |
  126. +----------+---------------------------+
  127. :ref:`Mesh<class_Mesh>` that is drawn for the second draw pass.
  128. ----
  129. .. _class_Particles_property_draw_pass_3:
  130. - :ref:`Mesh<class_Mesh>` **draw_pass_3**
  131. +----------+---------------------------+
  132. | *Setter* | set_draw_pass_mesh(value) |
  133. +----------+---------------------------+
  134. | *Getter* | get_draw_pass_mesh() |
  135. +----------+---------------------------+
  136. :ref:`Mesh<class_Mesh>` that is drawn for the third draw pass.
  137. ----
  138. .. _class_Particles_property_draw_pass_4:
  139. - :ref:`Mesh<class_Mesh>` **draw_pass_4**
  140. +----------+---------------------------+
  141. | *Setter* | set_draw_pass_mesh(value) |
  142. +----------+---------------------------+
  143. | *Getter* | get_draw_pass_mesh() |
  144. +----------+---------------------------+
  145. :ref:`Mesh<class_Mesh>` that is drawn for the fourth draw pass.
  146. ----
  147. .. _class_Particles_property_draw_passes:
  148. - :ref:`int<class_int>` **draw_passes**
  149. +-----------+------------------------+
  150. | *Default* | ``1`` |
  151. +-----------+------------------------+
  152. | *Setter* | set_draw_passes(value) |
  153. +-----------+------------------------+
  154. | *Getter* | get_draw_passes() |
  155. +-----------+------------------------+
  156. The number of draw passes when rendering particles.
  157. ----
  158. .. _class_Particles_property_emitting:
  159. - :ref:`bool<class_bool>` **emitting**
  160. +-----------+---------------------+
  161. | *Default* | ``true`` |
  162. +-----------+---------------------+
  163. | *Setter* | set_emitting(value) |
  164. +-----------+---------------------+
  165. | *Getter* | is_emitting() |
  166. +-----------+---------------------+
  167. If ``true``, particles are being emitted.
  168. ----
  169. .. _class_Particles_property_explosiveness:
  170. - :ref:`float<class_float>` **explosiveness**
  171. +-----------+--------------------------------+
  172. | *Default* | ``0.0`` |
  173. +-----------+--------------------------------+
  174. | *Setter* | set_explosiveness_ratio(value) |
  175. +-----------+--------------------------------+
  176. | *Getter* | get_explosiveness_ratio() |
  177. +-----------+--------------------------------+
  178. Time ratio between each emission. If ``0``, particles are emitted continuously. If ``1``, all particles are emitted simultaneously.
  179. ----
  180. .. _class_Particles_property_fixed_fps:
  181. - :ref:`int<class_int>` **fixed_fps**
  182. +-----------+----------------------+
  183. | *Default* | ``0`` |
  184. +-----------+----------------------+
  185. | *Setter* | set_fixed_fps(value) |
  186. +-----------+----------------------+
  187. | *Getter* | get_fixed_fps() |
  188. +-----------+----------------------+
  189. The particle system's frame rate is fixed to a value. For instance, changing the value to 2 will make the particles render at 2 frames per second. Note this does not slow down the simulation of the particle system itself.
  190. ----
  191. .. _class_Particles_property_fract_delta:
  192. - :ref:`bool<class_bool>` **fract_delta**
  193. +-----------+-----------------------------+
  194. | *Default* | ``true`` |
  195. +-----------+-----------------------------+
  196. | *Setter* | set_fractional_delta(value) |
  197. +-----------+-----------------------------+
  198. | *Getter* | get_fractional_delta() |
  199. +-----------+-----------------------------+
  200. If ``true``, results in fractional delta calculation which has a smoother particles display effect.
  201. ----
  202. .. _class_Particles_property_lifetime:
  203. - :ref:`float<class_float>` **lifetime**
  204. +-----------+---------------------+
  205. | *Default* | ``1.0`` |
  206. +-----------+---------------------+
  207. | *Setter* | set_lifetime(value) |
  208. +-----------+---------------------+
  209. | *Getter* | get_lifetime() |
  210. +-----------+---------------------+
  211. The amount of time each particle will exist (in seconds).
  212. ----
  213. .. _class_Particles_property_local_coords:
  214. - :ref:`bool<class_bool>` **local_coords**
  215. +-----------+----------------------------------+
  216. | *Default* | ``true`` |
  217. +-----------+----------------------------------+
  218. | *Setter* | set_use_local_coordinates(value) |
  219. +-----------+----------------------------------+
  220. | *Getter* | get_use_local_coordinates() |
  221. +-----------+----------------------------------+
  222. If ``true``, particles use the parent node's coordinate space. If ``false``, they use global coordinates.
  223. ----
  224. .. _class_Particles_property_one_shot:
  225. - :ref:`bool<class_bool>` **one_shot**
  226. +-----------+---------------------+
  227. | *Default* | ``false`` |
  228. +-----------+---------------------+
  229. | *Setter* | set_one_shot(value) |
  230. +-----------+---------------------+
  231. | *Getter* | get_one_shot() |
  232. +-----------+---------------------+
  233. If ``true``, only ``amount`` particles will be emitted.
  234. ----
  235. .. _class_Particles_property_preprocess:
  236. - :ref:`float<class_float>` **preprocess**
  237. +-----------+-----------------------------+
  238. | *Default* | ``0.0`` |
  239. +-----------+-----------------------------+
  240. | *Setter* | set_pre_process_time(value) |
  241. +-----------+-----------------------------+
  242. | *Getter* | get_pre_process_time() |
  243. +-----------+-----------------------------+
  244. Amount of time to preprocess the particles before animation starts. Lets you start the animation some time after particles have started emitting.
  245. ----
  246. .. _class_Particles_property_process_material:
  247. - :ref:`Material<class_Material>` **process_material**
  248. +----------+-----------------------------+
  249. | *Setter* | set_process_material(value) |
  250. +----------+-----------------------------+
  251. | *Getter* | get_process_material() |
  252. +----------+-----------------------------+
  253. :ref:`Material<class_Material>` for processing particles. Can be a :ref:`ParticlesMaterial<class_ParticlesMaterial>` or a :ref:`ShaderMaterial<class_ShaderMaterial>`.
  254. ----
  255. .. _class_Particles_property_randomness:
  256. - :ref:`float<class_float>` **randomness**
  257. +-----------+-----------------------------+
  258. | *Default* | ``0.0`` |
  259. +-----------+-----------------------------+
  260. | *Setter* | set_randomness_ratio(value) |
  261. +-----------+-----------------------------+
  262. | *Getter* | get_randomness_ratio() |
  263. +-----------+-----------------------------+
  264. Emission randomness ratio.
  265. ----
  266. .. _class_Particles_property_speed_scale:
  267. - :ref:`float<class_float>` **speed_scale**
  268. +-----------+------------------------+
  269. | *Default* | ``1.0`` |
  270. +-----------+------------------------+
  271. | *Setter* | set_speed_scale(value) |
  272. +-----------+------------------------+
  273. | *Getter* | get_speed_scale() |
  274. +-----------+------------------------+
  275. Speed scaling ratio. A value of ``0`` can be used to pause the particles.
  276. ----
  277. .. _class_Particles_property_visibility_aabb:
  278. - :ref:`AABB<class_AABB>` **visibility_aabb**
  279. +-----------+---------------------------------+
  280. | *Default* | ``AABB( -4, -4, -4, 8, 8, 8 )`` |
  281. +-----------+---------------------------------+
  282. | *Setter* | set_visibility_aabb(value) |
  283. +-----------+---------------------------------+
  284. | *Getter* | get_visibility_aabb() |
  285. +-----------+---------------------------------+
  286. The :ref:`AABB<class_AABB>` that determines the node's region which needs to be visible on screen for the particle system to be active.
  287. Grow the box if particles suddenly appear/disappear when the node enters/exits the screen. The :ref:`AABB<class_AABB>` can be grown via code or with the **Particles → Generate AABB** editor tool.
  288. **Note:** If the :ref:`ParticlesMaterial<class_ParticlesMaterial>` in use is configured to cast shadows, you may want to enlarge this AABB to ensure the shadow is updated when particles are off-screen.
  289. Method Descriptions
  290. -------------------
  291. .. _class_Particles_method_capture_aabb:
  292. - :ref:`AABB<class_AABB>` **capture_aabb** **(** **)** |const|
  293. Returns the axis-aligned bounding box that contains all the particles that are active in the current frame.
  294. ----
  295. .. _class_Particles_method_get_draw_pass_mesh:
  296. - :ref:`Mesh<class_Mesh>` **get_draw_pass_mesh** **(** :ref:`int<class_int>` pass **)** |const|
  297. Returns the :ref:`Mesh<class_Mesh>` that is drawn at index ``pass``.
  298. ----
  299. .. _class_Particles_method_restart:
  300. - void **restart** **(** **)**
  301. Restarts the particle emission, clearing existing particles.
  302. ----
  303. .. _class_Particles_method_set_draw_pass_mesh:
  304. - void **set_draw_pass_mesh** **(** :ref:`int<class_int>` pass, :ref:`Mesh<class_Mesh>` mesh **)**
  305. Sets the :ref:`Mesh<class_Mesh>` that is drawn at index ``pass``.
  306. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  307. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  308. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`