Combine Materials at runtime... possible?

Hi

At the moment I’m trying to optimize a prototype of mine. In it I have a car that consists of multiple meshes (for animation purposes), which all come with their separate materials (as I might want to give players a way to “upgrade” their cars parts, so the meshes need to be swappable).

Now I have a mesh with about 12 parts, each having its own material. When all the lighting and shadows are applied though this number increases quite a bit, so to optimize performance, I would like to be able to reduce the amount of draw calls by combining all the materials into kind of a “dynamic texture atlas” at runtime.

Is there any possibility to do that in unity with scripting?

Thanks in advance for any help

Regards

gian-Reto

Yes this is possible. There’s an atlas packing thingy which helps pack all the textures into a single texture.

I think you’ll also have to remap your meshes uv’s to point to the area of the atlas image areas. I’m not aware of a built in function that will do this for you so you might have a bit of coding / searching to do.

Thanks a lot, I’ll look into it… I hope I’m not the first one that tries to do that and google will help me further, but I’ll find out :wink: