Integration
Using Kiwi Foliage
Draw forests of millions of trees through Kiwi Foliage, automatically or with a Forest Renderer you control.

Leafshaper works on its own and works better with Kiwi Foliage (net.kiwistudios.foliage), which is sold separately. With Kiwi Foliage 26.12.0 or later in the same project, Leafshaper adds the Leafshaper Forest Renderer, which draws forests of up to millions of trees without a game object per tree. Without Kiwi Foliage, Leafshaper trees draw through Unity's LOD groups and terrain trees; see Large forests.
Install Kiwi Foliage from My Assets in the Package Manager, or from its tarball. Leafshaper finds it on its own, and there is nothing to set up: your Leafshaper trees draw through Kiwi Foliage from then on.
Automatic drawing
With Kiwi Foliage installed, Leafshaper draws these trees through it in the Editor and in Play Mode, in URP, HDRP and the Built-in Render Pipeline:
- Terrain trees. A terrain whose tree prototypes are all baked Leafshaper prefabs gets a hidden Forest Renderer. The terrain keeps its tree colliders and stops drawing the trees itself. Painting, erasing and moving trees follow on their own. A terrain that also holds other trees stays with Unity, so nothing on it disappears.
- Trees placed by the Forest Scatterer and its brushes. Terrain trees draw as above. Trees placed as scene objects go under a parent with a Leafshaper Foliage Group.
- Trees under a Leafshaper Foliage Group. The group's Leafshaper trees draw through Kiwi Foliage, and follow it when you move, add, remove, turn on or turn off a tree. Their own renderers stay in the scene, untouched. Its inspector shows which renderer draws them.
Trees you dropped into a scene before are left as they are. Choose GameObject > Leafshaper > Move Scene Trees to Kiwi Foliage to add a group to each set of loose Leafshaper trees, with Undo.
Edit > Project Settings > Leafshaper has the Render with Kiwi Foliage when installed setting, on by default. It shows how many terrains, groups and trees Kiwi Foliage draws, and has the move button. Turn it off to give every tree back to Unity; a player built with it off does the same.
Nothing about this is saved in your scenes. The hidden renderers are never saved, a terrain's tree distance is written as it was, and tree renderers stay switched on. If you remove Kiwi Foliage, the same scenes draw through Unity's terrain trees and LOD groups, and the Leafshaper Foliage Group does nothing.
Forest Renderer
For trees from code, or to change culling, LOD and shadow settings, add a renderer yourself with GameObject > Leafshaper > Forest Renderer. Before Kiwi Foliage is installed, that menu item explains what it adds. A Forest Renderer you add takes over its terrain from the automatic one.
The Leafshaper component keeps its own settings, terrain import and scripting API, and owns a Kiwi Foliage Renderer on a hidden object that is never saved with the scene. Foliage returns that renderer, for its debug views, per prefab statistics and settings. To draw rocks, grass or prefabs from other packages next to your trees, add a Kiwi Foliage Renderer of your own.
The Forest Showcase scene requires Kiwi Foliage. With it, the sample plants 150,000 trees and grows to a million. Without it, Unity draws a preview forest of 3,000 trees and the panel says Kiwi Foliage is needed.
How it works
For every Game and Scene view camera, a compute shader visits each instance and:
- Culls it against the view frustum and Max Distance.
- Picks a level of detail from its screen size using the prefab's LOD Group thresholds, your quality level's LOD bias and LOD Bias, with a dithered Cross Fade Width between levels.
- Optionally culls it against a farthest-depth pyramid built from the previous frame's depth (Occlusion Culling, URP and the Built-in Render Pipeline). The test uses each tree's oriented box, skips boxes that were partly outside the previous view, widens with camera movement, and switches itself off for a frame when the camera jumps.
- Culls shadow casters separately, along the direction of Shadow Light or the scene's sun, within Shadow Distance, using a level of detail Shadow Lod Offset steps coarser.
Each mesh level and material then draws with one indirect call, so the CPU cost does not grow with the number of trees. The forest draws on the layer of the object that holds the renderer; cameras whose culling mask leaves that layer out draw no trees and skip the culling.
Levels of detail cross-fade when the prefab's LOD Group uses Fade Mode > Cross Fade, as Leafshaper's baked prefabs do. A group set to None switches levels without a fade. A large batch of new instances uploads over a few frames instead of in one.
Draw a terrain's trees
Assign Source Terrain. The renderer reads the terrain's tree instances whose prototypes are baked Leafshaper prefabs and sets the terrain's tree distance to zero while Hide Terrain Trees is on, so the terrain keeps its tree colliders but stops drawing the trees. Painting trees in the Editor re-imports them. Turning the renderer off restores the terrain's tree distance.
Add trees from code
var _handle = forest.AddInstance(prefab, position, rotation, widthScale, heightScale);
forest.SetInstanceTransform(_handle, position, rotation, widthScale, heightScale);
forest.SetInstanceVisible(_handle, false);
forest.RemoveInstance(_handle);A prefab must be baked by Leafshaper, or use Leafshaper/Tree and Leafshaper/Tree Impostor materials. Its level-of-detail renderers may sit on child objects. The renderer supports up to 4,000,000 instances. InstanceCount, VisibleInstanceCount, ShadowCasterCount and DrawCallCount report what it drew last frame.
Notes
- Before you remove Kiwi Foliage, remove the Forest Renderer components you added from your scenes. Automatic drawing needs nothing removed. Your baked prefabs and terrain trees keep working without it.
- Compute shaders are required. The renderer logs a warning and draws nothing on platforms without them.
- Trees drawn this way use the light probe at the forest's bounds, plus Adaptive Probe Volumes per pixel in URP and HDRP.
- In URP the renderer requests the camera depth itself; you do not need to enable Depth Texture on the pipeline asset.
- HDRP keeps frustum, distance and shadow culling. Depth occlusion runs in URP and the Built-in Render Pipeline.
- While two levels cross-fade, the main view draws both with complementary dithering. The shadow map dithers the same pair, and casters dissolve over the last tenth of Shadow Distance.
Still stuck?
Bring the recipe with you.
Include the Leafshaper, Unity and render-pipeline versions, the operating system and graphics API, the first Console error, the preset and seed, and the steps that reproduce the problem.