How to draw a mesh multiple times with different shader parameters

Hello to Unity users,

I’ve got a small problem I’m trying to solve and your help would be appreciated.

I’ve got a simple one pass shader with parameters that I can change from code, and I’d like to know the cleaner solution to draw multiples times (a varying / dynamic number of time) an object with this shader, but modifying the parameters between each draw.

What I’m doing right now is having N copies of the mesh in the scene, every copy with a different material (same shader, but different parameters). I’d like to optimize this by having only one copy of the mesh and a simple management of the draw count from code while still being able to update the shader parameters between draws.

How would you do that?

Thanks !

What you need is a material property block. You can use the same material and set a different property block for each renderer.