- Home /
Is it better to use multiple materials or bake texture on low poly assets?
I'm creating low poly assets for my game in blender. They are pretty simple, I just assign different colors to different faces (e.g. in tree leaves are green and trunk is brow). Before I just imported the to unity, but now I'm wondering if it's better(in case of performance) to bake texture and assign it to the object? Or maybe I should split the object to different meshes in blender and assign one material per mesh?
So the best option is to bake texture or use multiple materials?
Answer by Devastus · Aug 02, 2016 at 01:19 AM
Less unique meshes, less unique materials = less drawcalls. Less drawcalls = very likely better performance (in some rather rare cases this might not be true however).
Textures get stored in memory. Drawcalls use CPU.
So, strictly performance-wise, your best bet would be to have multiple objects using the same single material with the texture being a texture atlas that contains the textures for all the different objects inside one image. Your objects will be UV mapped into their corresponding places on the atlas, and thus you'll have just one drawcall (the other meshes will be batched) instead of a dozen, and dramatically reduced CPU load.
Since that may be more work than you require for results, I recommend you to atleast bake the texture for the mesh instead of using several materials to produce the same effect.
Thanks! That's exactly what i read about and I wasn't sure if it's a good method. So if I'm using only one color per face I can create for example 8x8 pixels texture(each pixel with different color) and map UVs on the correct color? Another thing is that drawcalls are now split to batches nad SetPass calls. I still have problem with understanding this, but to simplify: if this method works correctly which of these should stay on the same level?
Yes, you should be able to UV map them on their correct colors. Note that if you intend to do lightmapping of any sort, you'll have to make a separate Lightmap UV for each object as otherwise an 8x8 texture that has the UVs sorted in an atlas shape will more than likely produce severe artifacts.
In best scenario, you should see a positive reduction in both Setpass calls and batches. Now, my understanding may be invalid, but if I am correct, SetPass calls are the actual passes in shaders called to be rendered. Shaders can have multiple passes, and each post-effect will produce at least one SetPass call. Batches are the actual geometry and materials being grouped and sent to the GPU to be drawn, ie. grouped Drawcalls (someone correct me on this if I'm wrong).
Generally speaking, reducing the number of unique materials (and unique meshes using them) and the amount of passes in your shaders will result in better performance. The importance of doing intrinsic optimizations on these matters depends a lot on your platform of choice, and while I'm still a fan of good optimization, PC games for example can handle the absence of texture atlasing and other techniques to a greater extent. There's power in being able to modify your content later on, which often times gets cumbersome with heavy optimization applied.
Answer by Trevdevs · Aug 01, 2016 at 11:39 PM
I'm doing the same thing your doing, making a game with low poly models, what I've been doing is adding the materials in the modeling software such as blender which I'm using that way when it gets exported the materials are also exported automatically. So I would say multiple materials. Although it shouldn't make much of a difference which you use i Just find mine to be simpler.
Your answer
Follow this Question
Related Questions
Effects Of Tiling Textures 1 Answer
Mesh renderer with three submesh textures - only one renders properly, others are solid colors 1 Answer
Performance: many materials vs. TextureMap 2 Answers
How to fix a half transparent texture? 1 Answer
Can't copy skybox faces to a cubemap sized texture without huge quality loss 0 Answers