Performance concerns about using too many materials in one scene

So I have a project where I will look orginise too many object. Those objects are similar to eachoter but different meshes and textures.

Imagine a supermarket where you have bunch of snaks. When you take a general look they all have the same shape more or less. You need to see them all the time and they are not static you can pick them up look an put it back.

So that raises a problem in my head. How can I reuse most of my materials by only changing it’s textures.

I’m not a graphics programmer so for give me if I say something noob.

Here is what I tought.
Enable Material instancing. I know that enabling material instancing is good if I have multible copies of same mesh and same material but in my case my meshes are slightly different and materials have different textures.

Dynamic Batching. I know I can batch dynamic objects but there are too many limitations. My models are lower then 900 verts but I haven’t decided on a shader yet. I’m thinking about Uber shader but dynamic batching limits me interms of shader choice and vertex coun’t I’m not sure using standart or Uber shader would force me to lower my vert couse I can’t go lower poly than I already am.

The last but not the least is the 2DTextureArray and MaterialProperityBlock. I think this is the best way to go in my stuation but there aren’t so many tuts or documantation about it. As far as I understand it’s easy to use in c# but I’m afraid if I crash a wall while using this I may not be understand what’s wrong since there aren’t much reasources out there that explains how this method works.

I want to know what you are thinking what would you do if you had the same stuation.

Cheers! :slight_smile:

You shouldn’t have any performance issue on the amount of materials, but more the number of different meshes with about 900 verts each. Have you tried running the Profiler to see what is actually dropping your frame rate?
If the performance issue is about to many high poly meshes, then you whould consider making your object more simple models (low poly).

Actually I haven’t started this project. There is a similar project and I need to write a newer version of it. I was told that they will have so many materials and meshes but all meshes are well optimized. However as the number of materials increased and I’m expected to change them on runtime it will eat some gpu memory. Because I’m gonna have to create virtual materials and assign them at run time. What I want to decide at this point how should I start building the project interms of runtime material changes.

Here is an example of what I want to do. Exept this guy changes a single material for the same mesh. My meshes are similar but not the exect same.