Skip to content

Commit 7813926

Browse files
authored
Merge pull request #10597 from skyace65/Particles2DUpdate
Update 2D particles page for Godot 4.4
2 parents b338f45 + 95946bf commit 7813926

18 files changed

+301
-241
lines changed

tutorials/2d/img/emission_shapes1.png

-3.65 KB
Binary file not shown.
3.58 KB
Binary file not shown.

tutorials/2d/img/emission_shapes2.png

-6.76 KB
Binary file not shown.
5.11 KB
Binary file not shown.

tutorials/2d/img/emission_shapes3.png

-3.89 KB
Binary file not shown.
3.71 KB
Binary file not shown.

tutorials/2d/img/emission_shapes4.png

-21.4 KB
Binary file not shown.
9.24 KB
Binary file not shown.

tutorials/2d/img/particles2.png

-12.5 KB
Binary file not shown.

tutorials/2d/img/particles2.webp

18 KB
Binary file not shown.
-8.51 KB
Binary file not shown.
Binary file not shown.
-8.98 KB
Binary file not shown.
9.87 KB
Binary file not shown.

tutorials/2d/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Rendering
3333
2d_meshes
3434
2d_sprite_animation
3535
particle_systems_2d
36+
particle_process_material_2d
3637
2d_antialiasing
3738
custom_drawing_in_2d
3839
2d_parallax
Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
.. _doc_particle_process_material_2d:
2+
3+
ParticleProcessMaterial 2D Usage
4+
================================
5+
6+
Process material properties
7+
---------------------------
8+
9+
The properties in this material control how particles behave and change over their lifetime.
10+
A lot of them have ``Min``, ``Max``, and ``Curve`` values that allow you to fine-tune
11+
their behavior. The relationship between these values is this: When a particle is spawned,
12+
the property is set with a random value between ``Min`` and ``Max``. If ``Min`` and ``Max`` are
13+
the same, the value will always be the same for every particle. If the ``Curve`` is also set,
14+
the value of the property will be multiplied by the value of the curve at the current point
15+
in a particle's lifetime. Use the curve to change a property over the particle lifetime. Very
16+
complex behavior can be expressed this way.
17+
18+
.. note::
19+
This page covers how to use ParticleProcessMaterial for 2D scenes specifically.
20+
For information on how to use it in a 3D scene see :ref:`doc_process_material_properties`.
21+
22+
Lifetime Randomness
23+
~~~~~~~~~~~~~~~~~~~
24+
25+
The ``Lifetime Randomness`` property controls how much randomness to apply to each particle's
26+
lifetime. A value of ``0`` means there is no randomness at all and all particles live for
27+
the same amount of time, set by the :ref:`Lifetime <doc_3d_particles_properties_time>` property. A value of ``1`` means
28+
that a particle's lifetime is completely random within the range of [0.0, ``Lifetime``].
29+
30+
Particle Flags
31+
--------------
32+
33+
Spawn
34+
-----
35+
36+
Angle
37+
~~~~~
38+
39+
Determines the initial angle of the particle (in degrees). This parameter
40+
is mostly useful randomized.
41+
42+
.. image:: img/paranim11.gif
43+
44+
Velocity
45+
~~~~~~~~
46+
47+
Direction
48+
^^^^^^^^^
49+
50+
This is the base direction at which particles emit. The default is
51+
``Vector3(1, 0, 0)`` which makes particles emit to the right. However,
52+
with the default gravity settings, particles will go straight down.
53+
54+
.. image:: img/direction1.png
55+
56+
For this property to be noticeable, you need an *initial velocity* greater
57+
than 0. Here, we set the initial velocity to 40. You'll notice that
58+
particles emit toward the right, then go down because of gravity.
59+
60+
.. image:: img/direction2.png
61+
62+
Spread
63+
^^^^^^
64+
65+
This parameter is the angle in degrees which will be randomly added in
66+
either direction to the base ``Direction``. A spread of ``180`` will emit
67+
in all directions (+/- 180). For spread to do anything the "Initial Velocity"
68+
parameter must be greater than 0.
69+
70+
.. image:: img/paranim3.gif
71+
72+
Flatness
73+
^^^^^^^^
74+
75+
This property is only useful for 3D particles.
76+
77+
Initial Velocity
78+
^^^^^^^^^^^^^^^^
79+
80+
Initial velocity is the speed at which particles will be emitted (in
81+
pixels/sec). Speed might later be modified by gravity or other
82+
accelerations (as described further below).
83+
84+
.. image:: img/paranim4.gif
85+
86+
Animated Velocity
87+
-----------------
88+
89+
Angular Velocity
90+
~~~~~~~~~~~~~~~~
91+
92+
Angular velocity is the speed at which particles rotate around their center
93+
(in degrees/sec).
94+
95+
.. image:: img/paranim5.gif
96+
97+
Orbit Velocity
98+
~~~~~~~~~~~~~~
99+
100+
Orbit velocity is used to make particles turn around their center.
101+
102+
.. image:: img/paranim6.gif
103+
104+
Accelerations
105+
-------------
106+
107+
Gravity
108+
~~~~~~~
109+
110+
The gravity applied to every particle.
111+
112+
.. image:: img/paranim7.gif
113+
114+
Linear Acceleration
115+
~~~~~~~~~~~~~~~~~~~
116+
117+
The linear acceleration applied to each particle.
118+
119+
Radial Acceleration
120+
~~~~~~~~~~~~~~~~~~~
121+
122+
If this acceleration is positive, particles are accelerated away from
123+
the center. If negative, they are absorbed towards it.
124+
125+
.. image:: img/paranim8.gif
126+
127+
Tangential Acceleration
128+
~~~~~~~~~~~~~~~~~~~~~~~
129+
130+
This acceleration will use the tangent vector to the center. Combining
131+
with radial acceleration can do nice effects.
132+
133+
.. image:: img/paranim9.gif
134+
135+
Damping
136+
~~~~~~~
137+
138+
Damping applies friction to the particles, forcing them to stop. It is
139+
especially useful for sparks or explosions, which usually begin with a
140+
high linear velocity and then stop as they fade.
141+
142+
.. image:: img/paranim10.gif
143+
144+
Display
145+
-------
146+
147+
Scale
148+
~~~~~
149+
150+
Determines the initial scale of the particles.
151+
152+
.. image:: img/paranim12.gif
153+
154+
Color Curves
155+
~~~~~~~~~~~~
156+
157+
Color
158+
^^^^^
159+
160+
Used to change the color of the particles being emitted.
161+
162+
Hue Variation
163+
~~~~~~~~~~~~~
164+
165+
The ``Variation`` value sets the initial hue variation applied to each
166+
particle. The ``Variation Random`` value controls the hue variation
167+
randomness ratio.
168+
169+
.. _doc_particle_systems_2d_animation:
170+
171+
Animation
172+
~~~~~~~~~
173+
174+
.. note::
175+
176+
Particle flipbook animation is only effective if the CanvasItemMaterial used
177+
on the GPUParticles2D or CPUParticles2D node has been
178+
:ref:`configured accordingly <doc_particle_systems_2d_using_flipbook>`.
179+
180+
To set up the particle flipbook for linear playback, set the **Speed Min** and **Speed Max** values to 1:
181+
182+
.. figure:: img/particles_flipbook_configure_animation_speed.webp
183+
:align: center
184+
:alt: Setting up particle animation for playback during the particle's lifetime
185+
186+
Setting up particle animation for playback during the particle's lifetime
187+
188+
By default, looping is disabled. If the particle is done playing before its
189+
lifetime ends, the particle will keep using the flipbook's last frame (which may
190+
be fully transparent depending on how the flipbook texture is designed). If
191+
looping is enabled, the animation will loop back to the first frame and resume
192+
playing.
193+
194+
Depending on how many images your sprite sheet contains and for how long your
195+
particle is alive, the animation might not look smooth. The relationship between
196+
particle lifetime, animation speed, and number of images in the sprite sheet is
197+
this:
198+
199+
.. note::
200+
201+
At an animation speed of ``1.0``, the animation will reach the last image
202+
in the sequence just as the particle's lifetime ends.
203+
204+
.. math::
205+
Animation\ FPS = \frac{Number\ of\ images}{Lifetime}
206+
207+
If you wish the particle flipbook to be used as a source of random particle
208+
textures for every particle, keep the speed values at 0 and set **Offset Max**
209+
to 1 instead:
210+
211+
.. figure:: img/particles_flipbook_configure_animation_offset.webp
212+
:align: center
213+
:alt: Setting up particle animation for random offset on emission
214+
215+
Setting up particle animation for random offset on emission
216+
217+
Note that the GPUParticles2D node's **Fixed FPS** also affects animation
218+
playback. For smooth animation playback, it's recommended to set it to 0 so that
219+
the particle is simulated on every rendered frame. If this is not an option for
220+
your use case, set **Fixed FPS** to be equal to the effective framerate used by
221+
the flipbook animation (see above for the formula).
222+
223+
Emission Shapes
224+
---------------
225+
226+
ParticleProcessMaterials allow you to set an Emission Mask, which dictates
227+
the area and direction in which particles are emitted.
228+
These can be generated from textures in your project.
229+
230+
Ensure that a ParticleProcessMaterial is set, and the GPUParticles2D node is selected.
231+
A "Particles" menu should appear in the Toolbar:
232+
233+
.. image:: img/emission_shapes1.webp
234+
235+
Open it and select "Load Emission Mask":
236+
237+
.. image:: img/emission_shapes2.webp
238+
239+
Then select which texture you want to use as your mask:
240+
241+
.. image:: img/emission_shapes3.webp
242+
243+
A dialog box with several settings will appear.
244+
245+
Emission Mask
246+
~~~~~~~~~~~~~
247+
248+
Three types of emission masks can be generated from a texture:
249+
250+
- Solid Pixels: Particles will spawn from any area of the texture,
251+
excluding transparent areas.
252+
253+
.. image:: img/emission_mask_solid.gif
254+
255+
- Border Pixels: Particles will spawn from the outer edges of the texture.
256+
257+
.. image:: img/emission_mask_border.gif
258+
259+
- Directed Border Pixels: Similar to Border Pixels, but adds extra
260+
information to the mask to give particles the ability to emit away
261+
from the borders. Note that an ``Initial Velocity`` will need to
262+
be set in order to utilize this.
263+
264+
.. image:: img/emission_mask_directed_border.gif
265+
266+
Emission Colors
267+
~~~~~~~~~~~~~~~
268+
269+
``Capture from Pixel`` will cause the particles to inherit the color of the mask at their spawn points.
270+
271+
Once you click "OK", the mask will be generated and set to the
272+
ParticleProcessMaterial, under ``Spawn`` and then ``Position``
273+
274+
.. image:: img/emission_shapes4.webp
275+
276+
All of the values within this section have been automatically generated by the
277+
"Load Emission Mask" menu, so they should generally be left alone.
278+
279+
.. note:: An image should not be added to ``Point Texture`` or ``Color Texture`` directly.
280+
The "Load Emission Mask" menu should always be used instead.

0 commit comments

Comments
 (0)