Search Unity

Can someone help me to figure out why GPU instancing failed after building in Unity?

Discussion in 'Shaders' started by Dragon_Baby, Sep 16, 2020.

  1. Dragon_Baby

    Dragon_Baby

    Joined:
    Apr 19, 2020
    Posts:
    7
    Here's what I have in C# code:
    Code (CSharp):
    1.        Graphics.DrawMeshInstanced(meshToDraw, 0, material, renderMatrices, renderMatrices.Length, null, ShadowCastingMode.Off, true, 0, null, LightProbeUsage.Off);
    In shader, I add some code like this:
    Code (CSharp):
    1.             #pragma multi_compile_instancing
    And I already used the instance in shader.
    In my graphics settings, I set the Instancing variants to be Keep All.
    But after building, I can't see any mesh to be rendering.
     
  2. Dragon_Baby

    Dragon_Baby

    Joined:
    Apr 19, 2020
    Posts:
    7
    I've already accomplished it.We also have to add your shader with instance to the Always Included Shaders.But it's better to use RenderDoc.