class_particles.rst 20 KB

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