Materials and performance

I’m making a bunch of objects to UE, and I’m having a doubt about the materials.

I want this objects to be optmized, but I wonder if the best is to use tilable textures for objects with wood or brick materials for example, or if the best is to create a texture map for each object, for example, I have three tables that will use the same wood material, if I create a texture individually for each one of the tables I will have three textures + normal maps+ spec maps, etc, in other hand, If I make a single material called wood, and add this material to all the objects I will have 1 material on the scene.

So, what is the best way to do it?

Less individual textures - better performance. Thats what I know. But do you mean if it is better to have one big texture (for example 1 texture containing all 3 diffuse textures for your tables) instead of 3 smaller ones? That would be the question that I have.

Hope somene can answer this: )

Thanks build, I’m really in doubt about that.

Optimized is one of those words that gets used often as “Best possible setup ever anywhere” when it really should mean “Best possible setup for this specific application”. The answer to all your questions is “It depends.”

To be more specific about what it depends on, it depends on what capabilities the platform you’re targeting has, what hardware resources are available, and how much of those resources the rest of your game is using. Ie if you wanted to use layered materials you may not be able to target mobile devices.

Though you are hitting on the general rule of “As few resources as necessary”.
Every choice presented here is a trade-off rather than an objectively better way of doing things.

To your example, the first thing to do is to not confuse materials with textures. Materials are shaders. Code that defines how a surface looks. You can create a single material to be used on all of your props, and just swap out textures via material instances. This is common and fairly inexpensive.

The advantage to having unique textures per prop is you can have unique detail, and each asset can look its best.
The downside is that requires at least one additional draw call per material switch and requires VRAM for every texture.

Having a single tiling “wood” material may be useful. The renderer will be able to batch all the objects with that material applied, you’ll save on VRAM, however you absolutely must create your assets, especially their UV layouts, with that tiling texture in mind, and they very well may not look as good as a model crafted with its own specific textures.

If you are targeting higher end systems, you should look into layered materials. You can set up a material function that is your tiling material, and use that in a master material for your assets, but you can blend and alter that tiling material with asset specific textures, like normal maps and roughness maps. (which will be important for selling a high quality prop)

This way you can keep the main wood textures in memory across all the assets, but they can still have individual flair.

A third consideration when dealing with this kind of thing is “How often will these assets be seen together?” If you anticipate that these assets will often be in the same scene you can get more mileage out of your resources by having them all share a texture atlas, which brings you back to one material and one set of textures loaded, even if the individual textures are larger to ensure adequate texel density.

Thanks Valias, your answer is great, it really helped, you are absolutelly right I think, even tough its still hard to find the “best” alternative, but you gave me some great ideas, thanks!