Can anyone clarify my confusion about Textures, materials and atlases?
I am trying to increase performance of my game by reducing draw calls, and as such I've started to make texture atlases for the textures where it makes sense.
My scenario is this:
I have a mesh, that I want to use several times, but with a different texture. So I figured I'd put all the textures into one atlas. Now the problem is that the UVs of the mesh will always be the same for all of the "instances" of it, which means it will always display the same texture, unless I give each instance a different material, and handle tiling and offset for each material.
My understanding is that if I use a unique material for each copy of the mesh, I will have gained no performance, is this true?
if true, then the only solution I see, is to go to my 3D application and make several versions of the same object with different UVs, which will be quite a chore, as I have lots of different meshes I need to do this with. If this is indeed the solution, is there an easier way to do this, preferably non-runtime?
Thanks for your time!
Answer by Raresh · Jun 05, 2016 at 12:51 PM
You will only gain performance by using the same material with the same mesh with the same scale. Other than that, you will drive the draw calls number up, which after a while might become enough to slow down your game.
Read up on Dynamic Batching for your case: http://docs.unity3d.com/Manual/DrawCallBatching.html
Thanks for your response Raresh :-)
I'm still a bit confused though- If I only save draw calls by using the same material on the same mesh, what is the point of making Texture atlases?
According to the manual, that you linked (Thanks for that, it was a nice read :-) ) it says the following: Unity can automatically batch moving objects into the same draw call if they share the same material and fulfill other criteria. The other criteria listed however, does not include that it has to be the same mesh.
Do you see my confusion?
I've considered looking into editor extensions and write an extension that can offset the UV mapping for me, but I'll refrain from doing that, until I know more on the subject- I'd hate to spend time on it, if it doesn't make any sense to do so :-)
Thanks for your time.
Texture atlases are for saving time on loading certain textures. Imagine a map like one from Battlefield. You would put all the textures for that map in an atlas, and load it when you need it. After that you unload it. It's just to save time and memory, as textures require more of both than other types of assets.
Answer by Nhauste · Jun 05, 2016 at 04:22 PM
The less materials you have in your scene, the faster your game will be. So yes, using the same material for multiple objects is a good way to reduce draw calls (batches). Unfortunately, you'd have to modify your meshes UVs to fit with the texture atlas you've made.
Thanks for your input. It's basically the same I gathered from reading about dynamic batching, as Raresh posted.
I appreciate your input. I'll look further into this, and maybe make an editor extension that allows me to do it easily in Unity.
Your answer
Follow this Question
Related Questions
Distorted/Warped Textures On Character Model After Bundling For Tabletop Simulator/In A Build 1 Answer
Why is texture sliding on different iphones? 0 Answers
Optimally adding textures to the Unity atlas 0 Answers
Mesh broken up into several pieces, how do I apply texture? 2 Answers
ProBuilder: texture UVs mess up badly 0 Answers