346 Game Development and Simulation with Unreal Technology
(a) (b) (c)
FIGURE 6.35: (a) The Blizzard Emitter spewing droplets from one point. (b) The Blizzard
Emitter spawning snow droplets over a two-dimensional plane. (c) Blizzard Emitter Actor
shown in the level.
26. The first thing to do, to simulate the e ffect of the atmospheric drag force on
the snow particles, is to change the Screen Alignment of the particles in the
Required emitter module.
27. Click on the Required module, and in its details panel, change its Sc reen
Alignment to PSA_Velocity.
28. Right-click under the last emitter module (it should be the Initial Location
module), and choose the Size Size By Speed module to add it to your par-
ticle emitter.
29. Click on the Size By Speed module. In this modu le ’s de ta ils panel, make the
following changes:
SpeedScale = [X : 1.0,Y : 2.0] MaxScale = [X : 1.0 , Y : 2.0]
30. As shown in Figure 6.36(a) th e particles are too big to be snowflakes. This is
because we are scaling the initial size of the particles up along the Y axis of
their velocity path. Let us make the fo llowing changes to the Sta rt Size
Distribution of the Initial Size mod ule of the emitter see r esults in Fig-
ure 6.36(b):
Max = [X : 5.0,Y : 5.0,Z : 5.0] Min = [X : 3.0,Y : 3.0,Z : 3.0]
31. One thing abo ut this snow effect that is still not quite righ t is the way they drop to
the gr ound. We have used an Initial Velocity module to give the particles a
start speed. Snowflakes are affected by a number of f orces due to th eir mass. Two
of the se forces are the earth’s gravity and the wind. To simulate these forces, we
will add an Acceleration module to the emitter.
32. Make the following changes to the Acceleration Const parameters in the
details panel of the A cceleration Module:
Max = [X : 60.0, Y : 0.0,Z : 98 .0]
Visual Effects and Cascade in Unreal Engine 347
(a) (b) (c)
FIGURE 6.36: (a) The snow droplets are scaled along their speed path. (b) The snow droplets,
after changing their initial size. (c) Blizzard Emitter Actor shown in the level. (c) Snow parti-
cles affected by gravity and wind forces.
33. You will notice that after adding the acceleration module and applying the forces
to our particles, they tend to speed up as time goes by. This will make them exit
our field of v iew, and therefore a few of the snow particles are now visible. We
need to increase the num ber of these particles being spawned .
34. Click on the Spawn module of the emitter and change the constant value of its
Spawn R ate D istribution to 1500. 0:
Constant = 1500.0
35. Save your progress and the level. Rain particles should now look like Fig-
ure 6.36(c).
Fantastic! Our blizzard effect is now comple te . L et us take a look at what are the
similarities and differences between the CPU-based rain effect and the GPU-based
blizzard effect.
What Happened in TUTORIAL 6.4. . .
In this tutorial you set up a visual effects system to simulate a blizzard using a
GPU sprite emitter.
The particle material for this system is just like a regular material. However,
instead of a color parameter or constant value, we used a Particle Color node
to drive the color of our particle system’s sprites from the color modules of the
emitter. This node h as the benefit of exposing the color of the sprites within the
Color Module s of the Emitter to which this material is applied. This way, we can
control the initial color and color over life of sprites within the Emitter module.
To make the material translucent, we set the Shadin g Model of the material
to Unlit, and its Blend Mode to translucent. Since the shading model for the m a-
terial is set to Unlit, we can program the shading o f the material via its Emissive
348 Game Development and Simulation with Unreal Technology
Color channel. The outp ut of any expression we plug into this node will drive
the shading of the material.
The material and particle setup was quite similar to the CPU-based particles.
The only major difference is that the blizzard effect is a GPU-based particle
system. Therefore, when we applied the acce le ration module, we can only choose
a constant acceleration for it. However, we can now spawn a lot more particles.
In fact, we spawned 1500 snow particles, compared to a m ere 90 for the rain
emitter. Moreover, we will be able to app ly Vec tor Fields to our GPU-based
particle system to simula te a complex snowstorm. An exercise will ask you to
apply a vector field to this particle system to simulate a snowstorm.
6.7 WORKING WITH SUB UVS
So far in o ur particle systems we have used textures or expressions to establish the
look of the material. But this look stayed the same as each particle is created. We
changed colors, sizes, alp ha values and so on, but the looks (texture) of our particles
were fixed at the time of their cr eation.
In the next Tutorial, we will c reate a fire effect. The difference between the look of
flames than that of a rain drop, or a snowflake, is that flames change their shape. This
look is easily created by employing Sub Images in your particle system. To be ab le
to utilize sub images to change the look (textu re) of a particle as it is created and as
it ages, we need to take a few steps.
FIGURE 6.37: Particle Emitter SubUV Properties.
The first step involves allowing the particle emitter to utilize Sub UVs. Whe n you
select an emitter in the Cascade Particle Editor, you will be able to modify its Su b
UV prop erties in its Details ro llout shown in Figure 6.37. In the Sub UV section
you will see the Interpolation Mode, Sub Im ages Horizontal, Sub Images
Vertical, Scale UV, a nd Random Image Changes.
Visual Effects and Cascade in Unreal Engine 349
TABLE 6.4: SubUV Properties
Interpolation Mode: This sets the interpo lation method the emitter uses to
determine how to change sub imag e s. The available opti ons are as follows:
None: This option does not apply SubUV modul e s in the emitter.
Linear: This option transitions between sub images in a given order
without any blending between successive sub images.
Linear_Blend: This option transitio n s between sub images in a
given order and blends successive sub images as the emitter transi-
tions from one sub image to the next.
Random: This option transitions randomly between su b images with -
out any blending between successive sub images.
Random_Blend: This option transitions randomly between sub im-
ages and blends sub imag e s as it transition s from one to the next.
Sub Images Horizontal: Number of horizontal sub images in the texture
applied in the particle material.
Sub Images Vertical: Number of vertical sub images in the texture appli e d
in the particle material.
Scale UV: This option specifies whether to scale the UVs, if the original
model was not set up with sub UVs.
Random Image Changes: This option specifies the number of times to
change a random sub image over the lifetime of a particle.
FIGURE 6.38: Particle SubUV Expression and its Properties.
The second step in utilizing sub UVs and sub images in a particle system is to make
its material draw from a texture composed of an array of image s. The number of
350 Game Development and Simulation with Unreal Technology
horizontal and vertical sub texture in the texture we will use in the materia l should be
equal to the Sub Images Horizontal and Sub Images Vertical numbers in the Sub
UV section of the particle emitter’s Required module. Once we have such a texture,
in the Material Editor we will place a Particle Su b UV material expression and
assign the texture to it (see Figure 6.38).
Finally, with the particle material set up to accept sub images and the emitter set up
to use h orizontal and vertical sub imag es in order (or randomly), we will have to tell
the emitter how to change the sub im ages over the lifetime of a particle. In order to
do this, we will use a Sub Image Index module. The Sub Image Index module
contains a Sub Im age Index distribution. This distribution will tell your emitter how
to pick the sub images from the particle materia l. The simplest way to set this module
up is to make its distribution a Float Constant Curve distribution. Then, make
the first point to have the In Val=0 and Out Val=0. Make the second point to
have In Val=1 and Out Val=U ×V 1. Where U is the number of horizontal sub
images an d V is the number of vertical su b images in your texture. Doin g so will
make a particle apply the upper-left texture sub image when it is spawned and go
through the sub images one-by-one through the bottom-right textur e sub image.
FIND ON THE WEBSITE
To find updates to this tutorial and upda te d instructions about its implementa-
tion on othe r UE4 versions, p le ase visit the books companion Website at:
http://www.RVRLAB.com/UE4Book/
TUTORIAL 6.5 Simulating Fire
In this tutorial we will set up another sprite emitter to simulate a fir e effect.
Like all other tutorials, the first thin g to do is to create a project to which we
add the particle system. The initial setup of this tutorial should resemble the
image shown in Figure 6.29.
NOTE
We will need the demo ro om to be set up before we can proceed
with the rest of the tutorial. You may find instructions to set up y our
demo room in Tutorial 6.1 on page 309.
SETTING UP THE LEVEL
To have a uniform level that we ca n work with, you may perform one of the
following options to start the work:
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.241.250