class_particles.rst 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Particles.xml.
  6. .. _class_Particles:
  7. Particles
  8. =========
  9. **Inherits:** :ref:`GeometryInstance<class_GeometryInstance>` **<** :ref:`VisualInstance<class_VisualInstance>` **<** :ref:`CullInstance<class_CullInstance>` **<** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. GPU-based 3D particle emitter.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 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.
  15. 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.
  16. \ **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**.
  17. \ **Note:** On macOS, **Particles** rendering is much slower than :ref:`CPUParticles<class_CPUParticles>` due to transform feedback being implemented on the CPU instead of the GPU. Consider using :ref:`CPUParticles<class_CPUParticles>` instead when targeting macOS.
  18. \ **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.
  19. .. rst-class:: classref-introduction-group
  20. Tutorials
  21. ---------
  22. - :doc:`Controlling thousands of fish with Particles <../tutorials/performance/vertex_animation/controlling_thousands_of_fish>`
  23. - `Third Person Shooter Demo <https://godotengine.org/asset-library/asset/678>`__
  24. .. rst-class:: classref-reftable-group
  25. Properties
  26. ----------
  27. .. table::
  28. :widths: auto
  29. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  30. | :ref:`int<class_int>` | :ref:`amount<class_Particles_property_amount>` | ``8`` |
  31. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  32. | :ref:`DrawOrder<enum_Particles_DrawOrder>` | :ref:`draw_order<class_Particles_property_draw_order>` | ``0`` |
  33. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  34. | :ref:`Mesh<class_Mesh>` | :ref:`draw_pass_1<class_Particles_property_draw_pass_1>` | |
  35. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  36. | :ref:`Mesh<class_Mesh>` | :ref:`draw_pass_2<class_Particles_property_draw_pass_2>` | |
  37. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  38. | :ref:`Mesh<class_Mesh>` | :ref:`draw_pass_3<class_Particles_property_draw_pass_3>` | |
  39. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  40. | :ref:`Mesh<class_Mesh>` | :ref:`draw_pass_4<class_Particles_property_draw_pass_4>` | |
  41. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  42. | :ref:`int<class_int>` | :ref:`draw_passes<class_Particles_property_draw_passes>` | ``1`` |
  43. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  44. | :ref:`bool<class_bool>` | :ref:`emitting<class_Particles_property_emitting>` | ``true`` |
  45. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  46. | :ref:`float<class_float>` | :ref:`explosiveness<class_Particles_property_explosiveness>` | ``0.0`` |
  47. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  48. | :ref:`int<class_int>` | :ref:`fixed_fps<class_Particles_property_fixed_fps>` | ``0`` |
  49. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  50. | :ref:`bool<class_bool>` | :ref:`fract_delta<class_Particles_property_fract_delta>` | ``true`` |
  51. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  52. | :ref:`float<class_float>` | :ref:`lifetime<class_Particles_property_lifetime>` | ``1.0`` |
  53. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  54. | :ref:`bool<class_bool>` | :ref:`local_coords<class_Particles_property_local_coords>` | ``true`` |
  55. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  56. | :ref:`bool<class_bool>` | :ref:`one_shot<class_Particles_property_one_shot>` | ``false`` |
  57. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  58. | :ref:`float<class_float>` | :ref:`preprocess<class_Particles_property_preprocess>` | ``0.0`` |
  59. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  60. | :ref:`Material<class_Material>` | :ref:`process_material<class_Particles_property_process_material>` | |
  61. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  62. | :ref:`float<class_float>` | :ref:`randomness<class_Particles_property_randomness>` | ``0.0`` |
  63. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  64. | :ref:`float<class_float>` | :ref:`speed_scale<class_Particles_property_speed_scale>` | ``1.0`` |
  65. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  66. | :ref:`AABB<class_AABB>` | :ref:`visibility_aabb<class_Particles_property_visibility_aabb>` | ``AABB( -4, -4, -4, 8, 8, 8 )`` |
  67. +--------------------------------------------+--------------------------------------------------------------------+---------------------------------+
  68. .. rst-class:: classref-reftable-group
  69. Methods
  70. -------
  71. .. table::
  72. :widths: auto
  73. +-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`AABB<class_AABB>` | :ref:`capture_aabb<class_Particles_method_capture_aabb>` **(** **)** |const| |
  75. +-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`Mesh<class_Mesh>` | :ref:`get_draw_pass_mesh<class_Particles_method_get_draw_pass_mesh>` **(** :ref:`int<class_int>` pass **)** |const| |
  77. +-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  78. | void | :ref:`restart<class_Particles_method_restart>` **(** **)** |
  79. +-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  80. | void | :ref:`set_draw_pass_mesh<class_Particles_method_set_draw_pass_mesh>` **(** :ref:`int<class_int>` pass, :ref:`Mesh<class_Mesh>` mesh **)** |
  81. +-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  82. .. rst-class:: classref-section-separator
  83. ----
  84. .. rst-class:: classref-descriptions-group
  85. Signals
  86. -------
  87. .. _class_Particles_signal_finished:
  88. .. rst-class:: classref-signal
  89. **finished** **(** **)**
  90. Emitted when all active particles have finished processing. When :ref:`one_shot<class_Particles_property_one_shot>` is disabled, particles will process continuously, so this is never emitted.
  91. \ **Note:** Due to the particles being computed on the GPU there might be a delay before the signal gets emitted.
  92. .. rst-class:: classref-section-separator
  93. ----
  94. .. rst-class:: classref-descriptions-group
  95. Enumerations
  96. ------------
  97. .. _enum_Particles_DrawOrder:
  98. .. rst-class:: classref-enumeration
  99. enum **DrawOrder**:
  100. .. _class_Particles_constant_DRAW_ORDER_INDEX:
  101. .. rst-class:: classref-enumeration-constant
  102. :ref:`DrawOrder<enum_Particles_DrawOrder>` **DRAW_ORDER_INDEX** = ``0``
  103. Particles are drawn in the order emitted.
  104. .. _class_Particles_constant_DRAW_ORDER_LIFETIME:
  105. .. rst-class:: classref-enumeration-constant
  106. :ref:`DrawOrder<enum_Particles_DrawOrder>` **DRAW_ORDER_LIFETIME** = ``1``
  107. Particles are drawn in order of remaining lifetime.
  108. .. _class_Particles_constant_DRAW_ORDER_VIEW_DEPTH:
  109. .. rst-class:: classref-enumeration-constant
  110. :ref:`DrawOrder<enum_Particles_DrawOrder>` **DRAW_ORDER_VIEW_DEPTH** = ``2``
  111. Particles are drawn in order of depth.
  112. .. rst-class:: classref-section-separator
  113. ----
  114. .. rst-class:: classref-descriptions-group
  115. Constants
  116. ---------
  117. .. _class_Particles_constant_MAX_DRAW_PASSES:
  118. .. rst-class:: classref-constant
  119. **MAX_DRAW_PASSES** = ``4``
  120. Maximum number of draw passes supported.
  121. .. rst-class:: classref-section-separator
  122. ----
  123. .. rst-class:: classref-descriptions-group
  124. Property Descriptions
  125. ---------------------
  126. .. _class_Particles_property_amount:
  127. .. rst-class:: classref-property
  128. :ref:`int<class_int>` **amount** = ``8``
  129. .. rst-class:: classref-property-setget
  130. - void **set_amount** **(** :ref:`int<class_int>` value **)**
  131. - :ref:`int<class_int>` **get_amount** **(** **)**
  132. The number of particles emitted in one emission cycle (corresponding to the :ref:`lifetime<class_Particles_property_lifetime>`).
  133. \ **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>`.
  134. .. rst-class:: classref-item-separator
  135. ----
  136. .. _class_Particles_property_draw_order:
  137. .. rst-class:: classref-property
  138. :ref:`DrawOrder<enum_Particles_DrawOrder>` **draw_order** = ``0``
  139. .. rst-class:: classref-property-setget
  140. - void **set_draw_order** **(** :ref:`DrawOrder<enum_Particles_DrawOrder>` value **)**
  141. - :ref:`DrawOrder<enum_Particles_DrawOrder>` **get_draw_order** **(** **)**
  142. Particle draw order. Uses :ref:`DrawOrder<enum_Particles_DrawOrder>` values.
  143. .. rst-class:: classref-item-separator
  144. ----
  145. .. _class_Particles_property_draw_pass_1:
  146. .. rst-class:: classref-property
  147. :ref:`Mesh<class_Mesh>` **draw_pass_1**
  148. .. rst-class:: classref-property-setget
  149. - void **set_draw_pass_mesh** **(** :ref:`int<class_int>` pass, :ref:`Mesh<class_Mesh>` mesh **)**
  150. - :ref:`Mesh<class_Mesh>` **get_draw_pass_mesh** **(** :ref:`int<class_int>` pass **)** |const|
  151. :ref:`Mesh<class_Mesh>` that is drawn for the first draw pass.
  152. .. rst-class:: classref-item-separator
  153. ----
  154. .. _class_Particles_property_draw_pass_2:
  155. .. rst-class:: classref-property
  156. :ref:`Mesh<class_Mesh>` **draw_pass_2**
  157. .. rst-class:: classref-property-setget
  158. - void **set_draw_pass_mesh** **(** :ref:`int<class_int>` pass, :ref:`Mesh<class_Mesh>` mesh **)**
  159. - :ref:`Mesh<class_Mesh>` **get_draw_pass_mesh** **(** :ref:`int<class_int>` pass **)** |const|
  160. :ref:`Mesh<class_Mesh>` that is drawn for the second draw pass.
  161. .. rst-class:: classref-item-separator
  162. ----
  163. .. _class_Particles_property_draw_pass_3:
  164. .. rst-class:: classref-property
  165. :ref:`Mesh<class_Mesh>` **draw_pass_3**
  166. .. rst-class:: classref-property-setget
  167. - void **set_draw_pass_mesh** **(** :ref:`int<class_int>` pass, :ref:`Mesh<class_Mesh>` mesh **)**
  168. - :ref:`Mesh<class_Mesh>` **get_draw_pass_mesh** **(** :ref:`int<class_int>` pass **)** |const|
  169. :ref:`Mesh<class_Mesh>` that is drawn for the third draw pass.
  170. .. rst-class:: classref-item-separator
  171. ----
  172. .. _class_Particles_property_draw_pass_4:
  173. .. rst-class:: classref-property
  174. :ref:`Mesh<class_Mesh>` **draw_pass_4**
  175. .. rst-class:: classref-property-setget
  176. - void **set_draw_pass_mesh** **(** :ref:`int<class_int>` pass, :ref:`Mesh<class_Mesh>` mesh **)**
  177. - :ref:`Mesh<class_Mesh>` **get_draw_pass_mesh** **(** :ref:`int<class_int>` pass **)** |const|
  178. :ref:`Mesh<class_Mesh>` that is drawn for the fourth draw pass.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. _class_Particles_property_draw_passes:
  182. .. rst-class:: classref-property
  183. :ref:`int<class_int>` **draw_passes** = ``1``
  184. .. rst-class:: classref-property-setget
  185. - void **set_draw_passes** **(** :ref:`int<class_int>` value **)**
  186. - :ref:`int<class_int>` **get_draw_passes** **(** **)**
  187. The number of draw passes when rendering particles.
  188. .. rst-class:: classref-item-separator
  189. ----
  190. .. _class_Particles_property_emitting:
  191. .. rst-class:: classref-property
  192. :ref:`bool<class_bool>` **emitting** = ``true``
  193. .. rst-class:: classref-property-setget
  194. - void **set_emitting** **(** :ref:`bool<class_bool>` value **)**
  195. - :ref:`bool<class_bool>` **is_emitting** **(** **)**
  196. If ``true``, particles are being emitted.
  197. .. rst-class:: classref-item-separator
  198. ----
  199. .. _class_Particles_property_explosiveness:
  200. .. rst-class:: classref-property
  201. :ref:`float<class_float>` **explosiveness** = ``0.0``
  202. .. rst-class:: classref-property-setget
  203. - void **set_explosiveness_ratio** **(** :ref:`float<class_float>` value **)**
  204. - :ref:`float<class_float>` **get_explosiveness_ratio** **(** **)**
  205. Time ratio between each emission. If ``0``, particles are emitted continuously. If ``1``, all particles are emitted simultaneously.
  206. .. rst-class:: classref-item-separator
  207. ----
  208. .. _class_Particles_property_fixed_fps:
  209. .. rst-class:: classref-property
  210. :ref:`int<class_int>` **fixed_fps** = ``0``
  211. .. rst-class:: classref-property-setget
  212. - void **set_fixed_fps** **(** :ref:`int<class_int>` value **)**
  213. - :ref:`int<class_int>` **get_fixed_fps** **(** **)**
  214. 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.
  215. .. rst-class:: classref-item-separator
  216. ----
  217. .. _class_Particles_property_fract_delta:
  218. .. rst-class:: classref-property
  219. :ref:`bool<class_bool>` **fract_delta** = ``true``
  220. .. rst-class:: classref-property-setget
  221. - void **set_fractional_delta** **(** :ref:`bool<class_bool>` value **)**
  222. - :ref:`bool<class_bool>` **get_fractional_delta** **(** **)**
  223. If ``true``, results in fractional delta calculation which has a smoother particles display effect.
  224. .. rst-class:: classref-item-separator
  225. ----
  226. .. _class_Particles_property_lifetime:
  227. .. rst-class:: classref-property
  228. :ref:`float<class_float>` **lifetime** = ``1.0``
  229. .. rst-class:: classref-property-setget
  230. - void **set_lifetime** **(** :ref:`float<class_float>` value **)**
  231. - :ref:`float<class_float>` **get_lifetime** **(** **)**
  232. The amount of time each particle will exist (in seconds).
  233. .. rst-class:: classref-item-separator
  234. ----
  235. .. _class_Particles_property_local_coords:
  236. .. rst-class:: classref-property
  237. :ref:`bool<class_bool>` **local_coords** = ``true``
  238. .. rst-class:: classref-property-setget
  239. - void **set_use_local_coordinates** **(** :ref:`bool<class_bool>` value **)**
  240. - :ref:`bool<class_bool>` **get_use_local_coordinates** **(** **)**
  241. If ``true``, particles use the parent node's coordinate space. If ``false``, they use global coordinates.
  242. .. rst-class:: classref-item-separator
  243. ----
  244. .. _class_Particles_property_one_shot:
  245. .. rst-class:: classref-property
  246. :ref:`bool<class_bool>` **one_shot** = ``false``
  247. .. rst-class:: classref-property-setget
  248. - void **set_one_shot** **(** :ref:`bool<class_bool>` value **)**
  249. - :ref:`bool<class_bool>` **get_one_shot** **(** **)**
  250. If ``true``, only ``amount`` particles will be emitted.
  251. .. rst-class:: classref-item-separator
  252. ----
  253. .. _class_Particles_property_preprocess:
  254. .. rst-class:: classref-property
  255. :ref:`float<class_float>` **preprocess** = ``0.0``
  256. .. rst-class:: classref-property-setget
  257. - void **set_pre_process_time** **(** :ref:`float<class_float>` value **)**
  258. - :ref:`float<class_float>` **get_pre_process_time** **(** **)**
  259. Amount of time to preprocess the particles before animation starts. Lets you start the animation some time after particles have started emitting.
  260. .. rst-class:: classref-item-separator
  261. ----
  262. .. _class_Particles_property_process_material:
  263. .. rst-class:: classref-property
  264. :ref:`Material<class_Material>` **process_material**
  265. .. rst-class:: classref-property-setget
  266. - void **set_process_material** **(** :ref:`Material<class_Material>` value **)**
  267. - :ref:`Material<class_Material>` **get_process_material** **(** **)**
  268. :ref:`Material<class_Material>` for processing particles. Can be a :ref:`ParticlesMaterial<class_ParticlesMaterial>` or a :ref:`ShaderMaterial<class_ShaderMaterial>`.
  269. .. rst-class:: classref-item-separator
  270. ----
  271. .. _class_Particles_property_randomness:
  272. .. rst-class:: classref-property
  273. :ref:`float<class_float>` **randomness** = ``0.0``
  274. .. rst-class:: classref-property-setget
  275. - void **set_randomness_ratio** **(** :ref:`float<class_float>` value **)**
  276. - :ref:`float<class_float>` **get_randomness_ratio** **(** **)**
  277. Emission randomness ratio.
  278. .. rst-class:: classref-item-separator
  279. ----
  280. .. _class_Particles_property_speed_scale:
  281. .. rst-class:: classref-property
  282. :ref:`float<class_float>` **speed_scale** = ``1.0``
  283. .. rst-class:: classref-property-setget
  284. - void **set_speed_scale** **(** :ref:`float<class_float>` value **)**
  285. - :ref:`float<class_float>` **get_speed_scale** **(** **)**
  286. Speed scaling ratio. A value of ``0`` can be used to pause the particles.
  287. .. rst-class:: classref-item-separator
  288. ----
  289. .. _class_Particles_property_visibility_aabb:
  290. .. rst-class:: classref-property
  291. :ref:`AABB<class_AABB>` **visibility_aabb** = ``AABB( -4, -4, -4, 8, 8, 8 )``
  292. .. rst-class:: classref-property-setget
  293. - void **set_visibility_aabb** **(** :ref:`AABB<class_AABB>` value **)**
  294. - :ref:`AABB<class_AABB>` **get_visibility_aabb** **(** **)**
  295. 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.
  296. 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.
  297. \ **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.
  298. .. rst-class:: classref-section-separator
  299. ----
  300. .. rst-class:: classref-descriptions-group
  301. Method Descriptions
  302. -------------------
  303. .. _class_Particles_method_capture_aabb:
  304. .. rst-class:: classref-method
  305. :ref:`AABB<class_AABB>` **capture_aabb** **(** **)** |const|
  306. Returns the axis-aligned bounding box that contains all the particles that are active in the current frame.
  307. .. rst-class:: classref-item-separator
  308. ----
  309. .. _class_Particles_method_get_draw_pass_mesh:
  310. .. rst-class:: classref-method
  311. :ref:`Mesh<class_Mesh>` **get_draw_pass_mesh** **(** :ref:`int<class_int>` pass **)** |const|
  312. Returns the :ref:`Mesh<class_Mesh>` that is drawn at index ``pass``.
  313. .. rst-class:: classref-item-separator
  314. ----
  315. .. _class_Particles_method_restart:
  316. .. rst-class:: classref-method
  317. void **restart** **(** **)**
  318. Restarts the particle emission, clearing existing particles.
  319. .. rst-class:: classref-item-separator
  320. ----
  321. .. _class_Particles_method_set_draw_pass_mesh:
  322. .. rst-class:: classref-method
  323. void **set_draw_pass_mesh** **(** :ref:`int<class_int>` pass, :ref:`Mesh<class_Mesh>` mesh **)**
  324. Sets the :ref:`Mesh<class_Mesh>` that is drawn at index ``pass``.
  325. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  326. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  327. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  328. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`