Multiple materials v/s single material - Best practices?

I’m confused about the performance implications of using multiple materials for a mesh as opposed to a single material with individual UV sections for each material used by the model.

A few questions:

  1. Which is more performant? Eg: if I was texturing a sword would I use one material for the metal blade, one for a cloth scabbard, one for a ruby gem on the scabbard, etc or create a single material with 3 UV sections for the blade, scabbard and ruby gem each representing a different material?
  2. Does using multiple materials mean the texture resolutions for each material should be set relatively lower as compared to a single material so you don’t end up using too much memory?
  3. Would you agree that with multiple materials it becomes easier to use the Unreal Material Editor to add extra effects as compared to a a single material approach? For example if I wanted to make only the ruby gem emmissive I’d just set up the emmissive node for the ruby material however if it were all a single material I’d need to create a bitmap mask masking all the other UV sections and lerp that into the emmissive node right?
  4. Multiple materials also seem to work without any UV maps if you just assign unique materials right within the 3D modeling app and refine them in UE. Obviously this doesn’t work for normal maps, etc but is this idea of skipping UV maps sensible in any way? I can always quickly auto-generate the lightmap UVs so there’s zero UV-ing work that way.

All in all, I find using multiple materials far more convenient but I’m worried that I’m missing something here, especially performance wise.

Thank you for asking this question. I ran into this exact same dilemma in my own development last night, and I would love to hear some responses.

Hi,

Im still far from the top of the learning curve, but this is how I would approach it:

1: I would create a texture that covers the entire sword in all its beauty, say a 256x1024 texture.
Then I would create a second masking texture with the 4 channles each masking out a section of the sword with the white areas defining what later is visible.
When you multiply each channel in the mask texture with the overall sword texture you get the separate parts where everything else is black. (now add any effects you want to the different parts=.
To put it together, you dont need lerps, you can simply add them together to get the full sword image.

2: It depends how you scale it and how large the area is that is shown. I read between the lines that you have a slight aversion towards uvmaps :rolleyes: , but remember that for mesh materials the entire UV space is covered. So you would have to scale them down anyway using TextureCoordinates nodes.

3: I find it easier to work with single materials and single maps. Only for really complex objects like characters I would use three different materials for body, head and face…

4: I have so far not noticedany performance penalty. A lot of the example content uses multi material setups, so I guess its a legit way to deal with mesh texturing. Unless the guys at Epic show us things we shouldnt do :smiley:
It working with multiple materials works for you, stick with it, but you should definitely try the masked approach. It offers exactly the same degree of flexibility you are looking for.
If you want, i can make a short example…

Cheers,
Klaus

The one big thing here is the performance, each material takes up 1 draw call, so if you are using 3 materials on the sword, it will take (approximately, this will vary) 3x longer to render. This might not be an issue for something like a sword, but in general, try to keep the draw calls to the minimum possible. The more complex each material is, the bigger impact it will have on performance.

This is not to say it does not have it’s merits, I will be using a mixture of both techniques on my vehicles, but it is not a good idea to use this method exclusively for every object. Try and reserve it’s use to objects that will be on screen most of the time and need that extra bit of detail, such as a weapon, and use the texturing approach for everything else (where possible). :slight_smile:

Thanks Klaus, that was a useful rundown of your workflow! The multi-material approach is new to me, I’d usually just a single material and paint the various maps.

On my aversion to UVs :slight_smile: I’m currently modeling a plant that has a single flower with dozens of tubes and spores coming out of it. The tubes are just so small that any detailed surface variation I add just isn’t visible to the player anyway - so I’ve currently just assigned a couple of unique materials in Blender to these tiny tubes and used the material editor to add an appropriate roughness value to each material (and zero metal because this is a plant of course). Using multiple materials I could texture around 75% of the plant this way within seconds, except for one material for the flowerhead which I’ve UV-ed because it truly needs a lot of detail and surface variation that I’ll need to paint in another application. If I had spent the time UV unwrapping the entire thing I’m guessing I’d have spent more time than I did modeling the plant! I’ve auto-generated all the Lightmap UVs as well.

I do have a feeling I’m taking shortcuts that will hit me down the line! It’s just not apparent how, yet…

Edit: Just saw DotCam’s post, thanks I didn’t know this affected draw calls. My level is pretty small but I guess I’ll need to get a feel for up to what extent I can get away with multiple materials.

Well the nature of best practice can only be applied to a given context and not as a blanket ideology as to what may or may not fall under the same category so with in context.

  1. UE4 is very good at handling performance issues in the background, more so if procedural materials in this case is used, and what seems to be what I would consider best practice is not so much about performance as it is about what gives you the best flexibility. Procedural materials for example will in most cases produce the best results with the best performance curve and the use of individual materials, more so if it’s an instance materiel will give you the best of both worlds.

  2. Yes and no. If you use diffused or photo source textures resolution does become an issue but once again procedural materials will give you a much better result. Metal for example you don’t need a 2048X texture when the same result can be achieved by a procedural material using numeric values.

  3. This is where instanced material could be used as a single material can be used and modified and as the material is modified it’s a free lunch as far as performance goes. The benefit is a single material could result in hundreds or even thousands of variations but still has the performance hit of the single material.

  4. Well the real question is how long will it be before we don’t even need UV maps? The nature of procedural materials is its a mathematical function and how layered materials are used is far superior as being able to define a mask as to areas that a texture should be mapped to.

Overall how to make best use of the material editor requires a top down rethink where the best practice, in my opinion, would be to consider how to make a material a math function with little or no dependency on defused materials. In other words the idea resolution becomes a thing of the past.

Hi,

@FrankieV

I love procedural materials (and procedural geometry… POV-Ray yaaay! :smiley: )
But some things just cannot be accomplished with them.
You can make checker boards procedural and some other cool stuff, but some stuff will require an image texture.

That question is closely tied to the queston: Do you want baked static lighting?

People mostly associate UV maps with (image) textures, but they are so much more usefull.

Cheers,
klaus

Cheers,
Klaus

Can you give an example?

Granted there might be a need for a defined texture but for everything else there is layered materials.

What is confusing is the word us “mask” is somewhat miss leading.

Better example of layering materials.

The idea of material ID’s is still there just done a different way.

Hi,

Sure. :slight_smile:

Although this wall would be nice for layering materials, try to make the logo procedural…

Anything that is not a generic material like “wood”, or “marble” but is of graphical art (graffity on a housewall), requires an image as basis…

Cheers,
Klaus

Try to make that house with a procedural coca cola logo…

Those are some really helpful links, FrankieV. It seems like both approaches are valuable for different scenarios. In any case, I shouldn’t stress too much about which approach to take right away.

Yeah you bet what works works.

But

The challenge has been issued and although I don’t currently have the skills maybe someone at Epic with mad material skills, and since it is free project Friday, can prove, or not, it it can, or can’t, be done. :smiley:

For that matter lets make a game out of it?

Someone issues a challenge and the first to come up with a working solution selects the next challenge.