MaterialPropertyBlock is used by Graphics.DrawMesh and Renderer.SetPropertyBlock. Use it in situations where you want to draw multiple objects with the same material, but slightly different properties. For example, if you want to slightly change the color of each mesh drawn. Changing the render state is not supported. Description Add a vector material property. For performance reasons, the property block can contain only a limited number of property values. Two 4x4 matrices, six vectors/colors or 12 floats can be stored in the block.
Customer is currently making use of BatchRendererGroup using the RenderMeshSystemV2 of Hybrid Renderer, it's modified in some Areas but the Core Batching is still the same logic. The Customer has added Material property blocks, which are working well when no culling happens. When individual objects get culled from a batch, the MPB instanced data does not get correctly updated, is this expected? The Transform Data gets correctly updated to match the visible objects.
To reproduce:
1. Download attached 'ECS-RenderBatch-MPB.zip' project and open in Unity
2. Open 'ECS-MPB-Batching-Test' scene
3. Enter to Play mode
4. Pause Play mode
5. Select 'Main Camera' gameObject and change Y Position with Mouse
6. Observe that Colors starts jumping around to different Entities due to bad indexing of instancing data
Notes:
- This might be Hybrid Renderer or Entities bug
- It is impossible to check for Regression of Hybrid Renderer because it is Modified by Customer
- It is impossible to check for Regression of Entities because when Upgrading to preview.24 - 0.0.12 or lower whole Project becomes Corrupted
- It is impossible to check on Unity 2018.4, 2019.2 and 2019.3 because Project becomes Corrupted
- In Package Found Version I pasted Hybrid Renderer version
- Another issue is if Customer set the Material property block through the SetInstancingData function of the Batch Group and set the Material property block to Null in AddBatch, then Customer gets no rendering at all
- Video and portion of the Code for Reference are added in Comments section
Reproduced on Unity 2019.1.7f1 and 2019.1.11f1
Hi,I wanna change the texture of my spine animations, with this forum's advice I made it work by using MaterialPropertyBlock.
But some animations not working properly, some parts of its attachments are not replaced with the new texture.
I checked its slots and attachments, found that they are hidden/showed, I mean when I setting MaterialPropertyBlocks the MeshRenderer's materials did not list these attachments' materials. So I must check the spine's meshrenderer's materials every frame, it's very bad.