Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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:
    213
    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:
    2,983
    Hi!
    Please report a bug.
    Thanks!
     
  3. battou

    battou

    Joined:
    Jan 25, 2011
    Posts:
    213
    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