294 Game Development and Simulation with Unreal Technology
Combining the capability of material functions in encompa ssing your material
channels’ ne tworks with the Make Attribute and Break Attribute expressions,
you can combine all of the material channels’ networks into one output material.
As a result, Unreal Engine 4’s Material Layer Blend functions allow us to com-
bine multiple materials (as defined within th eir own respective material fu nctions)
together to create a Multilayered Material.
The key be nefit of creating multilayer ed mate rials (also called Layered Materials)
in Unreal Engine 4 is the fact that Layered Materials allow for modular crea tion of
your materials which would otherwise require complicated n etworks to achieve the
same result. Moreover, this feature will effectively simulate natural multimater ia l
objects and will allow for more intuitive design of your materials.
For example, if you have a chair w ith multiple materials on it, you can create
each of those materia ls and use the Make Attribute expression to encapsulate each
of these materials within their respective material function. You can then use the
Material Layer Blend in your final Layered Material’s graph to blend each of its
individual materials into one final ma te rial.
Figure 5.12 shows an example o f a material that is de sig ned based on two indepen-
dently created materials, a Rock material and a Brick Material. Each of th e original
materials, the rock and the brick, have been independen tly created and made into a
material function, e. g., RockMatFunction and BrickMaterialFunction shown
in Figure 5.1 2. The two mater ia l functions are then used as the inputs to the Base
and Top ma te rial layers in the MatLayerBle n_Standard expression. The Alpha
channel of the blend expression is connec te d to a checker-board texture that ranges
between 0 and 1 to blend between the two layers. The Blended Material output
of the blend expression is a Material Attribute. It is conne cted to the Material
Attribute channel of the final material.
FIGURE 5.12: Layered Materials.
NOTE
In order to use the Materi al Attribute channel of the material node, ch eck
the box Use Material Attribute in the material node’s Details Panel.
Advanced Material Concepts in Unreal Engine 295
5.9.1 MAT ERIAL LAYER BLEND TYPES
The Material Layer Blend
8
expressions are quite diverse and each represents a
specific blend type. T he material layer blend types allow you to control the way you
wish the material layers to be blended with each other, such as overriding specific
material features. The list below is adopted fro m the Unreal Engine 4’s official doc-
umentation [32].
TABLE 5.33: Material Layer Blend Types
MatLayerBlend_AO: Blends an ambient occlusion (AO ) map over the surface to
remove reflection.
MatLayerBlend_BaseColorOverride: Allows the Base Color to be replaced.
MatLayerBlend_BreakBaseColor: Outputs the Base Color from a n incomin g Ma-
terial Layer.
MatLayerBlend_BreakNormal: Outputs the Normal from an incoming Material
Layer.
MatLayerBlend_Decal: Blends a decal sheet over the Material using the 2nd UV
channel.
MatLayerBlend_Decal_UV3: Blends a decal she et over the Material Layer using
the 2nd UV channel.
MatLayerBlend_Emissive: Blends an Emissive texture over the Material Layer.
MatLayerBlend_GlobalNormal: Blends a No rmal texture over the Mater ia l Layer.
MatLayerBlend_LightmassReplace: Replaces the Base Color in Lightmass, al-
lowing for changes to indirect lighting results.
MatLayerBlend_ModulateRoughness: Multiplies the Material La yer’s Rough-
ness by an incoming texture. Useful for a “greasy” look.
MatLayerBlend_NormalBlend: Blends a Normal texture across the surface, but
by way of a mask texture , allowing for control of where the normal will appear.
MatLayerBlend_NormalFlatten: Diminishes the effect of th e Normal map.
MatLayerBlend_RoughnessOverride: Replaces the Roughness texture of a Mate-
rial L ayer.
8
The contents of this section are adopted from the official UE4 online documentation found at:
https://docs.unrealengine.com/latest/INT/.
296 Game Development and Simulation with Unreal Technology
MatLayerBlend_Simple: Provides a simple line ar inte rpolation (Lerp) blending so-
lution for 2 Material Layers. Does not blend Normal; instead , retains Normal of
the Base Mater ia l.
MatLayerBlend_Stain: Blends the Top Material over the Base Material as a stain,
meaning that only the Base Color and Roughness values from the Top Material
are used.
MatLayerBlend_Standard: Blends all attributes of two Material Layers.
MatLayerBlend_Tint: Allows for tinting of a Material Layer by inputting a tint
color and a mask to control the tint’s lo cation. Usef ul for makin g partial color
changes.
MatLayerBlend_TintAllChannels: Similar to Tint, but also affects Specular. This
is a very special case function; generally, you will not ne ed it.
MatLayerBlend_TopNormal: Blends all attributes of both Materials but only uses
the Normal of th e Top Material.
5.10 MATERIAL INSTANCES AND DYNAMIC MATERIAL
MODIFICATIONS
Instanced Materials refer to materials in which spe cific features are represented
as param eters in th e base mater ia l. T hese parameters are in turn available within the
Material Instance Editor for editing without the need to recompile the base ma-
terial. Th is is a very important feature for in-game and dynamic modificatio n of the
instanced materials. This ability to change instanc ed materials allows for modifying
the material while in gameplay in re sponse to in-game events.
In order to instance a material and change its properties in the instanced materials,
you need to represen t such features as parameters. A Material Parameter expres-
sion, as we discussed earlier in this chapter, is a data node that co ntains the default
values given to it in the Material Editor. However, you may refer to th e parameter
in-game, at level design, or in the Material Instance Editor by the parameter’s
name.
Unreal Engine 4 allows for two types of material instances, Constant and Dynamic.
A Constant material instance is calculated once, prior to the gameplay. You may not
change its parameters’ values in-game. Although these types of material in stances are
fixed and cannot be mod ified in-game, they still give yo u the performance advantage
since they do not require compilation.
A Dynamic material instance (Material Instance Dynamic or MID) is a material in-
stance which can be changed in-game at runtim e. Therefo re, you will be able to
create a blueprint script or C++ code to make changes to its parameters’ values. For
example, you can create a Material Instance Dynamic in blueprint scripts by using
Advanced Material Concepts in Unreal Engine 297
a Create Dynamic Material Instance blueprint expression. You can then use
the Set <...> Parameter Value expressions to make change s to the Material
Instance parameters.
5.11 DE CALS
Unreal Engine 4 allows yo u to defin e your material domains when you create th e
material in the Material Editor. Deferred Decal blend mod e is one of the four
available blend m odes along with Surface, Light Function, and Post-Process.
5.11.1 DECAL BLEND MODE
As the name suggests, this defines the Blend Mode that will be used w hen the Mate-
rial Domain property is set to Defe rred Dec al and cannot be changed until the Mate-
rial Domain is set accord ingly. It contains different Blend Modes than those available
to surfaces. Table 5.34 shows a description of different Decal Blend Modes avail-
able.
TABLE 5.34
Description of Decal Blend Modes in Unreal Engine 4
Mode Description
Translucent This will cause the decal to blend Base Color, Metallic, Specular, Rough-
ness, Emissive Color, Opacity, and Normal. With this you can blend in
an entirely separate material, such as a wavy water puddle, complete with
normal map-based muddy building around it.
Stain Only blends Base Color and Opacity. Useful for decals that only change
color, such as dry spray paint on a wall.
Normal Only blends Normal and Opacity. This is useful for adding cracks to a
surface.
Emissive Only blends the Emissive and Opacity channels. Nice for making things
glow that were not originally.
DBuffer_[Channel] These allow you control over individual channels.
Source: Epic Games Inc. Decals: https:
//docs.unrealengine.com/latest/INT/Resources/ContentExamples/Decals/index.html.
Deferred decals offer better performance since they write and work with the GBuffer
instead of calculating the lighting [11]. T his has the benefit of increased performance
in the presence of multiple light sources as well as the ability to ma nipulate a screen
space mask to create othe rwise complicated effe cts; such as liquid stains, etc.
5.12 POST-PROCESS MATERIALS
Post-process mater ia ls are a by-product of the composition graph and m ay be created
and assigned to the Post-Process Volume to create interesting features. However,
298 Game Development and Simulation with Unreal Technology
they should be used sparingly, as ma ny of the features such as bloom, depth of field,
etc., are already implemented w ithin the Post-Process Volum e efficiently.
5.13 REFRACTION AND REFLECTION
TABLE 5.35
Common Indices of Refraction
Material Air Ice Water Glass Diamond Silicon
Refraction Index 1.0 1.31 1.33 1.52 2.42 3.48
Table 5.35 shows a list of common solid and liquids with their refraction indices. In
optics the index of refraction is a number that describes how the light propagates
through a translucent object. This value in its simplest form is depende nt on the r atio
between the speed o f light in vacuum c and the speed of light as it pa sses through the
material v:
n =
c
v
(5.1)
FIGURE 5.13: Refraction of light rays passing from a medium with Refractive Index n
1
through a medium with a Refractive Index of n
2
.
Figure 5.13 shows what happens to the direction of a light ray whe n it passes from a
medium with refractive index of n
1
and enters another medium with refractive index
of n
2
. Let
θ
i
be the Angel of Incidence,
θ
r
is the Angel of Refraction, and
n
1
and n
2
be the two mediu ms’ Refractive Indices respec tively, then:
n
1
× sin(
θ
i
) = n
2
× sin(
θ
r
) (5.2)
..................Content has been hidden....................

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