A
Material E xpressions in Unreal
Engine 4
T
HIS appendix presents a reference to all material expression nodes available in
Unreal Engine 4. The contents o f this chapter are a dopted form UE4 official
online docume ntations [36].
A.1 IN TRODUCTION
Material Expressions are the building blocks of materials in Unreal Eng ine 4. T hey
are the mathematical terms that either provide values or perform cer ta in op erations
needed in the calculation of the light-material interactions.
A.2 ATMOSPHERE EXPRESSIONS
This category includes expressions that interact with the atmospheric effects at post-
process stage o f the pipeline [1].
ATMOSPHERIC FOG COLOR
This Material Expression allows you to query the current color of the level’s Atmo-
spheric Fog, at any position in World Space. If no World Position is fed into it, th en
the world position of the pixel in question is used. This is useful when you need
Materials to appear to fade into a distant fog color.
A.3 CO LOR
This category of expressions inclu des those that interact with the color of inpu t chan-
nels by performin g certain mapping on them. As of Unreal Eng ine 4.6, the only
expression in this category includes Desaturation [5].
DESATURATION
The Desaturation expression desaturates its input, or converts the colors of its inpu t
into shades of gray, based on a certain percentage. As an example, if the d esaturation
color input vector is D, the input color is I and the luminance factor is L, then the
output value will be calculated according to the following equations:
O = (1
α
) × (D · I) +
α
× I (A.1)
where O is the output color vector, · is the dot pr oduct, and
α
is the percentage
parameter of the Desaturation expression.
631
632 Game Development and Simulation with Unreal Technology
Properties
Luminance Factor: Spec ifies the amount that each channel contributes to the
desaturated color. This is what controls that green is brighter than red which
is brighter than blue when desaturated.
Fraction: Specifies the amount of desaturation to apply to the input. Per cent can
range from 0.0 (fully desaturated) to 1.0 (full original color, no desatura-
tion).
A.4 CO NSTANT EXPRESS IONS
The items in this category represent material expressions whose valu es do not gen-
erally change once set in the editor or when the play begins [7]. These expressions
include the following item s:
CONSTANT
The Constant expression outputs a single float value. It is one the most commonly
used expressions and ca n be connected to any input, regardless of the number of chan-
nels the input expects. For instance, if you conne ct a Constant to an input exp ecting
a 3 Vector, the constan t value will be used for all 3 elements. When supplying a sin-
gle number, it can be useful to collapse the node using the small triangle icon in the
description area.
Properties
R: Specifies the float value of the expression output.
Shortcut: To place th is expression, you may hold the key 1 on your keyboa rd and
left-click in the graph editor.
Example: 0.7, -10, 2.35
CONSTANT 2VECTOR
The Constant2Vector expression outputs a two-channel vector value, in other words,
two constant numbers.
Properties
R: Specifies the first float value of the expression output.
G: Specifies the second float value of the expression output.
Shortcut: To place th is expression, you may hold the key 2 on your keyboa rd and
left-click in the graph editor.
Example: (0.7, -10) o r (2.35, 247)
Usage Example: You may use this exp ression to modify texture coordinates, sinc e
the texture coordinates are 2-dimensional.
Material Expressions in Unreal Engine 4 633
CONSTANT 3VECTOR
The Constant3Vector expression outputs a three-cha nnel vector value, in other words,
three constant numbers. An RGB color can b e thought of as a Constant3Vector,
where each ch annel is a ssigned to a color (red, green, blue).
Properties
R: Specifies the first float value of the expression ou tput.
G: Specifies the second float value of the exp ression ou tput.
B: Specifies the third float value of the expression ou tput.
Shortcut: To place this expression, you may hold the key 3 on your keyboard and
left-click in the graph editor.
Example: (0.35, 0.75, 0.75), (0.7, -10, 2.0) or (150, 235, 247)
Constant4Vector
The Constant4Vector expression outputs a four-channel vecto r value, in other words,
four constant numbers. An RGBA color can be thought of as a Constant4Vec tor,
where each ch annel is a ssigned to a color (red, green, blue, alpha).
Properties
R: Specifies the first float value of the expression ou tput.
G: Specifies the second float value of the exp ression ou tput.
B: Specifies the third float value of the expression ou tput.
A: Specifies the fourth float value of the expression output.
Shortcut: To place this expression, you may hold the key 4 on your keyboard and
left-click in the graph editor.
Example: (0.35, 0.75, 0.75, 0.0), (0.7, -10, 2.0, 0. 76) or (150, 235, 247, 100)
DISTANCE CULL FADE
The Distance Cull Fade expr ession outputs a scalar value that fades from black to
white and can b e used to fade an object in once it comes within the cull distance. It
should be noted that it does not fade the object out. This expression is quite useful if
applied to the Opacity c hannel of the material nodes to make them fade in and out
of view when the camera comes within the Cull distance (instead of popping in and
out).
PerInstance Fade A m ount
The PerInstance Fade Amount expression outputs a float value associated with
the amount of fade ap plied to an instanced Static Mesh, such as foliage. It is constant,
but can be a different number for each ind ividual instance of a mesh.
Note: This expression works only when it is applied to an Instanced Static Mesh
Actor or othe r Actors that utilize Instanced Static Mesh Components.
634 Game Development and Simulation with Unreal Technology
PerInstance Random
The PerInstance Random expression outputs a different ra ndom float value per
Static Mesh instance to which the material is applied. Instance d Static Mesh Com-
ponen t sets a random float for instance, which is exposed so that it can be used for
whatever is desired (e .g., ra ndom light level b ehind a window). It is constant, but
different, for each instance of the mesh.
The output value will be a whole number between 0 and RAND_MAX for the target
platform.
Note: This expression works only w hen it is applied to an Instanced Static Mesh
Actor or other Actors that utilize Instanced Static Me sh Components.
TIME
The Time expression is used to add the passage of time to a material, su ch as by a p-
plying it to a Panner, Cosine, or other time-dependent expressions and operations.
Properties
Ignore Pause: If set to true, this expression will continue to march on even if
the game is paused.
Usage Example: You may con nect the output channel of the Time expression to
the input of a Sine expression to create d ynamic value s that range between -1.0
to + 1.0 in value.
TWO-SIDED SIGN
The Two-Sided Sign expression is useful for flipping the no rmal on backfaces of
two-sided custom lig hting materials to match the functionality of the Phong shad-
ing models. Use the value of +1 for frontfaces, and -1 for backfaces of a two-sided
material.
VERTEX COLOR
The Vertex Color expression is the access point for the material to the outputs of
color module s affecting sprite particles emitters.
Properties
RGB: Specifies the RGB (3-channel) value of the expression output.
R: Specifies the Red color value of the expression output.
G: Specifies the Gree n color value of the expression output.
B: Specifies the Blue color value of the exp ression ou tput.
A: Specifies the Alpha value of the expression output.
Usage Example: Use the RGB and Alp ha output channels of this expression to mul-
tiply by the RGB and Alpha channe ls of a TextureSample expression to cr eate
sprite colors for a particle system.
Material Expressions in Unreal Engine 4 635
A.5 CO ORDINATE EXPRESSION S
These expressions utilize the 2D or 3D coordinate systems in the World Space or Tex-
ture Coordinates to enable interactions between these coordinate spaces and certa in
aspects of the ma te rials [9].
ACTOR POSITION WS
The Actor Position WS expression outputs a 3-vector (RGB) data representing the
location, in world space, of the object on which this material is applied.
Usage Example: This expression can be used to change the color of a mesh as it
moves across the world, or to apply the same material to different parts of the
level geometry and have the e ngine change the c olor of each part according to its
location –i.e., geograph ic ally color-coding objects.
CAMERA POSITION WS
The Camera Position WS expression outputs a three-channel vector value repre-
senting the c amera’s position in world space.
Usage Example: This expression can be used in a network to make the mesh on
which the material is applied change color depending on the direction viewed by
the camera.
LIGHTMAP UVs
The Lightmap UVs expression outputs the lightmap UV texture coordinates in the
forum of a two-channel vector value. If lightmap UV s are unavailable, it will output
a two-channel vector value of (0,0) .
OBJECT ORIENTATION
The Object Orientation exp ression outputs the world-space up vector of the object.
In other words, this is the direction of the local positive Z-axis of the object, on which
the material is applied, is pointing.
Usage Example: This expression can be connected to the color input channels of
a material node to change the color of a mesh as it rotates, or to apply the sam e
material to different parts of the level geometry and have the engine change the
color of each part according to its up vector (orientation).
OBJECT POSITION WS
The Object Position WS expression outputs the world-space center position of
the object’s bounds. This is useful fo r creatin g spherical lighting for a foliage, for
example.
..................Content has been hidden....................

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