Terrains and Landscapes in Un real Engine 471
1. Find the Starter Conten t folder in the Cont ent Browser, and
Double-click on the Props f older to ope n it up.
2. In th e Props folder, find a mesh called SM_Bush.
3. Right-click on SM_Bush and choose Duplicate. This will make a c opy of this
mesh.
4. Rename the du plicated mesh to SM_LScape_Bush.
5. Right-click on SM_Rock and choose Duplicate. This will make a c opy of this
mesh.
6. Rename the du plicated mesh to SM_LScape_Rock.
7. Drag the SM _LScape_Bush mesh into your Meshes folder and choose the Move
Here option (just like what you did in Figure 7.40(a)). If y ou do not have this
folder, create it under the main Game folder.
8. Drag the SM _LScape_Rock mesh into your Meshes folder and choose the Move
Here option (just like what you did in Figu re 7.40(a)).
9. Still in the Props folder, find the Materials folder and Double-clic k on it to
open it up.
10. In the Materia ls folder, find a material called M_Bush.
11. Drag the M_Bush material into your materials folder you created earlier (I called
my f older MyMaterials) and choose the Copy Here option (like Figure 7.40(b)).
12. Still in the Materials folder of the Props folder, find a material called M_Rock.
13. Drag the M_Rock material into your materials folder you created earlier (I called
my f older MyMaterials) and choose the Copy Here option (like Figure 7.40(b)).
14. Go to your mater ia ls folder and rename the copy of the M_Bush material to
M_LScape_Bush.
15. Still in your materials folder, rename the copy of the M_Rock material to
M_LScape_Rock.
16. The final step here is to apply the M_ LScape_Bush and M_LScape_Rock mate-
rials to our SM_LScape_Bush and SM_LSC ape_Rock static meshes, respectively.
To do so, perform th e following tasks:
a. Go to your own Meshes folder that y ou have crea te d under the Game folder.
b. Double-click on the SM_LScape_Bush mesh to open it up in the UE4’s
Static Mesh Editor.
c. Drag the M_LScape_Bush material to the Element 0 section of the
SM_LScape_Bush mesh in its LOD0 section in the Details rollout o f the
Static Mesh Editor (just like Figure 7.41).
d. Double-click on the SM_LScape _Rock mesh to open it up in the UE4’s
Static Mesh Editor.
e. Drag the M_LScape_Rock material to the Element 0 section of the
SM_LScape_Rock mesh in its LOD0 section in the Details rollout o f the
Static Mesh Editor (just like Figure 7.41).
17. Save your SM_LScape_Rock and S M_LScape_Bush meshes and close the Static
Mesh Editor.
472 Game Development and Simulation with Unreal Technology
ADDING FOLIAGE ME SHES
So far, we have organized our assets. We now have a copy of a Rock and a Bush
static mesh in our own Meshes folder. We also have a copy of their respective
materials in our own materials folder. With the assets re ady, let us go ahead and
apply them to our Foliage Tool:
18. Open the Foliage Tool by pressing Shift+4, or by clicking on the branch icon
in the Modes Panel.
19. In the Cont ent Browser, Double-cli ck on the Meshes folder to open it up.
This is the folder where we just placed copies of our duplicate Rock and Bush
static meshes.
20. Drag the SM_L Scape_Rock into the black area that reads Drag static meshes
from the content browser into this area”. You will have to place the
static mesh directly into the thin area , and not into the gray area beneath it. This
will add the SM _LScape_Rock to the Foliage System of which you can p la ce
instances into th e level.
21. Drag the SM_LScape_Bush on top of the Rock mesh you placed in the Foliage
System. If you now scroll down, you will see the SM_LSc ape_Bush static mesh
in the list of Meshes as well.
SETTING FOLIAGE MESH PROPERTIES
Now that we have added the foliage instance static me shes, let us set up their
properties so that they will be placed neatly in the level.
22. Change the following settings for the SM_LScape_Ro ck:
Density/1Kuu
2
: 5.0
Scale Min: 0.2
Scale Max: 0.8
Z-Offset Min: -15
Z-Offset Max: 0
Random Pitch ±: 45
23. Change the following settings for the SM_LScape_Bu sh:
Density/1Kuu
2
: 3.0
Scale Min: 0.5
Scale Max: 1.5
PAINTING FOLIAGE MESHES
With the Foliage settings established, it is now time to start painting the foliage
instances into our level. But first, we want to ensure that we have the right brush
size. We wou ld also like to exclude static mesh actors from the list of potential
locations on which our foliage instances will be placed. T his is because we do
not want the foliage instances to be placed on the road we created earlier (the
road is a static me sh).
24. Change the Bru sh Size in the Foliage Tool to a small brush, e.g., 4 50.
Terrains and Landscapes in Un real Engine 473
25. In the Filter section of the Foliage Tool, uncheck the Static Mes hes. This
will ensure that our instanced foliage meshes will not be placed o n static meshes.
We do not want any brush or roc ks to be placed on the walkway mesh we used in
the Spline Editor.
26. With these settings now establishe d, Left-click while moving your mouse on
your landscape to place some foliage instance on the landscape (see Figure 7.53).
FIGURE 7.53: Foliage Instance Added to the Landscape.
SETTING THE CULLING AND FADING SUPPORT
We are almost done! The last item of business is to set up our c ulling support for
the landscape foliag e mesh instances. I am going to intentionally do this proc ess
in three steps.
In the first step, I w ill set up a Start Cull Distance and an End Cull
Distance for both the Bush and the Rock in stances. D oing so will perfectly
demonstra te the cluster instancing done in UE4s Foliage System, and yo u
will see that e ntire clusters of foliage instances will disappear when they are
farther away from th e camer a than the End Cull Distance.
In the second step, I will show you how to set up the fading support in the
Bush’s material. We will do this for the Bush material first, since it already has
an opacity ma sk network and modifying this network to support Per Instance
Fading will be really easy.
Finally, we will set up a network to support Per Instan ce Fad ing for the Rock
material. This task is also pretty easy, we will simply change the mater ia l Blend
474 Game Development and Simulation with Unreal Technology
Mode to support masking, and then build the Opacity Mask network to incor-
porate Per Instan ce Fading Amount
(a) (b)
FIGURE 7.54: (a) Rock Instance Sett ings. (b) Bush Instance Settings.
27. Go to the Foliage System in the Modes Panel (by pressing Shift+4 ).
28. It should not matter which mode you are in the Foliage System. Click on
the Show Instance Settings of the SM_LScape_Rock mesh (see Fig-
ure 7.54(a)).
29. In the Show Instance Settings section of the SM_LScape_Rock static mesh,
make the following chang es to the properties:
Max Instance Per Cluster: 100
Max Cluster R adius: 2000
Start Cull Distance: 2 000
End Cull Distance: 4000
Cast Dynamic Shadow: Unchecked
30. In the Show Instance Settings section of the SM_LScape_Bush static mesh,
make the following chang es to the properties:
Max Instance Per Cluster: 100
Max Cluster R adius: 2000
Start Cull Distance: 2 000
End Cull Distance: 4000
Cast Dynamic Shadow: Unchecked
31. After applying the above values, you will notice two prominent changes:
a. The values for I nstance Count and Cluster Count have changed for
both the SM_LSCape_Rock and SM_LScape_Bush . This is because
we now have smaller clusters in our level.
b. If you zoom out in the level editor, you should notice entire groups of Rock
and Bush instances will suddenly disappear (see Figure 7.55(b)).
32. Walk around in the editor viewport and check out your landscape.
PER INSTANCE FADING FOR BUSH MATERIALS
So the go od news is our cluster culling works. When we are away from a clus-
ter by more than the End Cull Distance the rendere r culls the cluster. The
Terrains and Landscapes in Un real Engine 475
(a) (b)
FIGURE 7.55: (a) Clusters in the Landscape. (b) Far Away Clusters are Culled.
bad news is entire clusters of foliage instances suddenly disappear (see Fig-
ure 7.55(a) vs. Figure 7.55(b)). Of course if we had a huge landscape, and the
clusters were really far away, the sudden disappearance of foliage instances
would not have been a terribly negative experience. But we can notice this neg-
ative effect and should fix it.
The really good n ews is there is a very easy fix to the problem o f cluster dis-
appearance. It is called Per Instance Fading and Unreal En gine 4’s Mate-
rial Editor suppor t is thro ugh a material expression called Per Instance Fade
Amount. We will next use this expression to ma ke our Bush instance s fade
away as we walk away from them.
33. In the Content B r owser, go to your materials folder in which you placed copies
of the Bush and Rock materials.
34. Double-click on the M_LScape_Bush material to open it in the Material
Editor. We will now modify this ma te rial to support Per Instance Fading.
35. Right-click on the graph editor, b elow the Tex ture Sample with the leaves
texture to search for and place a Per Instance Fade Amount expre ssion.
36. Place a Multiply expr ession to the right of both the Texture Sample and the
Per Instance Fade A m ount expressions an d make the following connections
(Figure 7.56):
Multiply A Alpha output of leaves Texture Sample
Multiply B Output of Per Instance Fade Amount
Multiply out put Opacity Mask channel of material node
37. Save and apply your material.
38. Now, in the editor viewport, move around in the landscape and see how this effect
makes each bush instance to fade, before it is co mpletely culled, to make for a
smooth transition.
..................Content has been hidden....................

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