question about multiple materials

sorry if I’m asking some stupid questions, but I really have searched a lot on references and the forum, still cannot find the use of materials.
My question is why it need multiple materials on one gameobject? Does it only mean it can be easy to switch between different materials? such as:

if( flag < 0) 
 gameObject.meshrenderer.material = gameObject.meshrenderer.material[1];
else
 gameObject.meshrenderer.material = gameObject.meshrenderer.material[2];

or it can be used to make one mesh has two different parts,each part has a material?

Also, I have made a project that can load more than 100 3D models in one scene, such as an indoor scene. Each model has more than 2 sub objects, each has a corresponding texture. Such a scene renders rather slow. Is there any method to accelerate the rendering speed?

the drawcalls is around 2000, tris 553.7K, verts 1.7M, texture 236-80.7MB, render texture 20-16.9MB

Hello,

You do not need more than 1 material in one GameObject. looks like you are using objects designed to make renders, not for real time 3d projects :s

If you can, try to use 1 material per gameObject, It would help a lot on your project performance.

Also, you can render selectively to gain more performance,make sure also your meshes are optimized.

thanks. If one material is proper for one gameobject,then, why it has a material array for each gameobject? what’s the use of it?

Secondly, I have tried the large scene in Openscenegraph which uses C++ and opengl to render, it does not suffer any frame rate slow problems. It’s kind they use scenegraph and some other accereration schemes to optimize the rendering speed. Is there any smilar accertating scheme in unity because the same scene looks much slower than openscene graph. If not now, have you guys any plans on that?

You can’t always do everything with one material…if you have a character, for example, you have skin+clothes+hair+eyes+teeth which is probably going to be at least three different materials, depending on the look you’re going for. But you want them all on one object, because you don’t want to separately animate several different parts and combine them together manually somehow, which would be painful.

For indoor scenes, it’s not hard to implement your own kind of portal culling using triggers.

–Eric

thanks, that’s very helpful! Is there any portal culling scripts available to reference?

I’m not sure if there’s any actual example code, but this subject has come up more than once and has been discussed in some detail, so hopefully a search would find more info.

–Eric