2d shader materials blending VS game object layers

Im curious if anyone can answer a performance/technical question.

I have a randomly generated 2d levels filled with visually randomly generated 2d props. Averageing around 250 props per level. Props are tables, desks, chests, etc.

Each prop had 3 layers of randomly generated sprite textures. Currently represented inside 3 game objects with a sprite render as children of each prop’s game object. Each prop also assignes a single instance material to each sprite render to determine the color.

My question is would it be better performance wise to:

A. blend the 3 textues inside the materials and have 250 material instances assined to 250 game objects/sprite renders?

Or

B. have 1 material instance assined to 750 game objects/sprite renders.

My instincts are telling me A, but i wanted to see what others have to say before i change a bunch of scripts.

I wouldn’t listen to that!

For all performance and optimization issues, ALWAYS start by using the Profiler window:

Window → Analysis → Profiler

For your specific issue you might get something out of the Frame Debugger window as well, perhaps some insight into how things are decomposed, recomposed, and rendered.

1 Like