480 Game Development and Simulation with Unreal Technology
I wanted to avoid placing any rock or bushes onto the road mesh we placed
in the landscape in Tutorial 7.7. This was a fairly easy task to do by using the
Filter in Foliage System. All we needed to do was to uncheck the Static
Mesh in the Paint Mode. This will avoid paintin g foliage instances if the brush
covers static meshes in the level.
SETTING THE CULLING MECHANISM
The first task to perform to enable culling in the Foliage S ystem is to set the start
and end cull distances. Bu t befo re setting our cull distances, we mad e two minor
changes to our cluster sizes for the Rock and Bush static meshes. By default the
Cluster Radius is set to 10,000 world units. Our landscape is relatively small,
and I wanted us to see the culling effect better over the co urse of th e next few
steps. So we simply re duced the Cluster Radius for both of our meshes to 2,000
world units to make smaller clusters of foliage instances in the landscape .
Our n ext order of business was to go to the Show Instanc e Setting sec-
tion of each foliage static mesh, and set the Star t Cull Distance and the
End Cull Distance properties. We set the St art Cull Distance to 2,000
and the End Cull Distance to 4,000 for both the SM_LScape_Rock and
SM_LScape_Bush meshes.
Setting the start and end cull distance will trigger the engine to perfo rm two
tasks. When each cluster reaches the Start Cull Distance the engine will start
calculating the fading per instance process. This is a value that is ca lc ulated for
each in stance in the cluster and supplied to the Unr eal Engine’s Mate rial Editor
via a Per Inst ance Fade Amoun t material expression. When a cluster reaches
the End Cull Distance, the rendered will cull it, in its entirety, from the view.
So far in our progress, we saw the second effect –i.e., after zooming out in the
editor viewport cluster s disappeared (Fig ure 7.55(b)). But w hat happened to the
instance fading? Well, the materials for neither Bush nor Rock instan ces support
fading, yet. T hat is why foliage instances in the landscape suddenly disappeared
once you walked away from them. We set up the fading support in the materials
next.
PER INSTANCE FADING FOR THE BUSH MATERIAL
As it turns out, supporting per instance fading is relatively easy to set up in the
material editor. We first supported fading for the bush material, since it alrea dy
had an O pacity Mask network.
The Bush material is ma de of a texture sample that represents leaves’ colors
and texture. However, upon close inspection, y ou will notice that th is texture also
has an Alpha channel that is fed to the Opacity Mask channel of the material.
When applied to the Bush Static Me sh, this material will make only the leaves
and branches of the mesh visible and masks th e rest of the mesh as completely
transparent.
Well, this is perfect for our use in th e fading support network. We created
a Per Instance Fade Amount expression in the material editor. The o utput