Visual Effects and Cascade in Unreal Engine 361
v. Expand Distribution.
vi. Make the following changes to Distribution:
Distribution: Float Uniform
Min: 5.0
Max: 10.0
vii. Expand the Radius Sc ale.
viii. Expand Distribution.
ix. Make the following changes to Distribution:
Distribution: Float Constant
Constant: 500.0
x.
Expand the Ligh t Exponent.
xi. Expand Distribution.
xii. Make th e following changes to Distribution:
Distribution: Float Constant
Constant: 2.0
b. Save your P_Fire_Light particle system and close (or minimize) the Cas-
cade Particle Editor.
c. Now in the main e ditor, we will apply this particle system to the duplicated
particle emitter actor in the level. To do this perform the following actions:
i. Left-click on the duplicate emitter actor (the one on the right) in the
level in main editor.
ii. Navigate to you r particle s folder where you created the P_Fire an d
P_Fire_Light particle systems.
iii. Assign the P_Fire_Light particle system to th e P articles
Template of the selected particle emitter ac tor in its de ta ils rollout.
You may drag the P_Fire_Light onto the Template. Alternatively, you
may Left-click on the dropdown list next to the Template and choose
P_Fire_Light from the list.
iv. Now you should no tice that the fire effect on the right casts shadows,
reflections, and also flickers; something that looks much mor e realistic
(see Fig ure 6.44).
52. Now your particle emitter should look similar to Figure 6 .40(b).
53. Save the level and your progress.
Fantastic! We just created a really nice look ing fire effect and applied it to a torch
in our level. We worked on some mo dules that we were already familiar with and
362 Game Development and Simulation with Unreal Technology
FIGURE 6.44: Fire with Light Effect.
learned about some n ew particle modules as well, such as the S ub Image Index
and the Light modules. Let us see so me details about w hat we did in this tutorial to
set up this fire effect.
What Happened in TUTORIAL 6.5. . .
In this tutorial yo u set up a visual effects system to simulate a fire. We enc oun-
tered and used a new e mitter mo dule which utilizes the sub images of a texture.
This module and the technique is quite useful in creating effects such as fire,
smoke, clou ds, etc.
FIRE MATERIAL
As discussed above, the fire effect utilizes the Sub Ima ge Index module to
interpolate th e look of the flame material between a number of sub images. In
order for o ur emitter to successfully utilize this m odule, the p article material will
have to handle the effect as well.
So, how exactly can we make the particle material compatible with the Sub
Image Index module? The process is easy. Let us first look at a simple material
which is made of just one texture. We use a texture sample to create the look of
our material. Now, if we want our material to handle sub images, all we need
to have is a texture which is divided in such a way th at eac h sub image of the
texture looks like a complete textur e itself.
In order to accommodate this, we u sed a Flame texture that is composed of 36
smaller textures. If you open it up in the Unreal Texture Editor, it looks similar to
Visual Effects and Cascade in Unreal Engine 363
FIGURE 6.45: The Fire Sub Image Texture.
Figure 6.45. As you can see in this image, the Flame texture is made of 6 row and
6 columns of what a snapshot of a flame might look like. We used this textur e in
the creation of our fire particle mater ia l as shown in Figure 6.39(b).
In order for our fire to a lso have an o range fiery color, we used a flame texture.
Since our original fire texture has 6 rows and 6 columns of sub images, we con-
nected the fire texture to a Texture Coordinate expression and used the value
of 6 for bo th VTiling and U Tiling. This made the Fire texture look like an
array of 6×6 sub images. We then multiplied this Fire Texture with our Flames
texture to colorize the material.
SETTING UP THE FIRE EMITTER
With ou r Fire Particle Material created, we can now establish our emitter. We
added our Fire material to the Material of our particle sy stem and made its
364 Game Development and Simulation with Unreal Technology
Screen Alignment to bec ome based on the velocity. This will stretch the parti-
cles as they speed up to m ake the effect more natural.
The next task was to make the particle system able to utilize our material’s
sub images. In order to do so we changed the Int erpolation Mode of the
Sub UV section o f our particle system to Linear Ble nd and its Sub Images
Horizontal and Sub Images Verti cal to 6. This will make our particle sys-
tem able to split the mater ia l into an array of 6×6 sub materials, and blend fr om
one to another linearly.
We also need to make app ropriate changes to the Spawn a nd Burst sections
of our particle emitter. Next, we added a Lifetim e module to our emitter and
made each particle last between 0.7 to 1.0 seconds. After setting the lifetime
of each particle, we added an Initial Size module in which we assigned a
random size to each emitted particle that r anges between [40,70,0] to [60,90,0 ].
Next, we gave our p articles a speed value between 40 to 60 along their Z-axis
by using a Vector Uniform distribution. We also made some modifications to
the color and opacity of o ur particles. We want our particles’ colors to start with
a very bright glow ([20,5, 1]), but for the glow to fade as the fire particles age
([7,1, 0]). We mad e proper adjustments to the Alpha Over Life of our parti-
cle’s Color Over Life module to make them transparent as they age, as well.
However, our effect is not complete yet. The problem in our effect so far is
that, de spite setting its Sub UV values, the effec t still uses just 1 out of the 6×6
sub images for each emitter particle. To make th e effect be able to go over each
sub image, we need a Sub Image Index module to be added to the emitter.
This modu le can be programmed in such a way that during the lifetime of each
particle, it selects one of the 6×6 sub images as it ag es. Once the Sub I mage
Index m odule is added to ou r emitter, we made it use a Floa t Constant
Curve. This curve starts at the value of 0 (at time =0), and goes linearly to a
value of 35 over the lif etime of our particle s (time=1) . Therefore, the particle
emitter starts with sub image 0 and assigns it to each emitted particle, and as the
particle ages, the image will change to 1, 2, . . . , and finally to 35, at th e end of
the particle’s lifetime.
ADDING LIGHT TO PARTICLES
Once the pa rticle emitter is place d in the level, and especially if it is placed close
to a surface, you will soon realize that the emitter doe s n ot cast light into the level,
despite its bright glow of fire. To make this effect even more realistic, we add ed
a Light module to our emitter. We made proper modifications and adjustments
to the light module for each emitted particle to ca st a fiery light into the scene .
6.8 PARTICLE TYPE DATA MODULES
So far we have used the CPU-based and GPU-b ased particles. The default data type
of an emitter is Sprite emitter. We referred to these emitters as CPU-based emitters.
We have also worked with GPU-based emitters whose data type is GPU Sprites.
Visual Effects and Cascade in Unreal Engine 365
FIGURE 6.46: Assigning a Type Data to an Emitter.
In order to select a data type for a n emitter, simply Right-click on the emitter.
Move to the Type Data tab from the popup menu and choose the appro priate Type
Data for your emitter (see Figure 6.46). If a non-sprite type data is a ssigned to a
particle emitter and you wish to remove it, simply right-click on the type data and
choose Delete Mod ule.
In this section
1
we will go over different particle Type D ata and discuss their spe-
cialty and a pplications [44].
6.8.1 GPU SPRITES TYPE DATA
The GPU Sprite type data mod ule suppor ts simulating particles on the GPU. GPU
simulation allows for hundreds o f thousands of particles to be simulated and rendered
efficiently [44].
GPU particles do not support all of the feature s available to traditional CPU particles,
but they offer greater efficiency as well as a few uniqu e features. Emission of parti-
cles still h appens on the CPU to determine where, when, and how many particles to
spawn. T he CPU may also assign initial attributes such as size and velocity using
methods available to traditional CPU particles [19]. GPU particles support the use
of Vector Field modules and calculations. This module can be utilized to simulate
effects in which the global and/or local features affecting each pa rticle represent a
vector field. This will be a very powerful technique to simulate effects such as fluid
dynamic s, air flow, electromagnetic fields, etc.
1
The contents of this section are adopted from the official UE4 online documentation found at:
https://docs.unrealengine.com/latest/INT/.
..................Content has been hidden....................

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