334 Game Development and Simulation with Unreal Technology
we get closer to their boundaries. To achieve this, we can use a function (i.e., a
Material Expression node) that has a disk shape – i.e., it goes from 1 to 0 by
distance from the center as shown in Figure 6. 17(a).
Unreal Material Edito r has a material expression called Radial Gradient Ex-
ponential. It simulates a circle in 2D with f ull value ( equal to 1) at the center,
dropping its value to 0 as the distance grows from the center.
We could just multiply the output of the Radial Gradie nt Exponential ex-
pression with the Particle Color RGB values and assign it to th e emissive channel
of our sprite ma te rial. Our material would look like Figure 6.17(a).
•
Material’s Opacity: The opacity cha nnel of the material uses the same cal-
culations as the emissive color. We multiply the output of the Alpha chan -
nel of the P article Color module with the output of the Rad ial Gradient
Exponential expression to calculate opacity – see Figure 6.22(b).
RAIN INITIAL PARAMETERS
After setting u p and assigning the Rain Sprite’s material, it is tim e to set the
particle system up. As we discussed earlier in this chapter, a visual effect is made
of one or more Particle Emitters. Each emitter, in turn, is made of two or more
modules. If you remem ber, the Required and Spawn modules are manda tory
modules and must be present in each emitter. Most other modules can be add ed
later on; such as, initial control mod ule, or overtime module .
For this Rain sprite em itter, we added five initial modules, four initial modules,
and one lifetim e module.
•
Initial Color: We set the RGB values of the initial color to be (1,1, 1). Therefore,
all of our particles will have a white color when they spawn.
•
Lifetime: The lif etime module controls the m inimum and ma ximum possible life-
time of each emitted sprite. We set the minimum value of the lifetime distribution
to be 5, a nd maximum to be 10 . With these values, each emitted sprite is assigned
a lifetime of 5 to 10 seconds. The particle dies after its lifetime expires.
•
Initial Siz e: We assigned an initial size between (15,15,15) and (25, 25,25) to
each spawned particle through this module. This should give a nice randomness
to the shapes of the spawned sprites.
•
Initial Velocity: To create more randomness for the look of our visual e ffect, we
use another d istribution fo r the initial velocity of our particles. Wh en a particle
is about to spawn, unreal will pick its initial velocity between the minimum and
maximum values we set up for it. Since velocity is a vector in 3D – i. e., x, y, and
z– we set two vectors for initial velocity. In this example we set the minimum
speed of a rain droplet to be be tween [−10,−10,−50] and [10,10 , −30]. Notice
that sinc e the rain drops, we give negative values to the Z component of the min
and max speed vectors.
The variations in the x and the y axes of the initial speed m ake the pa rticles to
travel in a random trajectory – see Figure 6.25(a).
•
Initial Location: The problem so far with the particle system for rain is that it
looks like rain drop le ts are all being generated from one point in space – Fig-