Shaders and Materials
How Flora works with your existing shaders, and what to consider when authoring new ones.
Flora supports a wide range of Unity shaders and includes utilities for patching both Shader Graph and manually authored shaders for compatibility with instancing and selection.
Batch Renderer Group
When using BRG as the culling pipeline, no shader modification is typically necessary for rendering. One caveat is some 3rd party shaders might be setup incorrectly.
Shader Requirements
Every pass must include the following pragma, and will only work when the shader target is greater than 4.5.
#pragma multi_compile _ DOTS_INSTANCING_ON
#pragma target 4.5
For Universal, you can use the following include_with_pragmas to automatically setup the pass for DOTS.
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
Additionally for picking to work, ensure the ScenePickingPass correctly returns unity_SelectionID
and not _SelectionID
.
This is a common error in 3rd party shaders, and affects Amplify Shader Editor (a bug request has been submitted). For ASE, modify the template shader and replace the return result of _SelectionID
with unity_SelectionID
in the fragment shader of any templates you are using.
// return _SelectionID; Replace this line with:
return unity_SelectionID;
Render Mesh Pipeline (Legacy)
Shader Graph
Injection
Flora automatically patches Shader Graph, requiring no additional setup in most cases.
By default, the patcher excludes URP and HDRP targets that are incompatible with procedural instancing. However, if you encounter issues, you can disable this automatic injection via:
Project Settings → Flora → Disable Shader Graph Injection
Shader Graph Node
When Shader Graph injection is disabled, the Setup Flora Instancing Data
node becomes available.
To enable instancing manually:
Add the Setup Flora Instancing Data node in Shader Graph
Connect its output to the Vertex Position block
This enables procedural instancing support for Flora within Shader Graph.
Patching Shaders
You can patch materials or shaders via context menus:
Project Window: Right-click a selection of Materials or Shaders → Convert to Flora Shader

Inspector Window: Right-click a Material in the Inspector → Convert Material to Flora

Location
Patched shaders are saved alongside the original shader with the suffix: (Flora)
If the original shader is located in a package or non-asset directory, the patched version is saved at:
Assets/Flora/Original/ShaderPath/ShaderName
Modifying Shaders
For the RenderMesh pipeline to work, shader passes require the following includes and pragmas:
// Ensure your shader has the following include
#include "Packages/com.ma.flora/ShaderLibrary/Instancing.hlsl"
// And the following shader pragmas
#pragma instancing_options procedural:SetupFloraInstancingData
// Required here, or elsewhere in the shader pass
#pragma multi_compile_instancing
Additionally, selection outlines rely on instancing. If your shader’s selection passes aren’t configured for instancing, Flora instances may not be selectable with the legacy RenderMesh
pipeline.
If selection isn't working, make sure your selection passes (SceneSelectionPass
and ScenePickingPass
) include the line:
#pragma multi_compile_instancing
If you're using Amplify Shader Editor, modify the shader template so that both passes include this directive.
See also Modifying Shaders
Last updated