Materials in Unreal Engine 225
To achieve more depth, we also adjusted the normal map a little. If you re-
member from o ur d iscussion of normal maps from a previous tutorial, e ach pixel
in the normal map repr esents a three-dimensional vector, perpendicular to the
surface at the location of the pixel. The R, G, and B, values of the normal map
pixels represent the X, Y, and Z values o f the normal vector.
The Z-value represents the len gth of the vector perpendicular to the surface,
if the surface were a flat plane. The larger the Z-value is in comparison to the
X and Y values, the mor e flat the surface will look like. In or der to m agnify the
3D look of our material we can multiply each channel of the norm al map with a
value. If the Red and Green channels o f normal map are multiplied w ith values
larger than the value multiplied b y the Blue c hannel, the resulting vector will
emphasize the 3D-ness of the surface. To ach ieve this, we mu ltiplied the (R,G,B)
channels of the normal map by (2,2,1). Since norma l vectors must have a length
of 1, we normalized th e result.
CREATE THE DYNAMIC MATERIAL
With our static steel panel mate rial created , we can now focus on making the
material dynamic. Unreal Engine ’s Coordinate material expressions are those
with the ability to interact with the c oordin ates of a mater ia l’s texture or geometry.
We can make our material dynamic in two different mann ers, either by changing
its geometr y or b y manipulating the way in which its texture is applied to its
geometry.
In this tutorial we opted to work with the texture to achieve the dynamic look.
We modified the texture tiling of our material by panning it across the surface on
which it will be applied. A Pan ner expre ssion is the perfect tool for this purp ose.
The Panner expression takes in as input a SpeedX and a SpeedY value. The
SpeedX specified the speed of pannin g the U-c hannel of the texture coordinate,
while the SpeedY controls the panning speed of the V-channel.
We used SpeedX=0.1 and SpeedY =0 to pan our texture on the surface of
the object along its U-channel. Co nnecting the output of the Panner coordinate
expression to the UVs channels of all of our texture sample expr essions will make
the material move across the object’s surface. Since our object is a round object
(we used the preview mesh of th e UE4’s star te r c ontent), the end result loo ks like
the object is rota ting along its major axes.
CREATE PULSATION IN THE MATERIAL
To make our m aterial look a b it more interesting, we made the grout between
tiles pulsate b etween a fire and an ice color/texture. The idea was pretty straight-
forward, much like the pulsation in Tu torial 4.5.
The pulsation network will be connected to the Emissi ve Color channel of
our material, and its textur e comes from the T_Flame_Tile_D texture. We used
the original texture as the fire and sub tracted it from 1 (1 the o riginal textur e)
for the ice. To confine the pu lsatio n to just the grout, we multiply the ice a nd
fire textures with the green ch annel of our T_Tech_Hex_Tile_M mask texture.
226 Game Development and Simulation with Unreal Technology
Doing so will make the ice and color become non-z ero only in the grout area and
zero on the tiles (see Figure 4.72( b)).
To pulsate between ice and fire, we linearly interpolated between them. There-
fore, we connecte d the fire network to the A channel and the ice n etwork to the B
channel of a Lerp expression. The Alpha channel of the Lerp is responsible for
smoothly transitioning between the two. We used a network based on a Sine ex-
pression to oscillate between the values of 0 and 1 for the Alpha channel of the
Lerp. To see h ow we scaled and biased the output values of the sine expre ssion,
check out the calculations in equations (4.13)–(4.18) on page 209.
APPLYING MATERIALS TO THE PROPS
The fina l task in this tutorial was to apply the materials to the props in the level.
The p rocess was similar to all the other tutorials in this c hapter. We simply se-
lected each prop, and ap plied the material to its Eleme nt[0] in its Materials
section of its details rollout.
4.6.2.4 Depth Expressions
These expressions
5
utilize the frame buffer to calculate the depth. This depth is then
used to create seamless transitions within the scene [12].
Depth Fade: This expression can be used to remove the artifacts that appear as
objects intersect ea ch other, e specially when tran slu cent objects intersect with
opaqu e objects.
TABLE 4.31: Depth Fade
Properties
Fade Distance Property: World Space distance over which the fade
should take place. This is used if the FadeDistance Input is not
connected.
Inputs
Opacity Input: Ta kes in the existing opacity for the object prior to the
depth fade.
Fade Distance Input: World Space distance over which the fade should
take place.
5
The contents of this section are adopted from the official UE4 online documentation found at:
https://docs.unrealengine.com/latest/INT/.
Materials in Unreal Engine 227
Pixel Depth: This expression generates as output the distance of each pixel from
camera a t render time. This is very useful to utilize to generate special effects
such as mur kiness in the water as the depth increases.
Example Usa ge: Scene depth can be used in a n etwork if connected to the alpha
channel of a Lerp expression to interpo la te between two color s based on the
distance of pixels of the object from ca mera to d arken long hallways.
Scene Depth: This expression generates as output the existing scene d epth. This
is similar to PixelDepth, except that PixelDepth can sample the depth only
at the pixel currently being drawn, whereas SceneDepth samples depth at any
location.
TABLE 4.32: Scene Depth
Inputs
UVs Input: Ta kes in the UV texture coordinates used to determine how
to sample the depth texture.
Example Usa ge: Scene depth can be used in a n etwork if connected to the alpha
channel of a Lerp expression to interpo la te between two color s based on the
distance of all locations in th e scene. Note: Only translucen t materials may
utilize the Scene Depth expression.
ADVA N C ED TOPIC
Scene Depth expression r eturns a raw depth value. This value is an integer
value in the range of 0 to 2
24
1. To normalize this value to a linger range of
0 to 1, use the following equations:
Depth
norm
=
1 MAX Z
SceneDepth + MAXZ
(4.21)
where Depth
norm
is the normalized depth value between 0 and 1, and
MAXZ = 2
24
1 = 16777215 is the maximum perceivable depth.
4.6.2.5 Fon t Expressions
The Font category of Material Expressions deals with cr eating font materials to be
displayed using a TextRender component within Unreal Engine 4 [15].
228 Game Development and Simulation with Unreal Technology
Font Sample: This expression allows you to sample font texture s from a font r e-
source into a two-dimensional texture. T he A lpha channel of the font should co n-
tain the font ou tline value. Only valid Font pages are allowed to b e spec ified. This
expression ha s two properties: Fon t and Font Texture Page .
TABLE 4.33: Font Sample
Properties
Font: Holds the default font asset (from the Content Browser) to be held
within the expression.
Font Texture Page: The current font texture page to be used as a part
of the texture.
Font Sample Parameter: This expression provides a way to create a font-based pa-
rameter using a material instance constant. This allows easy switching between
different fonts without having to use many differe nt font materials. This expres-
sion has four properties:
TABLE 4.34: Font Sample Parameter
Properties
Parameter Name: Specified the name used to identify the parameter in
the mate rial instance through code or blueprint seque n c e .
Group: Provides a way to org a n ize parameter names into groups, or cat-
egories, within a Material Instance Constant. All parameters within
a material that have the same Group property name will be listed
underneath th a t category in the instance.
Font: Hold the de fault font asset (from the content browser) to be held
within the expression.
Font Texture Page: The current font texture page to be used as a part
of the texture.
4.6.2.6 Parameter Expressions
This section
6
presents an overview of Parameter Ex pressions [42]. These are expr es-
sions that can be referenc ed in Materials, Textures, Blueprints, etc. You can think of
these expression as variables in a programming language. Much like variables, you
6
The contents of this section are adopted from the official UE4 online documentation found at:
https://docs.unrealengine.com/latest/INT/.
Materials in Unreal Engine 229
may use the name o f these parameters to refere nce them and make m odifications to
their values.
CROSS-REFERENCE
To learn more about the Parameter Expressions and their use in conjunction
with material instances, check out Section 5.4 of Cha pter 5– A dvanced Mate-
rial Concepts in Unreal Engine.
Font Sampler Parameter: This expression provides a way to expose a font-based
parameter in a material instance constant, making it easy to use different fonts
in different instances. The alp ha channel of the font will contain the font outline
value. Only valid font pages are a llowed to be spe cified.
TABLE 4.35: Font Sampler Parameter
Properties
Parameter Name: Specifies the name use d to identify the parameter in
instance of the material and through code.
Group: Provides a way to organize parameter names into grou p s, or cat-
egories, within a M aterial Instance Constant. All parameters
within a material that have the same Group property n a m e will be
listed underneath that category in the instance.
Font: Holds the default fo n t asset (from the Content Browser) to be held
within the expression.
Font Texture Page: The current font texture pag e to be used as a part
of the texture.
Scalar Parameter: Th is parameter exp ression is equivalent to a Constant expres-
sion in that it stores a single float value and returns this value. However, like all
other parameters in Unr eal Engine, it can be referenced and its values changed in
an instance of the material at run-time, by level designe rs, or by the other engine
components such as Cascade and Matinee.
TABLE 4.36: Scalar Parameter
Properties
Parameter Name: Specifies the name use d to identify the parameter in
instance of the material and through code.
..................Content has been hidden....................

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