Multiple materials per mesh

Hi there.

I’m just getting started in Unity. I’m currently working with someone to build assets for the asset store and I was curious about balancing performance with the standard shader with textures and multiple materials.

Here’s a bit of background. A couple years ago I worked as a freelance 3D artist to build some low resolution cars for a game that was built in Unity. At the time the shader was designed by the company to be as efficient as possible on mobile devices. Most of the overall look was handled exclusively by materials, with very little texture work. There were approximately 10-15 meshes. From body, to light casings, break pads, break discs, etc. Each item was a separate mesh that had it’s own material.

Furthermore, there was essentially 1 UV map. In other words, It was UV unwrapped so that if you combined everything into 1 mesh, all UV’s would be laid out in the 0_1 space. This is how the client wanted it, but I had some concerns about efficiency. It basically meant that the small items, such as a license plate, or light cover, or steering wheel, occupied very little space in it’s own 0_1 space. The positive side, however, was that there was only 1 texture map. No matter what material it was assigned to, the texture covered the UV shells properly. The texture map was 2048 x 2048.

Today, that small business no longer exists, the owner is working with me to modify these cars to put up on asset store. the old version was designed to work well specifically with their game, however we want to make them a bit more general, which means I need to change a few things in regards to how the model is broken up, and how the UV’s are laid out.

Alright so here’s my question. When it comes to memory footprint and performance, is it more efficient to give each item it’s own UV space, then assign it smaller textures, such as 256x256, or 512x512 (depending on the size of the mesh, ie break pad vs body), then assign each item it’s own texture, or is it more efficient to combine everything into 1 large texture map, and keep the UV"s as they were?

Also, if I were to combine break discs, break pads, rims, and tires into 1 mesh “wheel”, would I be able to maintain separate materials for each of those components? This would allow me to have fewer UV shells and fewer textures.

I hope that made some sense. If not, ask for any clarification and I will provide. Again, I’m just getting started working with Unity so there’s still a lot I don’t understand just yet.

Regards,

J

I think it makes perfect sense, what you wrote :wink:
I don’t think you can get one good answer, though. So here’s something to consider:

Having all meshes laid out on one sheet:
Pros:

  1. It would be easy to make an LOD system, as all objects share one texture, and could essentially be placed on one simple LOD mesh, and still look somewhat like the original car. Batching is good.

Cons:

  1. It would be hard to make a libary of, say, 20 license plates, 20 wheel types, 20 whatevers, and then mix them together to produce a ton of variantions.

Having specific textures for each car part:
Pros:

  1. Easier to create the car, as you don’t have think about the overall uv layout. Say you want to add a detail, and there is no more room in the layout, you wouldn’t have to relayout everything, change the global texture etc.

  2. Easier to fix specific resolutions of specific parts.

Cons:

  1. Harder to batch stuff together for performance reasons later on (More drawcalls)

  2. More assets in your project.

Note: Having one mesh with multiple materials (Sub Meshes) is a pain, and very clumsy to maintain. You can’t turn off a sub mesh, if needed. And one mesh with multiple materials is just (or close to) as performance hungry as multiple meshes with one material. Always, imo, go with one mesh/material per logical GameObject.

What I would do? I would probably go with having specific textures for each part. Then you could place 200 license plates on a texture, and make a randomize script (Which would offset uvs) and so on. So much potential…
And I would make sure the color of the car was controlled by some dynamic color input, and only dirt and scratches was in the texture. Think out a system that makes the variation possibilities gigantic.

Then, if needed, I could always batch stuff together in a script (UV atlasing, bake several textures into one) at release.