Material optimisations

Hi Epic/Community,

I wonder if anyone can shed light on best practice for material performance.

I don’t necessarily have performance issues right now, but would like to get in to the best practice to mitigate it down the line.

So my question is, do we have to structure materials like the M_Owen_Master (in the Content Examples) or, can we break the M_Owen_Master in to multiple materials without a performance hit.

I am open to suggestions, as from a programmers perspective, M_Owen_Master currently resembles a “God” class and breaks the single responsibility principle.

Hope anyone can help.

Hey unfortunately I don’t really know about the materials you are talking about but here are couple of general ideas that always help.

  1. Less materials is better → different engines allow to optimize use of multiple materials via batching them together, but ultimately it comes down to keep exchanging information between GPU and CPU to minimum. Beside the performance it can also help to make it easier when you need to work with materials via code.

  2. Less textures is better → especially if you are able to tile your textures, try creating texture atlas, where you keep different textures together, this will allow you to send less information onto GPU, it’s possible to keep albedo, specular, roughness etc. in same atlas, depends on your choice

  3. Batch stuff together → this is not only about materials, but if you have lot of same objects, consider using Hierarchical instancing, this speeds up rendering immensly

  4. Only render what you need → this obviously means all general ways to cull and simplify scene, interesting stuff for UE especially for large scenes is terrain LODs generation, asset streaming, this also goes for the complexity of the objects you are rendering

  5. Profile → If you feel your scene is not rendering fast enough, you will need to figure out where is the problem, UE has a pretty neat GPU profiler that helps a lot see here: GPU Profiling | Unreal Engine Documentation

  6. But… → With that said I’m not saying you shouldn’t use multiple materials per mesh, and it can have its reasons, like if you need to swap them it’s probably easier if materials are separate rather than if it’s all one huge material

Ultimately you want to figure out if there’s a problem or not, that depends on what hardware you are going to aim your project on and what performance you want to get. Good advice is always, don’t fix what isn’t broken :slight_smile:

Hope I managed to answer at least a little bit of what you were asking.

It is almost irrelevant in terms of performance if you use instances of large generalized master material or break it down into several special case materials. Whatever takes less production efforts is usually preferable.