Search Unity

Bug Enabling GPU Instancing breaks Vertex color data (2021.3.0f1)

Discussion in 'Shaders' started by battou, Oct 25, 2022.

  1. battou

    battou

    Joined:
    Jan 25, 2011
    Posts:
    222
    Hi. Encountered a bug on 2021.3.0f1 Unity creating GPU Instancing enabled fragment shader.

    When I add #pragma multi_compile_instancing to the shader and enable instancing in inspector, then vertex color i.color from appdata becomes always (1,1,1,1). If I uncheck enable instancing toggle then i.color is correct in vertext program. At least when using on Sprite Renderer which passes set color through vertex color.

    Is there a fix or a proper way to get vertex color when using gpu instancing shader?
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,016
    Hi!
    Please report a bug.
    Thanks!
     
  3. battou

    battou

    Joined:
    Jan 25, 2011
    Posts:
    222
    I found a solution. But its not so obvious for someone not familiar with all Unity's cginc files. You need to include UnitySprites.cginc if you plan to use shader on Sprite renderers