|
A block of material values to apply.
MaterialPropertyBlock is used by Graphics.DrawMesh. 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.
Unity's terrain engine uses MaterialPropertyBlock to draw trees; all of them use the same material, but each tree has different color, scale & wind factor.
For performance reasons, the property block can contain only a limited number of property values. Two 4x4 matrices, 8 vectors/colors or 16 floats can be stored in the block. Storage space for the values is shared, so storing one matrix leaves twice less space to store vectors and floats.
Graphics.DrawMesh copies the passed property block, so the most efficient way of using it is to create one block and reuse it for all DrawMesh calls. Use Clear to clear block's values, and AddFloat, AddVector, AddColor, AddMatrix to add values.
See Also: Graphics.DrawMesh, Material.
AddFloat |
Add a float material property. |
AddVector |
Add a vector material property. |
AddColor |
Add a color material property. |
AddMatrix |
Add a matrix material property. |
Clear |
Clear material property values. |