Materials in Unreal Engine 175
ADDING GLOSSINESS WITH METALLIC CHANNEL
We created the same n etwork as the one for the Roughness channel of our ma-
terial for the Metallic channel. Since the moist areas are a bit glossy we want
the network to be similar to the rou ghness channel network. We used a Lerp ex-
pression to interpolate between a metallic value of 0.7 on the brick to 0.2 on the
grout. The effec t looks pretty neat!
APPLYING MATERIALS IN THE DEMO ROOM
In order to compare the results of our work in the past two tutorials, we created
three p review mesh props on a new display item. We applied our depth modified
material to the le ftmost prop, our moist material with the roughness chann el on
the middle prop, a nd the m oist and metallic material on th e rightmost prop.
We noticed tha t our material that incorporated a metallic channel looks a bit
dim. We simply multiplied its Base Colo r by 2, to make it look more comparable
to the other materials we have created.
We finally placed three spotlights in the scene to shine some light on our three
materials to see the differences more easily.
Now that we have our material looking pretty impressive, we are going to step into
one of the newest features of Unreal Engine 4 in regard s to materials. As mentioned
earlier in this chapter, Unreal Engine 4 allows for materials to actually change the
geometry. This can be done in two ways: (1) manipulate the World Position Off-
set channel and (2) utilize the Tessellation Multiplier and World Displacement
channels.
We will use the World Displacement channel in the following tutorial to add
more depth to the material via this cha nnel.
FIND ON THE WEBSITE
To find updates to this tutorial and u pdated instructions about its implementa-
tion on other UE 4 versions, please visit the books companion Website at:
http://www.RVRLAB.com/UE4Book/
TUTORIAL 4.4 Adding More Depth via Displacement
Thus far, yo ur focus has been on adding a type of simulated depth to your
brick wall material by m anipulating the way light interacts with it. However,
Unreal Engine 4 has the ability to change the actual geometry of the mesh using
the World Displacement channel. When you utilize this channe l, the material
actually modifies the polygons of the object in o rder to create real depth.
176 Game Development and Simulation with Unreal Technology
CREATING TH E WORLD DISPLACEMENT NETWORK
Let us now add some more depth to our mater ia l to make it actually look 3D.
(a) (b)
FIGURE 4.44: (a) You need to change the D3D11Tessellation Mode for this network to work.
(b) The network that uses a texture map to modify the mesh vertices’ geometry.
1. In the content browser, open the folder whe re you have been c reating your mate-
rials so far.
2. Right-click on the last material y ou created (the Mat_Enh anced_NormalV2) and
choose duplicate.
3. This will make a duplicate copy of your material with all expressions carr ie d over.
4. Right-click on this Duplicate material (or press the F2 key) to rename it to
something like Mat_Advanced_WD.
5. Select the mate rial node and in the Details panel scroll down to the section called
Tessellation.
6. In the Tessellation section change the D3D11TessellationMode to Flat
Tessellation (see Figure 4.44(a)). This will activate your materials tessella-
tion to be processed by DirectX 11. (Note: This mode is only available if your
hardware supports DirectX 11).
7. Add a TextureSample exp ression (by holding the T key on your keyboard and
clicking on the graph editor) to the graph.
8. Change this TextureSamples texture to T_Brick_Hewn_Stone_M.
9. Add a Constant below this TextureSample and set its value to 1.25.
10. To the right of these two expre ssions, create a Multip ly expression.
11. Connect the Green outp ut channel of the TextureSample expression to the A
input of the Multip ly expression.
12. Connect the output channel of the Constant expression to the A input of the
Multiply expression.
13. Add a Vertex N ormalWS expression above the TextureSample expression. To
do this, right- click above the TextureSample and type Vert exNormalWd in the
Materials in Unreal Engine 177
search box. This expression will output a normal vector for each vertex of a mesh
so th at your m aterial c an modify it to apply the ge ometry change to your mesh.
14. Create another Multiply expression to the right of the VertexNormalWS and
TextureSample.
15. Connect the VertexNormalWS output to the inpu t A of the Multiply expression .
16. Connect the output channel of the first Multiply expression to the input B of the
Multiply expression (see Figure 4.44(b)).
17. This combination of expressions will modify the amount that the vertices are off-
set. The lighter areas of the texture will move the vertices of the object in the
positive direction (outward), and the d arker a reas will move them in the negative
direction (inward), creating actual depth.
18. Connect output of th e last Multiply expr ession to the now activated World D is-
placement channel of your material node.
19. Save your material so far.
FIGURE 4.45: Tutorial 4.4 Material Progression.
APPLYING MATERIALS IN THE DEMO ROOM
Now we will place the last of each ma te rials we create d in each section side-by-
side in the Demo Room to showcase o ur progress.
20. In the co ntent browser, look for a folder inside the Demo Room folde r called
Blueprints and open it.
21. Drag a copy of Display Item onto the level and place it to the right of the second
Display Item. Change its properties to the following:
178 Game Development and Simulation with Unreal Technology
Number: 3-M.
Description: Basic Materials Comp arisons. . .
Type: Square-L.
22. In the conten t browser, look for a folder called Props and open it.
23. In the Props folder look for and find a mesh called SM_MatPreviewMesh_02
and drag it into the Display Item you have already placed in the Demo Room.
24. Rotate, scale , and position the mesh so that it faces ou twards from the Display
Item.
25. Alt-Drag the mesh to create two copies of it on the Display Item (see Fig-
ure 4.36). You ca n altern atively copy and paste the mesh in th e editor on the
Display Item.
26. Now let us bring some spotlights into the room and pla ce them in front of the
props in our demo display item:
a. In the Modes tab (top-left corner of the editor) click on Lights section.
b. Drag a spotlight into the demo ro om and place it in front of the left mesh
(see Fig ure 4.41).
c. Rotate the light so that it faces the mesh (you need to pre ss the E key on you r
keyboard to activate the rotate gizmo, rotate the light, and press the W key to
get the translate gizmo back) (see Figu re 4.41).
d. In the D etails Panel of the spotlight, go to the Light section and change
the Intensity to 100.
e. Also in the Light section find and uncheck the Ca st Shadows checkbox.
f. Alt-Drag the spotlight to create two copies of the spotlight and place them
in front of the other props (see Figu re 4.3 6). You can alternatively copy and
paste the mesh in the editor on the Display Item.
27. Select the lef t mesh in the Demo Display you created in step. Drag the
Mat_Enhanced_Norma l material to its Element 0 mater ia l slot.
28. Select the middle mesh in the Demo D isplay you created above. Drag the
Mat_Enhanced_Norma lV2 material to its Element 0 material slot.
29. Select the right mesh in the Demo Disp lay you created above. Drag the
Mat_Advanced_WD material to its Element 0 material slot.
30. Build the lighting and play the level by pressing Alt+P.
31. Your material prog ressions should lo ok like Figure 4.45. You might need to adjust
the location and rotation of the lights to see the difference on your materials and
objects.
32. Save all your materials and your level so far.
What Happened in TUTORIAL 4.4. . .
You just got a taste of one of the newest features o f materials in Unreal Engine
4, the world displacement channel. This channel is actually quite powerful. It is
Materials in Unreal Engine 179
a link between a material a nd the geometry on which it is applied. Not o nly will
you have the c ontrol over the ligh t interactions with your object, but you will
also have control of its geometry with the world displacement.
Remember from our discussion of the normal maps and the way normal chan-
nel contro ls the reflec tion of lig ht on a surface to simulate depth, when it is
not there. There are two ways to have a material affect the geometry. The first
is through the world p osition offset channel of the material, an d the second is
through the world displacement channel and tessellation multiplier.
In this tutorial we worked with the world displacement channel to pull some
vertices outwards and push other in, to create real depth.
CREATING TH E WORLD DISPLACEMENT NETWORK
The first thing to remember about the world displacement in UE4 is that this
feature is only available if the hardware supports DX11. If your hardware does
not suppo rt DX11, you cannot use the Te ssellation features that enable the world
displacement. In such cases, you still c an use the wor ld po sition offset channel
of your material to affect geometry.
To enable the world displacement, we first selected the material node and un-
der its details rollout, change d the Tessellation mode to D 3D11 Tessellation
Mode. Once the Tessellation mode is set to anything other than None, your mate -
rial node’s World Displacem ent and Tessellation Mult iplier channels
will become a ctivated.
Both the World Displacement and Tessellation Multiplier channels
work with the geometry’s vertice s. As such, we usually use a Vertex Normal
WS expression in the network that w ill be used to supply these channels. The
Vertex Normal WS will give us the n ormal vector of each vertex in the world
space.
Remember the normal vector is the vector perp endicular to the surface at any
given location. Therefore, having the normal vector at each vertex, we can push
and pull it with the World Displacement channel. This is exactly what we
did in our network. We used the green channel of th e T_Brick_Hewn _Stone_M
texture. This channel has larger values for the brick locations and lower values for
the grout location. We then multiplied the output of this channel by the Vertex
Normal WS to pull the object’s vertices. Sinc e the brick values are more than
the grout values, the vertices located on the bricks are pulled out mor e than tho se
on the group. This will make our object have real depth compared to what is
possible with only the nor mal channel.
In the previous series of tu torials, we started by working with a simple material
off of a texture map, and worked our way towards making this ma te rial look very
realistic. In fact, you just created your first advanced material u sin g Unr eal Material
Editor! We populated our demo room with these materials to showcase your progre ss
and the power of Unreal Engine.
..................Content has been hidden....................

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