Search Issue Tracker

Won't Fix

Votes

3

Found in

2017.4.0f1

2018.2.21f1

2018.4.0f1

2019.1.0a1

2019.2.0a1

2019.3.0a1

Issue ID

1172825

Regression

No

[2D] Instancing is broken when scene objects have custom properties set through material property blocks

Graphics - LowLevel

-

How to reproduce:
1. Open the attached project ("2D_Instancing_Bug_-_2018.2.zip")
2. Open the repro scene ("SampleScene")
3. Open the Frame Debugger
4. Enter Play mode
5. Enable the Frame Debugger
6. Inspect the "Draw Mesh" calls

Expected results: Draw Mesh calls are instanced
Actual results: Draw Mesh calls are not instanced because "Non-instance properties set for instanced shader"

Reproducible with: 2017.4.31f1, 2018.4.5f1, 2019.1.13f1, 2019.2.0f1, 2019.3.0a11

Workaround:
Material Property Block values that are set by Sprite Renderer cannot be used with SpriteRenderer.GetPropertyBlock because they contain a texture property - _MainTex, which breaks instancing, even if this one texture is shared by consecutive draw calls. To work around this, material instances have to be created for each texture: at runtime copy materials for each texture/sprite and assign textures directly to material instance as _MainTex instead of MPB. Runtime changes to Sprite Renderer properties such as flip, color will also have to be manually monitored to update as you can no longer use GetPropertyBlock and update those values in a bunch.

  1. Resolution Note:

    Edge case user workflow scenario

Comments (2)

  1. bobbaluba

    Oct 11, 2020 15:42

    Still an issue in 2020.1.6f1

  2. Last8Exile

    Jun 24, 2020 19:40

    Got the same issue with 2019.4.1f1 version.

    Sometimes sprite renderes will batch, sometimes not. If i reshufle them in hierarchy or randomly disable then enable some - they may or not batch together. Totaly unpredictable nonsense.

    All sprites come form singe sprite atlas, have same size and same settings.
    Even then all instanced properties in MaterialPropertyBlock have same values for every instance.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.