Download

Combining materials and textures for performance

Hi everyone, I have a few questions regarding combining material instances and textures for performance.

  1. I understand that it is better for performance (reduce draw calls I think?) for models to use as few textures/materials as possible. But is there a guideline on how many there should be, and is there a point where it becomes pointless optimization? For example, what if I combined every character texture into a massive 8k map, and then another huge texture for all environments, then another for all particles. Then in every scene I’d only be using 3 materials at most. Would this benefit performance in any way? Does UE4 automatically do something like this on packaging?

  2. Is it reducing textures or materials that reduces draw calls? For a character model I’m working on, I UV and texture each part separately, so currently I have a lot of materials and textures. I am thinking of placing them all into one texture map, then use UV offsets in different materials to get the UVs to match up. This means I will have few textures but lots of materials, is this bad for performance? My character uses 10 very simple material instances - is this a lot? (See the attached picture if you want to see the material complexity)6012c97df70ba3eb59cb33b1b9c2a112bf3c92f9.jpeg

  3. Is there a way to automate this process in UE4 or Maya? The only way I can think of doing this is piecing together the texture maps in Photoshop, then manually realigning the UVs in Maya, or importing into Unreal but adding UV offsets to the materials (this would not reduce the amount of materials though). Both of these methods are very time consuming, there must be an easier way right?

Any help or advice is appreciated, thanks in advance!

Having a huge atlas for all texture is pretty pointless, because you are wasting space for textures in memory that are not used.
You need to balance this.
For each Material Slot in your Mesh you add atleast 1 Drawcall. So you should keep the used Materials as low as possible.

My Characters use 2-4 Materials each: Clothing, Hair, Eyes and Skin where each texture ranges from 512 to 2048, but never bigger than that. My BaseColour/Subsurface Maps are 512, whereas my Normalmaps are 1024-2048.

The number of materials on each mesh will increase draw calls, so for 20 meshes that’s 20 draw calls for materials, even if they’re using the same material. There’s other areas where the number of materials being used will improve performance though. So for example, if you have a bunch of objects with a solid color then it’s better to make a simple texture with a swatch for each color and put that into a single material than to make a separate material for each color individually.

Well a performance saving is preformed by default as long as you stick with power of 2 textures.

So 4 512X textures is the same as say 1 1024X texture as far as video card memory requirements as they can be packed edge to edge as part of the process.

As for using a texture atlas it’s something worth doing but only when the environment is completed.

For that matter

Optimization of an environment is something that can be deferred until your are done with the environment and then preform a profile and see what needs attention as to real time play.

https://www.youtube.com/watch?v=-csRxRj_zcw

Thanks. I think I’ll work on reducing materials then. So does anyone know of an easy way to combine multiple textures into one? I can’t think of any easy way to do it, should I just redo all the texturing and just UV map everything onto as few maps as possible?