- Home /
Number of materials on a model
I am making a house inside and out in 3ds max. I first used regular uv maps to texture the walls and floors, but now im optimizing it, so im using render to texture. However as i go on im realizing that im going to have different materials for each room in order to keep the quality the way it was. How many materials is too much? Right now, not including furniture, i think i have around 8 materials for the house in total. This is my first time modeling such a large scene, and first time trying to optimize it, and im not sure how many materials is too much. Im targeting medium performance pcs, not iphone or mobile quality.
Answer by Bunny83 · Jul 29, 2012 at 04:58 PM
Another matierial usually means you also have that many submeshes. In other words, it's the same as you had split your house into 8 seperate meshes. Each submesh will have it's own drawcall. I don't think there's a submesh limit, but the overall vertex limit (64k) might give you problems, since if you use submeshes they all share the same vertex / index buffer.
Well when using a multi sub object material in max and importing it into unity, doesnt the mesh stay as a single object but it just has more than one material? by submeshes do you mean the meshes in the hierarchy that are childs of a main mesh in the drop down list?
Yes, it stays one single object, but this is not recommended. Bunny83 recommended to split the mesh into 8 smaller meshes, each using its own material.
The reason for this is that every material is a new drawcall. If your house had 8 materials, the house would be rendered 8 times every frame. If you split the house in smaller meshes, each of these would be rendered once. It would still be 8 drawcalls total, but each one of them would be faster, the 8 together roughly equal to a single one for the complete house.
Another reason for splitting the mesh would be that objects hidden by other objects would not be rendered. If you have a piece of furniture in the next room, but it is part of an object that you currently see, these polygons would still have to be calculated.
very interesting. So right now im splitting each room and giving it a different material, i was thinking in the end that id attach them together, but i guess i shouldn't?
also, before i started optimizing my model i had 4000 draw calls, now im down to 935. For a scene like $$anonymous$$e, what range should i be ai$$anonymous$$g for? Im not sure whats an ideal number of draw calls. But the information so far is extremely helpful thanks.
Here's the documentation of the mesh class. A submesh is still part of the same mesh. The mesh has one vertex array, but multiple triangle arrays. It might be a bit more "packed" when you use submeshes since all submeshes share the same vertices, but since a mesh can only have 64k vertices, you might reach the limit very quickly.
Also like Piflik said, the visibility is only deter$$anonymous$$ed for the whole mesh. Furthermore 8 or more materials on one mesh can get very confusing to match them up with the correct submesh.
The downside of using seperate meshes is that it will have a little bit more memory overhead. Each mesh needs it's own renderer and gameobject. Also those independent meshes can't share vertices, but usually you don't need this. Usually each submesh has it's own vertices.
Well i can't say much about good drawcall numbers. Anyway it depends extremely on your target platform. 4000 drawcalls are 100 times to high for mobile, but might be ok for desktop builds. It still depends on the user machine in the end.
Answer by oliver-jones · Jan 24, 2017 at 09:42 PM
Just for anyone who is interested. I conducted a stress test on a multiple range of iOS device. The first test was using a Single Mesh Model, the second was using a Multiple Mesh Model. Both exactly the same model, just combined mesh vs separated mesh, with a triangle count of 1,157.
The material being use was Unlit, so it was already very efficient to begin with. This is also running at maximum quality settings.
Both are pretty much very similar, although the Single Mesh performed slightly better than the Multi Mesh.