466 Game Development and Simulation with Unreal Technology
check box and make modifications. When you brush over the existing instances,
the changes will be ap plied. Most of the settings in this tool are similar to those
of the Paint Tool, but there are a few differences:
TABLE 7.29: Reapply Tool Properties
Reapply Settings
Density A djust: This setting is a density multiplier for existing in-
stances. For example, setting the value to 2.0 will double the
number of in stances in a particular, while a value of 0.5 will
leave only half of the instances remaining after painting.
Ground Slope: This setting will remove instances that do not sa tisfy
the ground slope criteria. No new instances wil l be added.
Height Min/Max: This setting will remove ins ta n c e s that do not
satisfy the height criteria. No new instances will be added.
Landscape Layer: This setting will remove instances in prop ortion
to the specified layer. No new instances will be added.
Selection Tool: This tool allows you to selec t individual in stances.
TABLE 7.30: Selection Tool Properties (Actions per Selected Instance)
Translate: Translate (move) a selected instance (group of instanc e s) by
dragging the translation widget axes. You can activate translate wid-
get by pressing W or clicki n g on the translation button in the editor
viewport.
Rotate: Rotate a selected instance (group of instances) by dragg ing the
rotation widget axes. You can activate rotation widget by pressing
E or clicking on the rotation button in the editor viewport.
Scale: Scale a selected instance (group of instances) by drag ging the
scale widget axes. You can activate translate widget by pressi n g R
or clicking on the scale button in the editor viewport.
Duplicate: Duplicate a selected instance (group of instances) by holding
Alt key and dragging the widget axes.
Delete: Press the Del key to delete a sel e c te d instance (group o f in-
stances).
Snap to Floor: Press the End key to attempt to snap a selected instance
(group of instances) to the oor.
Lasso Tool: This tool allows you to use a p aintbrush to select instances simultane-
ously in the level. You may use the Filter settings or select/deselect meshes
from the Meshes list to furthe r customize this tool.
Terrains and Landscapes in Un real Engine 467
TABLE 7.31: Lasso Tool Properties
Available Actions
Left-Click: Will select the instances that fall under the brush.
Shift+Left-Click: Will remove instances from the selection.
Fill Tool: This tool deter mines the number of mesh instances to place with the paint
tool. Afte r setting the density and other properties of the mesh instances, you ca n
use this tool to fill an entire actor with the instances of foliage meshes in your
level.
Instance Settings
You can use this mode to modify the instances of meshes a lready placed in the level.
TABLE 7.32: Instance Settings
Instance Count: This setting shows the number of instances of this mesh
currently placed in the level (currently streaming level).
Cluster Count: This setting shows the number of clusters us e d to render
instance of this mesh in the level.
Clustering:
Max Instance Per Cluster: This setting specifies the maximum
number of instances used in a clu ster. A good idea is to set
this value to use the number of po lygons per mesh to spec-
ify this value. Since each cluster will be rendered in a single
draw call, using very large numbers for this setting, if the poly
count of each me sh is high, might result in performance issues.
Setting very low values for this setting will eliminate clustering
effectiveness.
Max Cluster R adius: This setting specifi e s the maximum size to
which a c luster could grow before allocating new instances to
new clusters. Reducing this value will increase the number o f
clusters, b u t improve occlusion.
468 Game Development and Simulation with Unreal Technology
Culling:
Start Cull Distance: This setting specifies the distance (in world
units) from which instances start to fade. This value needs to
be set up in the material.
End Cull Distance: This s e tting sp e c ifies the distance (in world
units) from which instances will be completely culled. If the
material is not set up to support fading o f individual instances,
the entire cluster will disappear (reappear) a s player gets farther
from (closer to) at least one instance within the cluster.
7.6.2 CULLING INSTANCES
As I discussed earlier, one of the most important advantages of the Foliage sy stem
in UE4 is its efficiency in utilizing clustering to increase the rendering performance
of large numbers of static meshes on vast ou tdoor environments. To further increase
perfor mance, the foliage system uses a mechanism called Culling.
Culling allows the engine to determine when a cluster of instances is far enough
from the player that ignoring it to be rendered will not be detrimental to the player’s
experience. We discussed the two parameters in the Instance Settings that con-
trolled how the e ngine shou ld determine th e d istances from which to start the culling
process and to co mpletely c ull a clu ster from being rendered.
(a) (b)
FIGURE 7.51: (a) Culling Distances Are Not Set. (b) A n Entire Cluster Disappears Due to
Culling.
Terrains and Landscapes in Un real Engine 469
To use the culling mechanism of the foliage system, we should set a Start Cull
Distance and an End Cull Dis tance. Since foliage instances are rendered on a
per-cluster basis, setting the cull distances will result in an entire cluster of instances
to disappear if their cluster surpasses the End Cull Distance. This, if noticeable,
could have negative effects on the player’s experience.
Figure 7.51(a) shows a view of a landscape with some Rock and Bush instan ces
without culling p arameters set up. The End Cull Distance has been set for the
Rock in Figure 7.51(b), resulting in all of the rock instances to disappear if viewed
from farther than the End Cu ll Distance.
In order for the culling mechanism to work properly, the material on the mesh in-
stances must be set up proper ly. If the culling distanc es are not suppor te d in the
mesh’s mater ia l, culled instances will suddenly disappear from the view. Setting up
the materials to support culling is actually quite easy and straightforward.
Unreal Engine 4 has a material expression called Per Instance Fade Amount.
This expression returns a value b etween 0 and 1, b ased on the outp ut of the cull
distance calc ulations. If the instance of a mesh with the material is closer than the
Start Cull Distance, the value f or Per Instance Cull Amount will be 1. If
the instanc e of the mesh is farther than the End Cull Distance, the value for this
expression will be 0.
To set up a m aterial to support culling properly, simply integrate the o utput of the
Per Instance Fade Amount into an Opacity (or Opacity Mask) network. Doing
so will allow for the material to render opaque if th e instances are close, and start to
fade away as instances get farther away from the Start Cull Distan ce. Once the
instances reach the End Cull Distance they will become transparent and culling
them would not be noticeable by the player.
(a) (b)
FIGURE 7.52: (a) A Network to Support Proper Per Instance Culling. (b) A View of the Same
Level Shown in Figure 7.51(b) with Materials Supporting Culling. Notice how the closer rocks
still persist in the level as the ones that are farther away start to fade.
470 Game Development and Simulation with Unreal Technology
Figure 7.52(a ) shows a material network that supports proper per instance culling. To
achieve this effect, we use a Per Instance Fade Amount and Multiply its output
with the output of a network that makes some parts of the mesh transparent as they
fade away. The result of the fade amount calculation is then supplied to the Opacity
Mask chan nel of the material n ode. As a result, when instances of the rock object
get farther and farther from the player, parts of the instances start to be masked until
the entire mesh instance is culled from the view (see Figure 7.52(b)).
Now, it is time to populate our level with some pro ps. In Tutorial 7. 8 we will set up
a couple of Foliage Mesh Instan ces and populate our level with these props to make
the landscape look less empty.
FIND ON THE WEBSITE
To find updates to this tutorial and upda te d instructions about its implementa-
tion on othe r UE4 versions, p le ase visit the books companion Website at:
http://www.RVRLAB.com/UE4Book/
TUTORIAL 7.8 Pop ulating the Landscape with Foliage Mesh Instances
It is time for us to pop ulate our landscape with some objects. We will use the
UE4’s Foliage Tool to paint instances of a rock static mesh and a bush static
mesh on the landscape.
NOTE
If you have not completed Tutorial 7.1, go to page 386 to cr eate a La ndscape.
We w ill ne ed this landscape to complete our work below.
NOTE
It would be great if you also have finished one of Tutorials 7.3, Tutorial 7.4,
or Tutorial 7.6.
ORGANIZING ASSETS
Much like the other tutorials in this book, let us first organize the assets which
we will use to create our foliage instances. We will use two static meshes
from the Starter Content and their materials. We will copy these assets in to
our Meshes a nd MyMaterials f olders.
..................Content has been hidden....................

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