Is texture atlasing useless when you are constantly changing materials?

Hello, I have worked hard to pack every chara/enemy image in one big texture atlas but started wondering if it has any point doing so? I’m constantly changing scales, colors, and texture uv positions of enemies for animation so they don’t really share same materials. I think it won’t be much drawcall batch.

Is there still some performance benefit using one big texture atlas like not having have to switch textures? Or if materials are constantly changing, there is really no difference between using one big atlas and using 100s of small separate textures? I’m actually eager to stop packing textures if so… It’s so much easier to manage images in separate files. Please help!

If you use different materials for different objects, they can’t be batched, so indeed there is no real reason to use an atlas in that case.

What is costly is to switch shaders/material, incurring in CPU overhead. If you are not using the same material, you’ll get no benefit from the atlas (Draw Call Batching).

  • Using different material instances - even if they are essentially the same - will make objects not batched together.
  • Objects with lightmaps have additional renderer parameter: lightmap index and offset/scale into the lightmap. So generally dynamic lightmapped objects should point to exactly the same lightmap location to be batched.
  • Multi-pass shaders will break batching. Almost all unity shaders supports several lights in forward rendering, effectively doing additional pass for them. The draw calls for “additional per-pixel lights” will not be batched.
  • Objects that receive real-time shadows will not be batched.

Switching textures is costly for the GPU, but GPUs have caches and I’m unsure about how much of an impact this can have. See this comments about Texture Bandwidth on GPU Gems.

Finally, if you needed to use texture atlasing very often, my recommendation is to build an Editor script that does the atlasing and sets UV coordinates automatically (for this check into Texture2d.PackTextures).