Search Issue Tracker
[2D] Instancing is broken when scene objects have custom properties set through material property blocks
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
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.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- Shader warnings are thrown when creating a new empty 3D HDRP project
- Crash on tlsf_free when exiting the Play mode in a specific project
- Advanced Object Picker switches to Classic with Error "Exception caught with search engine (Object Selector)Advanced" when opening multiple Object Picker windows
- The "secondary" touchpoint reverts to the previous position when the "primary" touchpoint is released and re-engaged on WebGL applications
- GameObject with Visual Effect Graph Component is blooming when the VFX Graph Color is set to "0" and Alpha is set "1"