Foliage
Paint foliage types, procedural grass and trees from a Foliage component, and the settings that control batching, impostors, collision and navigation.
Mowo has two foliage sources. Painted foliage is what the Foliage mode puts in a level by hand. A Foliage component next to a terrain scatters grass and trees across it procedurally. Both draw through the same GPU path. The painting workflow is on the World building page; this page covers the settings and the behaviour.
Painted foliage
Everything the Foliage mode places is stored in one Painted Foliage container. Its palette rows are foliage types.
Type settings
| Setting | Meaning |
|---|---|
| Mesh | The mesh to place. Empty draws a grass clump |
| Density, Radius | Instances per square metre the brush fills toward, and the minimum spacing between instances of the type |
| Min / Max Scale, Scaling | The scale roll and how the axes roll: Uniform, Free or Lock XY |
| Align To Normal, Align Max Angle | Stand on the surface normal, tilting at most this far from upright |
| Slope Limit, Min / Max Height | Where the brush may place |
| Cull Distance | Hide instances past this distance. 0 = never |
| Use Impostor | Hand off to impostor cards past r.Foliage.ImpostorDistance. Off keeps the mesh out to the cull distance |
| Impostor Resolution | Pixels per side of each view in the type's impostor atlas: 64 (default) for background plants, 128 for hero trees that stay large on screen past the handoff. The atlas costs four times as much at 128 |
| Collision, Collision Radius, Collision Height | Simple gives every instance a vertical capsule. Capsules in a 32 m cell share one static physics body |
| Affects Navigation | Adds the instance's footprint (the capsule, or a 0.5 m trunk without collision) as an obstacle when the navigation mesh is baked |
How it draws
A type with a mesh is drawn as GPU batches: one batch per 64 m cell and mesh section, culled per instance on the GPU, with an impostor past the handoff distance. The cull compute rejects whole cells before it looks at an instance. A type falls back to one draw per instance, with a CPU distance test, when it needs something the instance record cannot carry: Align To Normal above 0, or a Scaling mode other than Uniform.
A grass type (no mesh) is one batch per row under the same rules, except that a Cull Distance moves it to the per-instance path.
Instances too small to cover two pixels on screen are skipped. A type whose Cull Distance is shorter than the handoff distance never shows its impostor: the mesh ends at the cull distance.
Impostors
An impostor is a card that faces the camera and shows the mesh as it looks from the camera's direction. When foliage builds, Mowo renders the mesh from 64 directions spread over the upper hemisphere (an 8 x 8 grid of views by default) into an atlas that stores colour, coverage, the surface normal and the surface depth. The card blends the three views closest to the current direction and lines each one up on the tree, so a tree turns smoothly as you walk around it or look down on it from a hill, instead of snapping between side views.
The card is lit with the baked normals, so it shades like the mesh, and it writes the baked depth, so it meets the ground where the trunk does and takes shadows on its own surface rather than as a flat sheet. Impostors do not cast shadows; trees stop casting at the handoff distance.
Across a band just before the handoff distance (10% of it by default) the mesh and the impostor both draw, each keeping a complementary pattern of pixels, so the switch fades instead of popping and no pixel is drawn twice or left empty. Temporal anti-aliasing smooths the pattern. Trees from a Foliage component switch at the handoff distance without the band.
Impostors see the tree from above and the sides only: a camera below a tree's centre sees the horizon view.
Cells and streaming
The container stores its instances in 64 m cells, one entry per occupied cell, instead of one string for the whole level. Three things follow:
- A brush stroke re-encodes only the cells it changed. The container is updated at most every 0.12 s while you paint, and once at the end of the stroke, so a stroke's cost depends on what the brush touches rather than on the level's total instance count. Cancelling a stroke restores the container exactly.
- Only cells within the container's Stream Radius (768 m by default) of the camera have GPU batches and collision bodies. A cell the camera leaves keeps its data and is built again when the camera returns; a cell is released once it is two cells past the radius. Set the radius to 0 to keep every cell resident. A dedicated server has no camera and keeps them all.
- Cells build a few per frame, nearest first, so a teleport fills in over a few frames.
A level saved before cells existed stores its instances in one string. It loads unchanged and is converted to cells the first time it is updated or edited; the converted level is saved in the new form and older builds do not read it. Merge Actors and PCG still write the single string, and the container converts it the same way.
The Foliage component
A Foliage component on a terrain actor scatters grass (and optionally trees) over the terrain, on the surface the terrain is built from: its sculpt (the saved edit layers) when it has one, otherwise its heightmap.
- Density is instances per square metre; Max Instances caps the total. A cap that cuts the requested density short is logged as a warning that says how much of the density was kept. The range of Max Instances goes to four million, so a large terrain can have an explicit budget instead of a silent one.
- Every instance is placed from its own seed. Painting a terrain layer or changing a filter moves only the blades it touches, never the rest of the terrain.
- Terrain Layer limits the grass to one weight layer (0-7) above the Layer Weight Threshold.
- Align To Slope blends from upright (0) to lying in the surface (1). A tilted scatter is baked into per-cell meshes instead of GPU batches.
- Trees use a mesh or a built-in procedural tree and switch to impostor cards past the handoff distance. Tree Impostor Resolution sets the pixels per view in their atlas (64 by default, 128 for hero trees).
Grass authored per layer on the terrain's own Grass Types list is described on the Landscape page. Grass marked GPU Scatter there is placed on the GPU rather than by this component.
Foliage and grass bend in the wind of a placed Weather actor and part around characters and Vegetation Interactor components. See Weather and wind.
Console variables
r.Foliage.GPU turns the GPU path off, r.Foliage.DensityScale scales every density, r.Foliage.GrassDistance is the far band for grass and r.Foliage.ImpostorDistance is the handoff to impostor cards.
| Variable | Default | Meaning |
|---|---|---|
r.Foliage.Impostor.FrameGrid | 8 | Views per side of the impostor atlas, 2 to 16. Read when foliage builds, so a change shows after the next rebuild |
r.Foliage.Impostor.CrossfadeBand | 0.1 | Width of the mesh-to-impostor fade as a fraction of the handoff distance, up to 0.5. 0 switches at once |
r.Foliage.Impostor.MeshShader | 0 | 1 draws impostor cards with mesh shaders on hardware that has them; 0 uses instanced cards |
The impostor distance, crossfade and view grid are also on the Foliage page of the engine settings. See the console variable reference.
Engine sources
This page describes behavior implemented in these files of the engine repository, checked against commit 0e77abe6b.
- Engine/Source/Gameplay/Game/Api/Game/Components/FoliageComponent.h
- Engine/Source/Gameplay/Game/Api/Game/Components/FoliageInstancesComponent.h
- Engine/Source/Gameplay/Game/Api/Terrain/FoliageSystem.h