Search Unity

Feedback Unity should really clarify what the h*ll Instancing variants "Strip All" does.

Discussion in 'General Graphics' started by bitinn, Jun 11, 2019.

  1. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Sorry, I was mad, I spent a month asking people what Instancing variants "Strip All" does, including QA and Unity engineers, and still doesn't understand it.


    The option:

    Screen Shot 2019-06-11 at 21.09.05.png

    https://docs.unity3d.com/Manual/class-GraphicsSettings.html#stripping



    My question was simple:

    Can you use Instancing variants "Strip All" with GPU instancing?



    My understand was:

    - People has been using Instancing variants "Strip All" option to reduce build time with success.
    - But when I use it, the instancing shader isn't included in my build, so my DrawMeshInstanced failed.
    - Note that my script has a direct reference to the material, and it works in editor.
    - I tried Shader preloading list, Always-included shader list, none of them take precedence over "Strip All".
    - While at the same time, MeshRenderer referencing the same material (instancing enabled), render just fine.


    Some screenshots and code:

    Screen Shot 2019-06-11 at 21.14.01.png Screen Shot 2019-06-11 at 21.17.09.png Screen Shot 2019-06-11 at 21.10.15.png


    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.Rendering;
    6.  
    7. public class TestSpawner : MonoBehaviour
    8. {
    9.     [SerializeField]
    10.     private Mesh _Mesh = null;
    11.  
    12.     [SerializeField]
    13.     private Material _Material = null;
    14.  
    15.     private List<Matrix4x4> _Matrices = null;
    16.  
    17.     private async void Start () {
    18.         var positions = new List<Vector3>() {
    19.             new Vector3(2f, 0f, 2f),
    20.             new Vector3(4f, 0f, 2f),
    21.             new Vector3(2f, 0f, 4f),
    22.             new Vector3(4f, 0f, 4f)
    23.         };
    24.  
    25.         _Matrices = new List<Matrix4x4>();
    26.         foreach (var pos in positions) {
    27.             _Matrices.Add(Matrix4x4.Translate(pos));
    28.         }
    29.     }
    30.  
    31.     void Update () {
    32.         Graphics.DrawMeshInstanced(
    33.             _Mesh,
    34.             0,
    35.             _Material,
    36.             _Matrices,
    37.             null,
    38.             ShadowCastingMode.Off,
    39.             true,
    40.             0,
    41.             null,
    42.             LightProbeUsage.Off,
    43.             null
    44.         );
    45.     }
    46. }
    47.  

    TL;DR:

    I am so confused.

    People with knowledge, what the hell is going on with "Strip All" and GPU instancing?


    I should note that there are exactly 3 Google results on this topic, ALL of them asked by me.

    Screen Shot 2019-06-11 at 21.15.20.png
     
    alexmcgt likes this.
  2. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Unity QA has closed my case 1153579 for this question as by-design, so basically:

    Can you use Instancing variants "Strip All" with GPU instancing?

    Their answer is No, you have to use "Strip Unused", there is no other workaround.

    https://issuetracker.unity3d.com/is...en-using-strip-all-instancing-variant-setting

    I don't know how people in the thread below does it with "Strip All" enabled, maybe they all just happen to not use gpu instancing at all, but anyway, that's the official stand.

    https://forum.unity.com/threads/compiling-shader-variants-taking-ages.527724/
     
    dairectx likes this.