666 Game Development and Simulation with Unreal Technology
TEXTURE OBJECT
This expression is used to provide a default texture for a texture function input within
a function. This node does not actually sample the texture, so it must be used in
conjunction with a Texture Sample exp ression.
Properties
Texture: Specifies the texture sampled by the expression.
Sampler Type: This is the type of data to be sampled from the node.
TEXTURE SAMPLE
This expression ou tputs the color value(s) from a texture. This texture can be a regu-
lar Texture2 D (including normal maps), a cu bemap, or a movie texture.
Properties
Texture: Specifies the texture sampled by the expression. To select a texture, you
might first Left-click on it in the Content Browser . When the texture is
selected in the Content Browser, c lick on th e Left Arrow in the Details
rollout of this expression in the Material Editor to apply the texture.
Sampler Type: This is the type of data to be sampled from the expression.
Mip Value Mode: Applies a noise value to the textur e.
Inputs
UVs: This input takes a UV Texture Coordinate to use for the texture.
Output s
RGB: Outputs the three-channe l RGB vector value of the color.
R: Outputs the red channel of the color.
G: Outputs the green c hannel of the color.
B: Outputs the blue channel of the color.
A: Outputs the alpha chan nel of the color.
A.15 UTILITY
These expre ssions allow you to perform some utility functio ns in unreal e ngine in
support of material and rendering functionalities. The following is adopted based on
a comprehen sive list of these functions, fo und online at Unreal Engine Documenta -
tion Pages [51].
BLACK BODY
This expression simulates the effects of black body radiation in a material. The user
may p rovide input par ameter temperature in Kelv in and connect the resulting out-
puts to the Base Color and Emissive Color channels of the material node for
physically accurate results.
Material Expressions in Unreal Engine 4 667
Example Usa ge: You can connect the Temp input channel of this expre ssion to a
network th at statically or dynamically derives the temperature in kelvin of a ma-
terial (such as lava, stars, e tc .). Feed the o utput result of this expre ssion to the
Base Color and the Emissive Color channels of the material to achieve phys-
ically realistic results. Figure 4.74 shows a network that moves noise texture co-
ordinates, while the no ise texture samples tempe ratures ranging between 500
K
(cold) to 5000
K (hot) on a surface of a radiating object.
BUMP OFFSET
This expression is the Unreal Eng ine 4 term for wh at is c ommonly known a s ‘p ar-
allax mapping’. The Bump Offset expression allows a material to give the illu-
sion of depth without the need for ad ditional geometry. Ma te rials with bump off-
set use a grayscale heightmap to give depth information. The brighter the value in
the heightmap, the more ‘popped out’ the material will b e; the se areas will paral-
lax (shift) a s a camera moves across the surface. Darker a reas in the heightmap are
‘further away’ and will shift the least.
Properties
Height Ratio: Multiplier for the depth ta ken from the heightmap. The larger the
value, the more extreme the d epth will be. Typical values range from 0.02 to
0.1.
Reference Plane: This value specifies the approx imate height in texture space to
apply the effect. A value of 0 will appear to distort the texture co mpletely
off the surface, whereas a value of 0.5 (the default) means that some of the
surface will pop off while some areas will be sunken in.
Inputs
Coordinates: This input takes in base texture coordinates to be modified b y the
expression.
Height: This input takes in th e texture (or a value) to be used as the heightmap.
Height Ratio Input: This input is the multiplier for the depth taken from the
heightmap. The larger the value, the more extreme the depth will be. Typical
values r ange from 0.02 to 0.1. If used, this input supersedes any value in th e
Height Ratio property.
CONSTANT BIAS SCALE
This expression takes an input value, adds a bias value to it, and then multiplies it
by a scaling factor outputting the result. So for example, to convert inp ut data from
[-1,1] to [0,1] you would use a bias of 1.0 and a scale of 0.5.
Properties
Bias: This value specifies the bias to be added to the input.
Scale: This value specifies the multiplier for the bias result.
668 Game Development and Simulation with Unreal Technology
DDX AND DDY
The DDX expression exposes DDX derivative calculatio n, a GPU hardware fe ature
used in pixel shader calculation.
The DDY expression exposes DDY derivative calculation, a GPU hard ware feature
used in pixel shader calculation.
DEPTH FADE
This expression is used to hide unsightly seams that take place when translucent
objects intersect with opaque ones.
Properties
Fade Distance: This value is the world space distance over which the fade should
take place. This is used if the Fade Distance input is unconnecte d.
Inputs
Opacity: This input takes in the existing opacity for the object prior to the depth
fade.
Fade Distance: This in put takes in the world space distance over wh ic h the fade
should take place.
DEPTH OF FIELD FUNCTION
This expression is designed to give artists control over what happen s to a Material
when it is being blurred by Depth of Field. It outputs a value between 0-1 such
that 0 represents "in focus" and 1 represents "completely blurred." This is useful for
interpolating be tween sharp and blurry versions of a texture, for instance. Th e Depth
input allows for the existing results from the scene’s De pth of Field calculations to
be overridden b y other calculations.
DESATURATION
This expression converts the colors of its input to softer shades based on a ce rtain
percentage. Let X be the original color, L be the Luminance Facto r and f be the
Fraction value, then the desaturated color D will be calculated according to the
following equation:
D = (1 f ) × (X L)+ f × X (A.15)
Properties
Luminance Factors: This property specifies the amount of each channel’s con-
tribution to the desaturated color.
Inputs
Fraction: This input value spec ifies the amount of desaturatio n to apply to the
input color, or texture . An amoun t of 0 is used for no desaturation (full
original color), or an amount of 1 is u sed for full desatura tion (no colors,
only greyscale).
Material Expressions in Unreal Engine 4 669
Example Usa ge: Use this expression to soften the colors of high contrast color ed
textures. You can con trol how much of the red, green o r blue colors of the original
texture to keep based on the Luminance Factor you can specify. Figure 4.76(a)
shows an original texture applied to the Base Color and the Emissiv e Color
channels of a material. Figure 4.76(b) shows the same texture applied to the
Base Color and Emissive Color channels after being desatura te d with the
Luminance Factor of (R:0.33, G:0.51, B:0.11) and 20% Fraction.
DISTANCE
This expression calculates the Euclidean distance between two vector s. These vectors
could represent colors, positions, etc. The expression can take on vectors with any
number of dimensions.
Inputs
A: The first input vector of any dimension.
B: The second input vector of any dimension.
FEATURE LEVEL SWITCH
This expression is useful to allow you to create different networks with varying levels
of complexity to target for different platform s. For example, you might create a ma-
terial with complex mathematics and many textures to target for hig h-end consoles,
but simpler texture and math to target mobile devices.
Inputs
Default: The default feature level.
ES2: Feature Level defined for core capabilities of OpenGL ES2.
ES3.1: Feature Level defined for core capabilities of Metal-Level devices
(OpenGL ES3.1).
SM4: Feature Level defined for core capabilities of DirectX 10 Shad er Model 4.
SM5: Feature Level defined for core capabilities of DirectX 11 Shad er Model 5.
FRESNEL
This expression calculates the amount of fall-off based on the dot prod uct of the sur-
face norm al and the viewer vector. In other words, if the viewer is directly looking at
a surface the ou tput value is 0. When the viewer is looking at the surface perpendic-
ularly, the fresnel will output a value of 1. The result of this expression is clamped
to [0,1]. Mathematically, let N be the surface normal, V be the camer a vecto r, and
p be the exponent value, the Fresnel output is calculated acc ording to th e following
equation :
FRES(N, V, p) = (1 N V)
p
(A.16)
In UE4, the Fresnel expression also takes into account a Base Re flection
Fraction value, b. This value augments the result of the Normal and Camera vector
670 Game Development and Simulation with Unreal Technology
dot p roduct to account f or the fraction of the light specular reflection on the surface.
A value of 0 for b is equivalent to the above equation, while a value of 1 for Base
Reflection Fraction disables the Fresnel. The complete equation for the Fres-
nel expression is as follows:
FRES(N, V, p, b) = [1 ((1 b) × (N V))]
p
(A.17)
Properties
Exponent: This p roperty specifies how quickly the result fall-off. The value p
in equations (A. 16) and (A .17). Larger values make the result fall off more
quickly and have tighte r boun daries.
Base Reflection Fraction: This pr operty specifies the amount of specular reflec-
tion if viewed straight on. A value of 1 disables the Fresnel expression.
Inputs
Exponent In: This input specifies the fall of values. It will replace the Exponent
property if connected.
Base Reflection Fraction: This input specifies the fr action o f specular reflec-
tion if viewed straight on. It will replace the Base Reflection Fractio n
property if connected.
Normal: This input takes in a 3D vector as the Surface No rmal. If you have
used a normal map in the material, you can connect this input to a Vertex
Normal WS expression to ac count for the normal map of the object. If this
input is no t connected, the engine will use the Tangent normal of th e mesh.
Example Usage: Use this exp ression to simulate proper and physically accurate re-
flection/refraction o f reflective and translucent objects. This expre ssion is widely
used to simulate water, glass, an d other reflective and refractive surfaces. Fig-
ure 4.77(a) and Figure 4.77(b) show two materials with a Fresnel expression with
exponent values of 1 and 5, resp ectively, controlling the Emissive Color and
Opacity channels. Figure 4.77(c) shows the network.
GI REPLACE
This expression allows artists to specify a different, usually simpler, expression chain
when the material is being u sed for Global Illumination.
Inputs
Default: The default GI.
Static Indirect: This input is used for baked indir ect lighting.
Dynamic Indirect: This input is used for dynamic indirect lig hting.
LIGHTMASS REPLACE
This expression simply passes through the Realtime inp ut when compiling the ma-
terial for normal rendering purposes, an d passes throug h the Lightma ss input when
exporting the material to Lightmass for glob al illumination. This is useful to work
..................Content has been hidden....................

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