180 Game Development and Simulation with Unreal Technology
It is highly recommended that you play around with some of the values of the
expressions to see how they are affected. Try increasing or d ecreasing the values of
the World Displacement constant or adding a constant value to the Tessellation
Multiplier ch annel. There is no limit to what you can do with the Material Editor
in Unreal Engine 4!
4.6 MATERIAL EXPRESSION S IN UNREAL 4
The third, and most important, component of a material is the collection of Ma terial
Expressions that make up the mater ia l itself. Material Expressions are the building
blocks of mate rials. To those readers who are mathem atically inclin ed, the material
expressions are like terms in the mathematical equations that govern each aspect of
a material.
FIGURE 4.46: Material Expression Components.
Each of the many Ma te rial Expressions in Unreal Engine 4 are used to give spe-
cific effects to a material, such as adding a texture, adding scalar or vector values,
panning materials over time, or modifying the UV coordina te s of the material. By
using combinations of simple Material Expressions, it is possible to create elabo-
rate textures that can make an object come to life.
Figure 4.46 sh ows a Texture Sample material expression with its components.
Each material expression has these ve components: Description, Title Bar, Inputs,
Outputs, and Preview. Descr iptions of each of th ese components are presented below:
Description: All material expressions have a common property called Desc in their
Details rollout. The text provided for this property will be shown in the Material
Editor to show short notes about the functionality of the expression . Yo u may
enter any text in the Description section.
Title Bar: This compon ent displays the name or any important infor mation about
the material expression.
Inputs: These are links that can be connected to the output channels of other expres-
sions to carry in put values into the expression.
Materials in Unreal Engine 181
Outputs: These are links that p rovide the output values of the materia l expre ssions
calculations to other expressions or to the input cha nnels of a material node.
Preview: A small window th at shows how the value of the expression looks. It basi-
cally is a 2D bitmap of the values of the expression. If the expression is a constant,
the preview will show black or white, or a shade of grey depending the value. If
the expression is a vector, then this preview will be a color associated to the RGB
values of the expression . You may expand or collapse the exp ression by clicking
on th e Triangle icon on the Tool Bar of the Material Expression. This window
updates if the real-time update is enabled, or can be updated manually by pressing
space-bar on the keyboard.
TABLE 4.8
Frequently Used Categories of Material Expressions
Most Commonly Use d Material Expressions
TextureSample2D Scalar Param eter
VectorParameter VertexColor
LinearInterpolat e Fres nel
Mathematical Material Expressions
Abs Floor
Add Frac
Ceil Multiply
Cosine OneMinus
CrossProduct Power
Divide Sine
DotProduct Subtract
Texture Coordinate Material Expressions
TextureCoordinat e Panner
Rotator Time
4.6.1 PARAMETER VS. NON-PARAMETER EXPRESSIONS
Certain material expressions are parameters while other are not. A parameter makes
the value of the expression exposed to the run-time compon ent of the engine to allow
for it to be modified. On e of the most basic ways of using material parameters is to
create a Material Instance from the base material. The para meters in the material
instance will be available at level-design in the editor or at run-time to modify and
dynamic ally change.
To change the values of a parameter in a material expression, you must use its
Parameter Name. The p arameter nam e will be available to the run-time engine
to programma tically alter its valu e as well. For this reason it is important to set a
meaning ful Parameter Name for each Paramete r Expression in a mater ia l. If there
are mu ltiple material parameters with the same Parameter N ame, the engine will
assume them to be the same parameter. Changin g the value of one of these duplicate
182 Game Development and Simulation with Unreal Technology
parameter s will change the values of all of its duplicates. You may also assign a
Default value to the Material Parameters at creation of the parameters.
4.6.2 COMMONLY USED MATERIAL EXPRESSIONS
Table 4. 8 lists a breakdown of some commonly used mate rials expressions. We will
discuss the functions of some useful and commonly used Material Expression s
below [36]. A more compreh ensive list and descriptions of functionalities may be
found on the Unreal Engine documentation Website
1
.
CROSS-REFERENCE
More details about the Material Expressions may be found in Appendix A.
4.6.2.1 Constant Expressions
Constant expressions
2
can be of the form of a single-valued, multivalued (e.g., Vec-
tors), or dynamically changing items, but are gener ally fixed and do not change once
their values are set in the editor. However, ce rtain c onstant expressions (such as Time
and Particle Color) are available for the engin e to control and update their values [7].
Constant: This expression outputs a single floating-point value i.e., a real-valued
number. Its output can be conn ected to the input of any other expression. For
example if it is connected to an expre ssion that needs a 3Vector value, the en-
gine will cast its output into a 3Vector value automatically. A description of the
properties of a Con stant expr ession are listed below:
TABLE 4.9: Constant
Properties
R: Specifies the float value of the expression output.
Constant2Vector: Th is expression outp uts two floating-point values. Its output ca n
be considered as a 2D vector. Expression properties include:
1
https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/
ExpressionReference/index.html
2
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 183
TABLE 4.10: Constant2Vector
Properties
R: Specifies the first flo a t value of th e expression output.
G: Specifies the second float value of the expression ou tp u t.
Constant3Vector: Th is expression outputs three floating-point values. Its output
can be considered as a 3D vector. You can use this expression to specify a color
(RGB values) or a point in 3D space (XYZ ) values. The X, Y, and Z values in
space correspond to the values R, G, and B, re spectively.
TABLE 4.11: Const3Vector
Properties
R: Specifies the first flo a t value of th e expression output.
G: Specifies the second float value of the expression ou tp u t.
B: Specifies the third float valu e of the expression output.
Constant4Vector: Th is expression outputs four floating-point values. Its output can
be considered as a 4D vector. You can use this expr ession to specify a color-alpha
(RGBA values) or a point in the 4D homogenous space (XYZW) values. The X,
Y, Z, and W valu es in space correspond to the values R, G, B, and A, respectively.
Expression properties include:
TABLE 4.12: Const4Vector
Properties
R: Specified the first floa t value of the expression outpu t.
G: Specified the second flo a t value of th e expression output.
B: Specified the thi rd float value o f the expression ou tp u t.
A: Specified the fourth oat value of the expression output.
NOTE
If you need to separa te the output channels into its R, G, B, or A compo-
nents you must use a Compo nent Mask expression. For more inf ormation
on Component Mask refer to page 188.
184 Game Development and Simulation with Unreal Technology
Time: This expression is used to add the passage of time to the material’s calcula-
tions. There are a number of different ways that this expression will be useful.
For examp le using it as the input to a Panner o r Rotator expression to move a
texture map on the surface of a mesh. Or you can use this expression as the input
of a Sine or Cosine expression to cr eate a dynamically changing value between
-1.0 and + 1.0. T he Time expression properties include:
TABLE 4.13: Time
Properties
Ignore Pause: If this property is set to True, the ti m e will continue to
pass even after the g a m e is paused .
Vertex Color: This expression is useful to access the material that will be rende red
on a modules of sprite par ticle emitters.
4.6.2.2 Mathematical Expressions
Mathematical expressions
3
in Unreal Engine’s m aterials allow us to combine values
from other expression, variable, and objects in the game and create values that are
useful for our calculations of all aspects of a material. These expressions are basically
mathematical functions they take some input values and combine these inputs to
generate a resulting values [40].
Abs: This expression takes a value (positive or negative), drops the sign and returns
the absolute value of the input it receives. I n math ematical terms, the absolute
value of a number x is calculated according to the following equation:
ABS(x) = |x| =
x x 0
x x < 0
(4.1)
Examples: Abs of -3.4 is 3.4 a nd Abs of 4.32 is 4.32. We write this mathe mati-
cally as | 3.4| = 3.4 and |4.32| = 4.32, respectively.
Example Usa ge: The Abs expression is commonly used on the result of a Dot
Produc t to take the sign of the valu e out and use the actual number, regard-
less of whether it is positive or negative (see Figure 4.47). In this example,
3
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.21.106.7