process_material_properties.rst 21 KB

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