New: Nature Shaders

Interaction, Wind, Dynamic Masking, and Better Shading for your vegetation.

Learn more
This page may not work correctly inside the Unity editor. Open in browser

Procedural Instancing for shaders

Overview

The Procedural Instancing feature of Nature Renderer drastically increases performances by making use of advanced GPU instancing techniques.

However, to use this feature it needs to be supported by the shaders that are used by the detail objects. The Nature Shaders that come with Nature Renderer automatically support procedural instancing. Your own shaders or shaders from third-party assets may need some modification to support procedural instancing.

The following warning will show if procedural instancing is not supported by the shader:

nature-renderer-procedural-instancing-not-supported-warning.jpg

Shader Modifications

Follow these steps to add support for Procedural Instancing to your own shaders:

  1. Add the tag "NatureRendererInstancing" = "True" to your shader.
    This tells Nature Renderer that the shader supports procedural instancing. This tag should be added to the Tags section in the SubShader, it does not need to be added to each pass. You can easily find the correct Tags section by searching for the RenderType or Queue tags in your shader, since most shaders contains these tags.
  2. Add the line #include "Assets/Visual Design Cafe/Nature Shaders/Integrations/Nature Renderer.templatex" to each pass to include the Nature Renderer code.
  3. Add #pragma instancing_options procedural:SetupNatureRenderer to each pass. This pragma enables the Nature Renderer code for the shader.
...
SubShader 
{ ...
Tags
{
"RenderType" = ...
"Queue" = ...
"NatureRendererInstancing" = "True"
} ...
Pass
{ CGPROGRAM ... #include "Assets/Visual Design Cafe/Nature Shaders/Integrations/Nature Renderer.templatex" #pragma multi_compile_instancing
#pragma instancing_options procedural:SetupNatureRenderer ... ENDCG
}
...
Pass
{ CGPROGRAM ... #include "Assets/Visual Design Cafe/Nature Shaders/Integrations/Nature Renderer.templatex" #pragma multi_compile_instancing
#pragma instancing_options procedural:SetupNatureRenderer ... ENDCG
} } ...
Was this article helpful?
8 out of 18 found this helpful