Foliage and landscape grass¶
The Foliage and landscape section of the settings controls foliage painted with the Foliage tool, instanced meshes, landscapes and landscape grass.
Map: Post-Soviet World by GeorgeShachnev, on Fab.
Foliage3D¶
UE2GD only
Foliage3D and swaying foliage are in the full edition. In UE2GD Lite, foliage and landscape grass
are grouped by type in plain Node3D nodes with their multimeshes, without sway, and placed plants and trees
stay ordinary meshes. The rest of this page, from Settings on, applies to both editions.
Each foliage type becomes one Foliage3D node, however many World Partition cells or levels it is spread over. Its
children are MultiMeshInstance3D nodes, one per cell of the level (16 m for foliage, larger for grass). Landscape
grass gets one Foliage3D per grass mesh.
Foliage3D is a small script, copied into the project at res://ue2godot/Foliage/foliage_3d.gd. Select the node
and set, in the Inspector:
| Property | |
|---|---|
| Sway | Bends the plants in the wind. |
| Sway Strength | How far the tops bend, as a share of the plant's height. |
| Branch Sway | How far branches away from the trunk swing on their own, as a share of the plant's height. 0 turns it off. |
| Leaf Flutter | How far leaves (surfaces with transparency or alpha clip) shiver, as a share of the plant's height. 0 turns it off. |
| Sway Speed | How fast the plants move and the gusts travel. |
| Sway Noise | Gusts: a tiling noise texture drifting across the level with the wind. Clear it for an even sway. |
| Noise Scale | How many times the noise repeats per metre. Smaller makes broader gusts. |
| Wind Direction | The direction the wind blows on the ground (X, Z). |
Each Foliage3D has its own settings, so grass can sway while trees stay still. Changes show in the editor.
The bend grows with the height up the mesh, so the base stays put. On top of it, parts further from the trunk swing more and out of step with each other (Branch Sway), and leaves shiver quickly (Leaf Flutter). This works on any tree without wind data in the mesh; it doesn't use Unreal's wind (SpeedTree, Pivot Painter).
How the sway is drawn¶
Sway uses a copy of each material, <material>__sway.tres next to the material, on a shader that draws the same
surface and bends the vertices. The shaders are in res://ue2godot/Foliage/shaders/; they share
ue2godot_foliage.gdshaderinc. Turning Sway off draws the plain mesh and materials again. Nothing is changed in
the mesh or the MultiMeshes.
A surface whose material uses a feature the sway shader doesn't draw keeps its own material and doesn't sway. When no surface can sway, Sway starts off.
Placed plants and trees¶
Plants placed by hand as static meshes (trees, bushes, flowers) also become Foliage3D nodes, one per mesh and
material set, so they sway like painted foliage. A placed mesh counts as a plant when one of its materials is shaded
as Two Sided Foliage, or is masked, two-sided and uses World Position Offset while the mesh or material is named like
a plant (tree, leaf, grass, vegetation, bush and so on). Hanging laundry and nets stay ordinary meshes. With
Sway in the wind set to Off, placed plants stay ordinary meshes too.
Placed plants taller than 2.5 m are trees:
- They go under a
Treesnode in their folder. - They keep their collision, as
StaticBody3Dnodes inside theFoliage3D. Smaller plants get no collision, so you can walk through bushes and grass. - Sway Strength starts at 0, so trunks stay still while the branches swing.
- Leaf Flutter is scaled down with the tree's height, so a big tree's leaves don't shake more than a bush's.
Leaves are sometimes modelled back to back, each face twice. Godot already draws both sides of a two-sided material, so the copies would z-fight and show as stripes that crawl as the tree sways. UE2GD drops such duplicate faces on surfaces whose materials are all two-sided.
Settings¶
| Setting | |
|---|---|
| Foliage and instanced meshes | Foliage, and instanced and hierarchical-instanced static meshes, as MultiMeshes. |
| Foliage in unloaded World Partition cells | On by default. World Partition levels keep foliage in grid cells that are often unloaded in the editor. These are loaded for the export and unloaded after, so all of the level's foliage is exported. |
| Sway in the wind (UE2GD only) | Whether each Foliage3D starts with Sway on. Grass and small plants (default): types up to 2.5 m tall, so trees start still. All foliage, trees included. Off: switch it on per type in Godot. |
| Sway strength, Branch sway, Leaf flutter, Sway speed (UE2GD only) | The starting Sway Strength, Branch Sway, Leaf Flutter and Sway Speed of every Foliage3D. |
| Landscapes | Mesh, HTerrain, Terrain3D or None. See Landscapes. |
| Landscape grass | On by default. Places the landscape material's grass. See below. |
| Grass density (%) | The share of Unreal's grass density to place. Unreal only draws grass near the camera; placing it all over a large landscape can be a lot. |
| Max grass instances per mesh | A cap on each grass mesh's instances over the whole level. Grass beyond it is thinned out evenly, with a warning. |
Landscape grass¶
Unreal makes landscape grass at runtime, around the camera, so it isn't stored in the level. UE2GD places it the way Unreal does and saves it with the scene.
In Unreal, grass comes from the landscape material:
- The material's Landscape Grass Output node has an input per Landscape Grass Type. The input is usually a paint layer's weight (a Landscape Layer Sample node).
- Each grass type lists grass varieties: a mesh with a density, scale range, random rotation, surface alignment and cull distance.
- For each landscape component, Unreal picks candidate points: an even scatter (a Halton sequence), or a jittered grid when the variety uses a grid. The density is instances per 10 x 10 m.
- At each point it reads the input's weight. It keeps the point when the weight is within the variety's Allowed Density Range and at least a random fraction. So the grass is densest where the layer is fully painted and thins out where it fades.
UE2GD reads the same setup, renders the landscape's heights and layer weights, and repeats those steps. Each instance gets the variety's scale (with Weight Attenuates Max Scale), random yaw, and alignment to the slope. The variety's End Cull Distance becomes the MultiMeshes' visibility range, and its material overrides are kept. Holes (the visibility layer) get no grass.
The grass input can be any mix of layer weights through Add, Subtract, Multiply, Divide, One Minus, Clamp, Saturate, Min, Max, Power, Lerp, constants, scalar parameters and reroutes. Any other node is approximated by the strongest of the layers above it, with a warning in the Output Log.
The points are the same kind as Unreal's but not the same points, so the grass looks the same without matching blade for blade. Grass is placed only on exported landscapes: it needs Landscapes set to Mesh, HTerrain or Terrain3D.
The confirmation counts the grass instances the export can place at most in its Scene line. The summary shows how many were placed.