Materials in Unreal Engine 185
we are using the Dot Product to calculate the angle between the reflection
vector and the camera vector. The brighter color represents when the two
vectors align.
FIGURE 4.47: Abs Expression Example.
Add: This expression takes its two input values (A and B) and returns the sum-
mation of the two values. The addition operation is performed on a per-channel
basis. In othe r words, if y ou add to Constant3Vectors, the result will be a Con-
stant3Vecto r in which the R, G, and B com ponents are the sum of the two input
R, G, and B channels, respectively.
Mathematically speakin g, Let X and Y be two N-channel vectors. Then the Add
expression of these two values will be:
ADD(X,Y) = X + Y = [x
1
+ y
1
,x
2
+ y
2
,··· ,x
N
+ y
N
] (4.2)
TABLE 4.14: Add
Properties
Const A: Take the value to add to. Only used if the A input channel is
not connected.
Const B: Take the value to be added to. Only used if the B input channel
is not connected.
Inputs
A: Take the value to add to.
B: Take th e value to be added.
Example Usa ge: You can connect the outpu t channels of two Texture Sample
expressions to the A and B inputs of an Add expression to create a com-
bination of the two textures. Note: If the result of the Add expression on
186 Game Development and Simulation with Unreal Technology
two Texture Sam ples is used as base co lor it brightens the material (see
Figure 4.48).
FIGURE 4.48: Add Expression Example.
Append Vector: This operation, as the name suggests, takes in two inputs and cre-
ates a vector from these two inputs by appending th e B input channel value to the
end of the A input cha nnel value. For example, if you use two Constant expres-
sions c
1
and c
2
and connect them to the A and B input ch annels of the Append
Vector expression, the output will be a 2-channe l vector with c
1
being the first
component, and c
2
being the second component.
TABLE 4.15: Append Vector
Inputs
A: Take the value to append to.
B: Take the value to be appended.
Example Usa ge:
To create an RGB color from three Constant values r,g, and b
you may use two A ppend Vector expressions, connect the r and g to the
A, and B, channel of the first expression. Then connect the result of the first
expression to the A channel, and the value b to the B channel of the second
expression (see Figure 4.49).
Ceil: This operation, as the name suggests, takes in one input and returns its ce iling
value - i.e., rounds the input up to the next integer number. If the input to this
expression is a vector, then the expression outpu ts the ceiling on a per-channel
basis.
Example: The ceiling of 3.4 is 4, and the c eiling of 3.9 is also 4.
Example Usa ge: You can multiply a vector or constant b y some constant K, then
take the ceiling of the result and divide it by the same K to create bands with
Materials in Unreal Engine 187
FIGURE 4.49: Append Vector Example.
FIGURE 4.50: Ceiling Expression Example.
varying colors (see Figure 4.50). In this example we use a Radial Gradient
Exponential expression to create values that ran ge from 0 to 1. We then use
the Ceiling expression to create the conc entric bands th at are supplied to the
Base Color o f the material. To make the bands to be parallel lines instead
of concentric circles, you may use a Linear Gradient instead of the Radial
Gradient Exponential expression.
Clamp: This expression takes one input cha nnel, one MIN input and one MAX in-
put, and returns a clam ped output from the input value. If th e input value is le ss
than MIN, the output will return MIN. If the input value is greater than MAX,
the output returns MAX. Oth erwise, the expression returns the input value un-
changed.
Mathematically, let x be the input value, and MAX and MIN be the maximum
and minimum clamp input values, the output o w ill be calculated ac cording to the
following equation:
CLAMP(x,MIN, MAX ) =
MAX x MAX
x MIN < x < MAX
MIN x MIN
(4.3)
188 Game Development and Simulation with Unreal Technology
TABLE 4.16: Clamp
Properties
Clamp Mode: Selects th e type of clamp. CMODE_Clamp will clamp bo th
ends of the rang e . CMODE_Clamp Min and CMODE_ClampMax will only
clamp their respective ends of the range.
Min Default: Ta kes in the valu e to us e as the minimum when clam p ing.
Only used when the Min input is unused.
Max Default: Takes in the value to use as the maximum when clamping.
Only used when the Max input is unused.
Inputs
Min: Takes in the value to use as the m inimum when clamping.
Max: Takes in the value to use as the maximum when c lamping.
Example Usa ge: When you want to ensure that the result of a calculation never
falls o utside of a certain range, you can use the minimum and maximum
values of the range to ensure yo ur output will always be in ran ge.
Component Mask: This expression allows you to select a specific subset of chan-
nels (R, G, B, and/or A) from the expression ’s input to pass through to the expres-
sion’s outputs. The current channels selected to be passed through are displayed
in the title bar of the expression. In case of the expressions that are more than
one-dimensional, if the channel is not available an error will occur if you check
that channel to be passed through. A description of the properties of a Constant
expression are listed below:
TABLE 4.17: Component Mask
Properties
R: If checked, the Red (or first) component of the vector will be mas ked
and available to pass through from input to output.
G: If checked, the Green (or second) component of the vector will be
masked and available to pass th rough from in p u t to output.
B: If checked, the Blue (or third) com ponent of the vector will b e masked
and available to pass through from input to output.
A: If checked, the Alpha (or fourth) component of the vector will be
masked and available to pass th rough from in p u t to output.
Example:
If you have an RGB Constant3Vector o f (1.2, 3.2, 5.3, 1.0) as the input
to this expression and check the R, a nd A boxes, the output will be (1.2, 1.0).
Materials in Unreal Engine 189
Cosine: This expression calculates a nd return s the cosine of its input value. Note
that the input value is always in radians (and not in degrees). By connecting the
output channel of a Time expression to this expression y ou will be a ble to create
a waveform that oscillates between -1.0 and +1.0 over time.
TABLE 4.18: Cosine
Properties
Period: Specifies the period of the resulting wave form. Larger values
result in sl ower osci llations while smaller values result in faster oscil-
lations.
Example Usa ge:
To create a pu lsatin g material, connect the Time expression to
the input of a Cosine expression and plug the output channel of the cosine
to the Emissive Color channel of the material node.
Divide: This expression takes its two input values and returns the division of the first
value by the second value. The division ope ration is performed on a per-channel
basis. Mathematically speaking, Let X and Y be two N-channel vectors. Then the
Divide expression of these two values will be:
DIVIDE(X,Y) =
X
Y
=
x
1
y
1
,
x
2
y
2
,··· ,
x
N
y
N
(4.4)
TABLE 4.19: Divide
Properties
Const A: Take the value to be divided. Only used if the A input channe l
is not connected.
Const B: Take th e value to divide by. Only used if the B input channel is
not connected.
Inputs
A: Take the value to be divided, the dividend.
B: Take th e value to divide by, the divisor.
Example Usa ge: You can conne ct the output channe ls of one Texture Sample
expression to the A and a Constant value to the B input of a Divide ex-
pression to make the texture look dimmer. Note: The constant v alue must
be greater than 1.0 to make the texture dimmer. If the constant value is less
than 1.0, the texture will look brighter.
..................Content has been hidden....................

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