Features
Shaders
Convert shaders automatically, set presets, add the three-line HLSL setup or use Shader Graph, and use Foliage Lit.

The renderer draws with indirect instancing. A shader can draw foliage instances when each pass it uses has the procedural instancing setup from KiwiFoliageInstancing.hlsl. That setup replaces the object matrices and the LOD fade of the instance being drawn, so the shader's own transforms, lighting and cross-fade keep working.
Automatic conversion
With Convert Shaders Automatically on (the default, in the renderer's ••• menu or the Shader Setup window), the first time a material with an unknown shader is drawn:
- Its shader is copied to
Assets/Kiwi Foliage/Converted Shadersand renamedKiwi Foliage/Converted/<original name>.
- Text shaders (.shader): every pass the renderer draws gains the instancing pragma, the procedural setup option and the include. Meta, 2D, picking and ray tracing passes are left alone. Relative includes are made absolute. Surface shaders gain addshadow so their shadows follow the instances. - Shader Graphs: the Kiwi Foliage Setup Custom Function node is inserted between the graph's vertex position and the Vertex Position block, and Support LOD CrossFade is turned on for every target.
- A persistent copy of the material is created in
Assets/Kiwi Foliage/Converted Materialsso players include the right shader variants. - Both are recorded in the material library, and every renderer refreshes.
Until the conversion finishes (a moment later in the editor) the material draws with Foliage Lit. Editing the source material copies its values into the converted copy. Saving the source shader converts it again.
Open Window > Kiwi Foliage > Shader Setup to see every shader your foliage uses, how it is drawn, and to convert, reconvert or forget each one.
Presets
Presets decide how a family of shaders is handled and which texture names the impostor baker reads.
| Preset | Shaders | Handling |
|---|---|---|
| Kiwi Foliage | Kiwi Foliage/* | Native |
| Leafshaper | Leafshaper/* | Native |
| URP Lit family | Lit, Simple Lit, Complex Lit, Baked Lit, Unlit | Converted |
| URP SpeedTree | Universal Render Pipeline/Nature/SpeedTree* | Converted (see limitations) |
| HDRP Lit family | HDRP/Lit, HDRP/LitTessellation, HDRP/Unlit | Converted |
| HDRP SpeedTree | HDRP/Nature/SpeedTree* | Converted (see limitations) |
| The Vegetation Engine | BOXOPHOBIC/The Vegetation Engine/* | Converted |
| Nature Shaders | Nature Shaders/* | Converted, replacing their own procedural setup |
| NatureManufacture | NatureManufacture*, Shader Graphs/NM_* | Converted |
| Built-in Standard and Legacy | Standard, Legacy Shaders/*, Mobile/*, Unlit/* | Foliage Lit fallback |
| Built-in Nature | Nature/*, terrain detail shaders | Foliage Lit fallback |
Any other shader with source in the project is converted. To override a family, create Assets > Create > Kiwi Foliage > Shader Preset, set its name patterns (a trailing * matches the start of a name), its handling and its texture names. Project presets win over the built-in list.
Adding the setup to your own shader
Add these three lines to every pass the renderer draws (forward, shadow caster, depth, depth normals, motion vectors, G-buffer), after the pass's own includes. Just before ENDHLSL or ENDCG is a safe place:
#pragma multi_compile_instancing
#pragma instancing_options procedural:kiwiFoliageSetup
#include "Packages/net.kiwistudios.foliage/ShaderLibrary/KiwiFoliageInstancing.hlsl"Also add the tag "KiwiFoliage" = "Instanced" to the SubShader's Tags, so the renderer draws the shader as it is instead of converting it.
Two more SubShader tags are optional:
| Tag | Effect |
|---|---|
"KiwiFoliageCrossFade" = "Instanced" | The shader dithers its own cross-fade from kiwiFoliageFade. The renderer draws your instanced material as it is, without a copy that turns on LOD_FADE_CROSSFADE, so edits to the material show at once. |
"KiwiFoliageImpostor" = "True" | The shader draws baked impostor cards. A level of detail drawn only with such materials counts as an impostor, and its card does not widen the culling bounds of a prefab that also has mesh levels. |
Shaders that keep their own object matrices, for example to work in absolute world space in every pipeline, can #define KIWI_FOLIAGE_CUSTOM_MATRICES before the include. The setup then leaves unity_ObjectToWorld, unity_WorldToObject and unity_LODFade alone, and the shader reads the values below.
The pass must call UNITY_SETUP_INSTANCE_ID in its vertex function, as Unity's own shaders do. For dithered LOD cross-fade, declare #pragma multi_compile _ LOD_FADE_CROSSFADE and apply Unity's LODFadeCrossFade (URP) or your own dither in the fragment function: the setup writes unity_LODFade with Unity's sign convention.
Inside the procedural variant, KIWI_FOLIAGE_INSTANCED is 1 and these values describe the current instance:
| Value | Meaning |
|---|---|
kiwiFoliageObjectToWorld, kiwiFoliageWorldToObject | The instance matrices. |
kiwiFoliageFade | Signed cross-fade: positive for the outgoing level, negative for the incoming one. |
kiwiFoliageTint | A per instance value from 0 to 1 (terrain tree colour variation, or the tint you pass when adding instances). |
A function that reads these values has to come after the include. Place the three lines above it, but still after the pass's own includes, as the Shader Integration sample does.
Shaders that keep their own matrices can define KIWI_FOLIAGE_CUSTOM_MATRICES before the include. The setup then leaves unity_ObjectToWorld alone and only fills the values above.
Amplify Shader Editor
Add the three lines under Additional Directives in the graph's output node. Converting an Amplify shader as text works too, but saving it from Amplify again removes the conversion.
Shader Graph
Add a Custom Function node:
- Type: File. Source:
Packages/net.kiwistudios.foliage/ShaderLibrary/KiwiFoliageShaderGraph.hlsl. Name:KiwiFoliageSetup. Turn on Use Pragmas. - Inputs:
Position(Vector 3). Outputs:Out(Vector 3) andTint(Float). - Connect a Position node in Object space (or your own vertex offset) to
Position, andOutto the Vertex Position block.
Turn on Support LOD CrossFade in the Graph Settings for cross-fades. Tint is available in the vertex stage.
The Shader Setup window can also convert a Shader Graph for you: it writes a converted copy and leaves your original untouched.
Foliage Lit
Kiwi Foliage/Foliage Lit is the renderer's own shader for leaves, grass and anything converted to a fallback. It works in URP, HDRP and the Built-in Render Pipeline with main texture, colour, cutout, normal map, smoothness, healthy and dry colours mixed by instance tint, translucency, an up-facing normal blend for grass, ground occlusion, and wind driven by the renderer's Wind Zone.
Still stuck?
Bring the renderer state with you.
Include the Kiwi Foliage version, Unity and render-pipeline versions, the graphics API, the Foliage Renderer's header state and statistics, the Shader Setup row for any shader involved, and a minimal scene.