process_material_properties.rst 20 KB

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