I'd like to fire up the following question as I have found the same problem:
http://answers.unity3d.com/questions/3483/problems-with-graphics-drawmesh-where-to-call-it-and-how-to-get-material-propert
This is what I understand from the documentation:
Graphics.DrawMesh(...) is used to queue up meshes to render that you don't want to have gameObjects for. i.e. it saves you the cost of instantiating many objects if you want many copies of that mesh drawn.
If all of those meshes are to be drawn with essentially the same material but perhaps each one varies by colour or by alpha or something like that, you can use a MaterialPropertyBlock which is essentially some parameters to create a variant of the used Material to apply at render time. So this means you don't have to create a new material for every mesh drawn, you simply create a MaterialPropertyBlock with the modified element eg. the color.
The thing is that no matter how hard I try, every time I try to use material property blocks all the meshes are drawn the same. Apparently using one variant of the MaterialPropertyBlock for the whole lot. I guess what I would like to know is if I am interpreting the documentation correctly and if so is this a bug? And if it is a bug, is it fixed in Unity 3
Documentation for reference:
http://unity3d.com/support/documentation/ScriptReference/Graphics.DrawMesh.html
asked
Jul 18 '10 at 11:24 AM
cncguy
1k
●
21
●
25
●
36
Could you post some code demonstrating more precisely the problem you're experiencing? Having some code reproducing the problem to test with may increase the responses to this question and/or the linked one. Graphics.DrawMesh(mesh,matrix0,material,0,null,0,propertyBlock0,false,false); Graphics.DrawMesh(mesh,matrix0,material,0,null,0,propertyBlock1,false,false); alone doesn't really tell anyone how the use case is trying to change the property block although obviously instantiating two separate propertyBlocks should produce the desired result.
Also, Aras' answer in the linked question seems to identify a potential part of the problem. Are you using single or multiple pass shaders in your material? pixel-lit or vertex-lit shaders? If so it may well be the bug he mentioned and should be submitted as a bug report if it hasn't been already.
Hi sorry Missed your comments. Nightime here, will post some code tomorrow.