trails.rst 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. .. _doc_3d_particles_trails:
  2. 3D Particle trails
  3. ------------------
  4. .. figure:: img/particle_trails.webp
  5. :alt: Particle trails
  6. .. figure:: img/particle_trail_params.webp
  7. :alt: Particle trail params
  8. :align: right
  9. Setting up particle trails
  10. Godot provides several types of trails you can add to a particle system. Before you can
  11. work with trails, you need to set up a couple of parameters first. Create a new particle
  12. system and assign a process material :ref:`as described before <doc_creating_3d_particle_system>`.
  13. In the ``Trails`` group of the particle system, check the box next to ``Enabled`` and
  14. increase the emission duration by setting ``Lifetime`` to something like ``0.8``. On
  15. the process material, set ``Direction`` to ``(X=0,Y=1.0,Z=0)`` and ``Initial Velocity`` to
  16. ``10.0`` for both ``Min`` and ``Max``.
  17. The only thing that's still missing is a mesh for the draw pass. The type of mesh that you
  18. set here controls what kind of particle trail you will end up with.
  19. Ribbon trails
  20. ~~~~~~~~~~~~~
  21. .. figure:: img/particle_ribbon_mesh.webp
  22. :alt: Particle ribbon
  23. :align: right
  24. Important ribbon mesh parameters
  25. The simplest type of particle trail is the ribbon trail. Navigate to the ``Draw Passes``
  26. section and select ``New RibbonTrailMesh`` from the options for ``Pass 1``. A
  27. :ref:`RibbonTrailMesh <class_RibbonTrailMesh>` is a simple quad that is divided into
  28. sections and then stretched and repeated along those sections.
  29. Assign a new :ref:`Standard Material <doc_standard_material_3d>` to the ``Material``
  30. property and enable ``Use Particle Trails`` in the ``Transform`` property group. The
  31. particles should now be emitting in trails.
  32. You have two options for the ribbon mesh ``Shape`` parameter. ``Cross`` creates two
  33. perpendicular quads, making the particle trail a little more three-dimensional. This
  34. really only makes sense if you don't draw the trails in ``Particle Billboard`` mode
  35. and helps when looking at the particles from different angles. The ``Flat`` option
  36. limits the mesh to a single quad and works best with billboard particles.
  37. The ``Size`` parameter controls the trail's width. Use it to make trails wider or
  38. more narrow.
  39. ``Sections``, ``Section Length`` and ``Section Segments`` all work together to
  40. control how smooth the particle trail looks. When a particle trail does not travel
  41. in a straight line, the more sections it has the smoother it looks as it bends and swirls.
  42. ``Section Length`` controls the length of each section. Multiply this value by
  43. the number of sections to know the trail's total length.
  44. .. figure:: img/particle_ribbon_sections.webp
  45. :alt: Particle ribbon sections
  46. 3 sections, 1m section length (left) vs. 12 sections, 0.25m section length (right). Notice how the total length of the trails stays the same.
  47. The ``Section Segments`` parameter further subdivides each section into segments.
  48. It has no effect on the smoothness of the trail's sections, though. Instead, it controls
  49. the smoothness of the particle trail's overall shape. The ``Curve`` property defines
  50. this shape. Click the box next to ``Curve`` and assign or create a new curve. The
  51. trail will be shaped just like the curve with the curve's value at ``0.0`` at the
  52. trail's head and the curve's value at ``1.0`` at the trail's tail.
  53. .. figure:: img/particle_ribbon_curve.webp
  54. :alt: Particle ribbon curves
  55. Particle trails shaped by different curves. The trails move from left to right.
  56. Depending on the complexity of the curve, the particle trail's shape will not look
  57. very smooth when the number of sections is low. This is where the ``Section Segments`` property
  58. comes in. Increasing the amount of section segments adds more vertices to the trail's
  59. sides so that it can follow the curve more closely.
  60. .. figure:: img/particle_ribbon_segments.webp
  61. :alt: Particle ribbon segments
  62. Particle trail shape smoothness: 1 segment per section (top), 12 segments per section (bottom)
  63. Tube trails
  64. ~~~~~~~~~~~
  65. Tube trails share a lot of their properties with ribbon trails. The big difference between them
  66. is that tube trails emit cylindrical meshes instead of quads.
  67. .. figure:: img/particle_tube.webp
  68. :alt: Particle tube trails
  69. Tube trails emit cylindrical particles
  70. To create a tube trail, navigate to the ``Draw Passes`` section and select ``New TubeTrailMesh``
  71. from the options for ``Pass 1``. A :ref:`TubeTrailMesh <class_TubeTrailMesh>` is a cylinder
  72. that is divided into sections and then stretched and repeated along those sections. Assign a
  73. new :ref:`Standard Material <doc_standard_material_3d>` to the ``Material`` property and enable
  74. ``Use Particle Trails`` in the ``Transform`` property group. The particles should now be emitting
  75. in long, cylindrical trails.
  76. .. figure:: img/particle_tube_mesh.webp
  77. :alt: Particle tube
  78. :align: right
  79. Important tube mesh parameters
  80. The ``Radius`` and ``Radial Steps`` properties are to tube trails what ``Size`` is to ribbon trails.
  81. ``Radius`` defines the radius of the tube and increases or decreases its overall size. ``Radial Steps``
  82. controls the number of sides around the tube's circumference. A higher value increases the resolution
  83. of the tube's cap.
  84. ``Sections`` and ``Section Length`` work the same for tube trails and ribbon trails. They control how
  85. smooth the tube trail looks when it is bending and twisting instead of moving in a straight line.
  86. Increasing the number of sections will make it look smoother. Change the ``Section Length`` property
  87. to change the length of each section and with it the total length of the trail. ``Section Rings``
  88. is the tube equivalent of the ``Section Segments`` property for ribbons. It subdivides the sections
  89. and adds more geometry to the tube to better fit the custom shape defined in the ``Curve`` property.
  90. You can shape tube trails with curves, just as you can with ribbon trails. Click the box next to the
  91. ``Curve`` property and assign or create a new curve. The trail will be shaped like the curve with
  92. the curve's value at ``0.0`` at the trail's head and the curve's value at ``1.0`` at the trail's tail.
  93. .. figure:: img/particle_tube_curve.webp
  94. :alt: Particle tubes
  95. Particle tube trails with a custom curve shape: 4 radial steps, 3 sections, 1 section ring (left),
  96. 12 radial steps, 9 sections, 3 section rings (right)
  97. An important property you might want to set is ``Transform Align`` in the particle
  98. system's ``Drawing`` group. If you leave it as is, the tubes will not preserve volume; they
  99. flatten out as they move because their Y-axis keeps pointing up even as they change direction.
  100. This can cause a lot of rendering artifacts. Set the property to ``Y to Velocity`` instead
  101. and each particle trail keeps its Y-axis aligned along the direction of its movement.
  102. .. figure:: img/particle_tube_align.webp
  103. :alt: Particle tubes aligned
  104. Particle tube trails without alignment (left) and with Y-axis aligned to velocity (right)