process_material_properties.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. .. _doc_process_material_properties:
  2. Process material properties
  3. ---------------------------
  4. .. figure:: img/particle_minmaxcurve.webp
  5. :alt: ParticleProcessMaterial properties
  6. :align: right
  7. Min, max, and curve properties
  8. The properties in this material control how particles behave and change over their lifetime.
  9. A lot of them have ``Min``, ``Max``, and ``Curve`` values that allow you to fine-tune
  10. their behavior. The relationship between these values is this: When a particle is spawned,
  11. the property is set with a random value between ``Min`` and ``Max``. If ``Min`` and ``Max`` are
  12. the same, the value will always be the same for every particle. If the ``Curve`` is also set,
  13. the value of the property will be multiplied by the value of the curve at the current point
  14. in a particle's lifetime. Use the curve to change a property over the particle lifetime. Very
  15. complex behavior can be expressed this way.
  16. .. note::
  17. This page covers how to use ParticleProcessMaterial for 3D scenes specifically.
  18. For information on how to use it in a 2D Scene see :ref:`doc_particle_process_material_2d`.
  19. Time
  20. ~~~~
  21. The ``Lifetime Randomness`` property controls how much randomness to apply to each particle's
  22. lifetime. A value of ``0`` means there is no randomness at all and all particles live for
  23. the same amount of time, set by the :ref:`Lifetime <doc_3d_particles_properties_time>` property. A value of ``1`` means
  24. that a particle's lifetime is completely random within the range of [0.0, ``Lifetime``].
  25. Particle flags
  26. --------------
  27. The ``Align Y`` property aligns each particle's Y-axis with its velocity. Enabling this
  28. property is the same as setting the :ref:`Transform Align <doc_3d_particles_properties_draw>` property to
  29. ``Y to Velocity``.
  30. The ``Rotate Y`` property works with the properties in the `Angle <#angle>`__ and
  31. `Angular Velocity <#angular-velocity>`__ groups to control particle rotation. ``Rotate Y``
  32. has to be enabled if you want to apply any rotation to particles. The exception to this
  33. is any particle that uses the :ref:`Standard Material <doc_standard_material_3d>`
  34. where the ``Billboard`` property is set to ``Particle Billboard``. In that case, particles
  35. rotate even without ``Rotate Y`` enabled.
  36. When the ``Disable Z`` property is enabled, particles will not move along the Z-axis.
  37. Whether that is going to be the particle system's local Z-axis or the world Z-axis is
  38. determined by the :ref:`Local Coords <doc_3d_particles_properties_draw>` property.
  39. The ``Damping as Friction`` property changes the behavior of damping from a constant
  40. deceleration to a deceleration based on speed.
  41. Spawn
  42. -----
  43. .. _doc_process_material_properties_shapes:
  44. Emission shape
  45. ~~~~~~~~~~~~~~
  46. Particles can emit from a single point in space or in a way that they fill out a shape.
  47. The ``Shape`` property controls that shape. ``Point`` is the default value. All
  48. particles emit from a single point in the center of the particle system. When set to ``Sphere``
  49. or ``Box``, particles emit in a way that they fill out a sphere or a box shape evenly.
  50. You have full control over the size of these shapes. ``Sphere Surface`` works like ``Sphere``,
  51. but instead of filling it out, all particles spawn on the sphere's surface.
  52. .. figure:: img/particle_shapes_simple.webp
  53. :alt: Simple particle emission shapes
  54. Particles emitting from a point (left), in a sphere (middle), and in a box (right)
  55. .. figure:: img/particle_ring.webp
  56. :alt: Ring-shaped particle system
  57. :align: right
  58. A ring-shaped particle system
  59. The ``Ring`` emission shape makes particles emit in the shape of a ring. You can control the ring's
  60. direction by changing the ``Ring Axis`` property. ``Ring Height`` controls the thickness
  61. of the ring along its axis. ``Ring Radius`` and ``Ring Inner Radius`` control how wide
  62. the ring is and how large the hole in the middle should be. The image shows a particle
  63. system with a radius of ``2`` and an inner radius of ``1.5``, the axis points along the
  64. global Z-axis.
  65. In addition to these relatively simple shapes, you can select the ``Points`` or
  66. ``Directed Points`` option to create highly complex emission shapes. See the
  67. :ref:`Complex emission shapes <doc_3d_particles_complex_shapes>` section for a detailed
  68. explanation of how to set these up.
  69. Angle
  70. ~~~~~
  71. The ``Angle`` property controls a particle's starting rotation `as described above <#process-material-properties>`__.
  72. In order to have an actual effect on the particle, you have to enable one of two properties: `Rotate Y <#particle-flags>`__
  73. rotates the particle around the particle system's Y-axis. The ``Billboard`` property in
  74. the :ref:`Standard Material <doc_standard_material_3d>`, if it is set to ``Particle Billboard``, rotates
  75. the particle around the axis that points from the particle to the camera.
  76. Direction
  77. ~~~~~~~~~
  78. .. note::
  79. The ``Direction`` property alone is not enough to see any particle movement. Whatever
  80. values you set here only take effect once velocity or acceleration properties are set, too.
  81. The ``Direction`` property is a vector that controls each particle's direction of movement
  82. at the moment it is spawned. A value of ``(X=1,Y=0,Z=0)`` would make all particles move
  83. sideways along the X-axis. For something like a fountain where particles shoot out up in the
  84. air, a value of ``(X=0,Y=1,Z=0)`` would be a good starting point.
  85. .. figure:: img/particle_direction.webp
  86. :alt: Different values for particle direction
  87. Different direction values: Y-axis only (left), equal values for X and Y (middle), X and Y with gravity enabled (right)
  88. After setting a direction, you will notice that all particles move in the same direction in
  89. a straight line. The ``Spread`` property adds some variation and randomness to each particle's
  90. direction. The higher the value, the stronger the deviation from the original path. A value
  91. of ``0`` means there is no spread at all while a value of ``180`` makes particles shoot out in
  92. every direction. You could use this for something like pieces of debris during an explosion effect.
  93. .. figure:: img/particle_spread.webp
  94. :alt: Different values for particle spread
  95. No spread (left), 45 degree angle (middle), full 180 degrees (right)
  96. The ``Flatness`` property limits the spread along the Y-axis. A value of ``0`` means there
  97. is no limit and a value of ``1`` will eliminate all particle movement along the Y-axis. The
  98. particles will spread out completely "flat".
  99. You won't see any actual movement until you also set some values for the velocity and
  100. acceleration properties below, so let's take a look at those next.
  101. Initial velocity
  102. ~~~~~~~~~~~~~~~~
  103. While the ``Direction`` property controls a particle's movement direction, the ``Initial Velocity``
  104. controls how fast it goes. It's separated into ``Velocity Min`` and ``Velocity Max``, both
  105. set to ``0`` by default, which is why you don't see any movement initially. As soon as you set
  106. values for either of these properties `as described above <#process-material-properties>`__, the
  107. particles begin to move. The direction is multiplied by these values, so you can make particles
  108. move in the opposite direction by setting a negative velocity.
  109. Accelerations
  110. -------------
  111. Gravity
  112. ~~~~~~~
  113. The next few property groups work closely together to control particle movement and rotation.
  114. ``Gravity`` drags particles in the direction it points at, which is straight down at the strength
  115. of Earth's gravity by default. Gravity affects all particle movement.
  116. If your game uses physics and the world's gravity can change at runtime, you can use this property
  117. to keep the game's gravity in sync with particle gravity. A ``Gravity`` value of ``(X=0,Y=0,Z=0)`` means
  118. no particle will ever move at all if none of the other movement properties are set.
  119. .. figure:: img/particle_gravity.webp
  120. :alt: Different values for particle gravity
  121. Left\: (X=0,Y=-9.8,Z=0), middle\: (X=0,Y=9.8,Z=0), right\: (X=4,Y=2,Z=0).
  122. Angular velocity
  123. ~~~~~~~~~~~~~~~~
  124. ``Angular Velocity`` controls a particle's speed of rotation `as described above <#process-material-properties>`__.
  125. You can reverse the direction by using negative numbers for ``Velocity Min`` or ``Velocity Max``. Like the
  126. `Angle <#angle>`__ property, the rotation will only be visible if the `Rotate Y <#particle-flags>`__ flag is set
  127. or the ``Particle Billboard`` mode is selected in the :ref:`Standard Material <doc_standard_material_3d>`.
  128. .. note::
  129. The `Damping <#damping>`__ property has no effect on the angular velocity.
  130. Linear acceleration
  131. ~~~~~~~~~~~~~~~~~~~
  132. A particle's velocity is a constant value: once it's set, it doesn't change and the particle will
  133. always move at the same speed. You can use the ``Linear Accel`` property to
  134. change the speed of movement over a particle's lifetime `as described above <#process-material-properties>`__.
  135. Positive values will speed up the particle and make it move faster. Negative values will slow it
  136. down until it stops and starts moving in the other direction.
  137. .. figure:: img/particle_accel_linear.webp
  138. :alt: Different values for particle linear acceleration
  139. Negative (top) and positive (bottom) linear acceleration
  140. It's important to keep in mind that when we change acceleration, we're not changing the velocity
  141. directly, we're changing the *change* in velocity. A value of ``0`` on the acceleration curve
  142. does not stop the particle's movement, it stops the change in the particle's movement. Whatever
  143. its velocity was at that moment, it will keep moving at that velocity until the acceleration is
  144. changed again.
  145. Radial acceleration
  146. ~~~~~~~~~~~~~~~~~~~
  147. The ``Radial Accel`` property adds a gravity-like force to all particles, with the origin
  148. of that force at the particle system's current location. Negative values make particles move
  149. towards the center, like the force of gravity from a planet on objects in its orbit. Positive
  150. values make particles move away from the center.
  151. .. figure:: img/particle_accel_radial.webp
  152. :alt: Different values for particle radial acceleration
  153. Negative (left) and positive (right) radial acceleration
  154. Tangential acceleration
  155. ~~~~~~~~~~~~~~~~~~~~~~~
  156. .. figure:: img/particle_tangent.webp
  157. :alt: Tangents on a circle
  158. :align: right
  159. Tangents on a circle
  160. This property adds particle acceleration in the direction of the tangent to a circle on the particle
  161. system's XZ-plane with the origin at the system's center and a radius the distance between each
  162. particle's current location and the system's center projected onto that plane.
  163. Let's unpack that.
  164. A tangent to a circle is a straight line that "touches" the circle in a right angle to the circle's
  165. radius at the touch point. A circle on the particle system's XZ-plane is the circle that you see
  166. when you look straight down at the particle system from above.
  167. .. figure:: img/particle_accel_tangent.webp
  168. :alt: Tangential acceleration from above
  169. :align: right
  170. Tangential acceleration from above
  171. ``Tangential Accel`` is always limited to that plane and never move particles along the system's Y-axis.
  172. A particle's location is enough to define such a circle where the distance to the system's center is
  173. the radius if we ignore the vector's Y component.
  174. The ``Tangential Accel`` property will make particles orbit the particle system's center, but the
  175. radius will increase constantly. Viewed from above, particles will move away from the center
  176. in a spiral. Negative values reverse the direction.
  177. Damping
  178. ~~~~~~~
  179. The ``Damping`` property gradually stops all movement. Each frame, a particle's movement
  180. is slowed down a little unless the total acceleration is greater than the damping effect. If
  181. it isn't, the particle will keep slowing down until it doesn't move at all. The greater the value, the less
  182. time it takes to bring particles to a complete halt.
  183. Attractor interaction
  184. ~~~~~~~~~~~~~~~~~~~~~
  185. If you want the particle system to interact with :ref:`particle attractors <doc_3d_particles_attractors>`,
  186. you have to check the ``Enabled`` property. When it is disabled, the particle system
  187. ignores all particle attractors.
  188. Display
  189. -------
  190. Scale
  191. ~~~~~
  192. ``Scale`` controls a particle's size `as described above <#process-material-properties>`__. You can set
  193. different values for ``Scale Min`` and ``Scale Max`` to randomize each particle's size. Negative values
  194. are not allowed, so you won't be able to flip particles with this property. If you emit particles as
  195. billboards, the ``Keep Size`` property on the :ref:`Standard Material <doc_standard_material_3d>`
  196. in your draw passes has to be enabled for any scaling to have an effect.
  197. Color
  198. ~~~~~
  199. The ``Color`` property controls a particle's initial color. It will have an effect only after the
  200. ``Use As Albedo`` property in the ``Vertex Color`` group of the :ref:`Standard Material <doc_standard_material_3d>`
  201. is enabled. This property is multiplied with color coming from the particle material's
  202. own ``Color`` or ``Texture`` property.
  203. .. figure:: img/particle_ramp.webp
  204. :alt: Particle color ramp
  205. :align: right
  206. Setting up a color ramp
  207. There are two ``Ramp`` properties in the ``Color`` group. These allow you to define a range of colors
  208. that are used to set the particle's color. The ``Color Ramp`` property changes a particle's color
  209. over the course of its lifetime. It moves through the entire range of colors you defined.
  210. The ``Color Initial Ramp`` property selects the particle's initial color from a random
  211. position on the color ramp.
  212. To set up a color ramp, click on the box next to the property name and from the dropdown menu
  213. select ``New GradientTexture1D``. Click on the box again to open the texture's details.
  214. Find the ``Gradient`` property, click on the box next to it and select ``New Gradient``.
  215. Click on that box again and you will see a color range. Click anywhere on that range
  216. to insert a new marker. You can move the marker with the mouse and delete it by clicking
  217. the right mouse button. When a marker is selected, you can use the color picker next to
  218. the range to change its color.
  219. Hue variation
  220. ~~~~~~~~~~~~~
  221. Like the ``Color`` property, ``Hue Variation`` controls a particle's color, but in a
  222. different way. It does so not by setting color values directly, but by
  223. *shifting the color's hue*.
  224. Hue describes a color's pigment: red, orange, yellow, green and so on. It does not
  225. tell you anything about how bright or how saturated the color is. The ``Hue Variation``
  226. property controls the range of available hues `as described above <#process-material-properties>`__.
  227. It works on top of the particle's current color. The values you set for
  228. ``Variation Min`` and ``Variation Max`` control how far the hue is allowed to shift
  229. in either direction. A higher value leads to more color variation while a low value
  230. limits the available colors to the closest neighbors of the original color.
  231. .. figure:: img/particle_hue.webp
  232. :alt: Different values for hue variation
  233. Different values for hue variation, both times with blue as base color: 0.6 (left) and 0.1 (right)
  234. .. _doc_process_material_properties_animation:
  235. Animation
  236. ~~~~~~~~~
  237. The ``Animation`` property group controls the behavior of sprite
  238. sheet animations in the particle's :ref:`Standard Material <doc_standard_material_3d>`.
  239. The ``Min``, ``Max``, and ``Curve`` values work `as described above <#process-material-properties>`__.
  240. An animated sprite sheet is a texture that contains several smaller images aligned on a grid.
  241. The images are shown one after the other so fast that they combine to play a short
  242. animation, like a flipbook. You can use them for animated particles like smoke or fire.
  243. These are the steps to create an animated particle system:
  244. .. figure:: img/particle_sprite.webp
  245. :alt: A sprite sheet
  246. :align: right
  247. An 8x8 animated smoke sprite sheet
  248. #. Import a sprite sheet texture into the engine. If you don't have one at hand, you can download the :download:`high-res version of the example image <img/particle_sprite_smoke.webp>`.
  249. #. Set up a particle system with at least one draw pass and assign a ``Standard Material`` to the mesh in that draw pass.
  250. #. Assign the sprite sheet to the ``Texture`` property in the ``Albedo`` group
  251. #. Set the material's ``Billboard`` property to ``Particle Billboard``. Doing so makes the ``Particles Anim`` group available in the material.
  252. #. Set ``H Frames`` to the number of columns and ``V Frames`` to the number of rows in the sprite sheet.
  253. #. Check ``Loop`` if you want the animation to keep repeating.
  254. That's it for the Standard Material. You won't see any animation right away. This is
  255. where the ``Animation`` properties come in. The ``Speed`` properties control how fast
  256. the sprite sheet animates. Set ``Speed Min`` and ``Speed Max`` to ``1`` and you should see the
  257. animation playing. The ``Offset`` properties control where the animation starts on a
  258. newly spawned particle. By default, it will always be the first image in the sequence.
  259. You can add some variety by changing ``Offset Min`` and ``Offset Max`` to randomize
  260. the starting position.
  261. .. figure:: img/particle_animate.webp
  262. :alt: Animated particles
  263. Three different particle systems using the same smoke sprite sheet
  264. Depending on how many images your sprite sheet contains and for how long your
  265. particle is alive, the animation might not look smooth. The relationship between
  266. particle lifetime, animation speed, and number of images in the sprite sheet is
  267. this:
  268. .. note::
  269. At an animation speed of ``1.0``, the animation will reach the last image
  270. in the sequence just as the particle's lifetime ends.
  271. .. math::
  272. Animation\ FPS = \frac{Number\ of\ images}{Lifetime}
  273. If your sprite sheet contains
  274. 64 (8x8) images and the particle's lifetime is set to ``1 second``, the animation
  275. will be very smooth at **64 FPS** (1 second / 64 images). if the lifetime is set to ``2 seconds``, it
  276. will still be fairly smooth at **32 FPS**. But if the particle is alive for
  277. ``8 seconds``, the animation will be visibly choppy at **8 FPS**. In order to make the
  278. animation smooth again, you need to increase the animation speed to something like ``3``
  279. to reach an acceptable framerate.
  280. .. figure:: img/particle_animate_lifetime.webp
  281. :alt: Animated particles lifetimes
  282. The same particle system at different lifetimes: 1 second (left), 2 seconds (middle), 8 seconds (right)
  283. Note that the GPUParticles3D node's **Fixed FPS** also affects animation
  284. playback. For smooth animation playback, it's recommended to set it to 0 so that
  285. the particle is simulated on every rendered frame. If this is not an option for
  286. your use case, set **Fixed FPS** to be equal to the effective framerate used by
  287. the flipbook animation (see above for the formula).
  288. .. _doc_process_material_properties_turbulence:
  289. Turbulence
  290. ~~~~~~~~~~
  291. Turbulence adds noise to particle movement, creating interesting and lively patterns.
  292. Check the box next to the ``Enabled`` property to activate it. A number
  293. of new properties show up that control the movement speed, noise pattern and overall influence
  294. on the particle system. You can find a detailed explanation of these in the section on
  295. :ref:`particle turbulence <doc_3d_particles_turbulence>`.
  296. .. _doc_process_material_properties_subemitter:
  297. Collision
  298. ---------
  299. The ``Mode`` property controls how and if emitters collide with particle collision nodes. Set it
  300. to ``Disabled`` to disable any collision for this particle system. Set it to ``Hide On Contact``
  301. if you want particles to disappear as soon as they collide. Set it to ``Constant`` to make
  302. particles collide and bounce around. You will see two new properties appear in the inspector.
  303. They control how particles behave during collision events.
  304. A high ``Friction`` value will reduce sliding along surfaces. This is especially
  305. helpful if particles collide with sloped surfaces and you want them to stay in
  306. place instead of sliding all the way to the bottom, like snow falling on a mountain.
  307. A high ``Bounce`` value will make particles bounce off surfaces they collide with,
  308. like rubber balls on a solid floor.
  309. If the ``Use Scale`` property is enabled, the :ref:`collision base size <doc_3d_particles_properties_collision>`
  310. is multiplied by the particle's `current scale <#scale>`__. You can use this to
  311. make sure that the rendered size and the collision size match for particles
  312. with random scale or scale that varies over time.
  313. You can learn more about particle collisions in the :ref:`Collisions <doc_3d_particles_collision>`
  314. section in this manual.
  315. Sub-emitter
  316. -----------
  317. .. figure:: img/particle_sub_mode.webp
  318. :alt: Sub-emitter modes
  319. :align: right
  320. The available sub-emitter modes
  321. The ``Mode`` property controls how and when sub-emitters are spawned. Set it to ``Disabled``
  322. and no sub-emitters will ever be spawned. Set it to ``Constant`` to make sub-emitters
  323. spawn continuously at a constant rate. The ``Frequency`` property controls how often
  324. that happens within the span of one second. Set the mode to ``At End`` to make the sub-emitter
  325. spawn at the end of the parent particle's lifetime, right before it is destroyed. The
  326. ``Amount At End`` property controls how many sub-emitters will be spawned. Set the
  327. mode to ``At Collision`` to make sub-emitters spawn when a particle collides with the
  328. environment. The ``Amount At Collision`` property controls how many sub-emitters will be spawned.
  329. When the ``Keep Velocity`` property is enabled, the newly spawned sub-emitter starts off
  330. with the parent particle's velocity at the time the sub-emitter is created.
  331. See the :ref:`Sub-emitters <doc_3d_particles_subemitters>` section in this manual for a detailed explanation of how
  332. to add a sub-emitter to a particle system.