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