What is the performance price of additional UVs?

I want to use an additional 3rd set of UVs (apart from the main and the one for Lightmass) for precise placement of certain things in the material (leaks, rust, etc. with very specific non-tileable textures). What would be the performance cost of that?
The only thing I managed to find in the manual was in the GPU profiling, where among the non-resolution related performance issues is: “Too many vertex attributes (extra UV channels)”. But there are no further details given. I understand the increased vertex count implications, and the that if I make anything with normals with the 3rd UVs, the tangent space will still be calculated with the 1st UV set, but that’s it. What else should I worry about? Please, enlighten me :).

Having another UV set or essentially an additional Material ID will result in an extra draw call per frame. I wouldn’t recommend going crazy and having everything have three or more UVs/Mat IDs, but the occasional object is not going to be that big of a hit. Another thing to consider as well is texture resolution and whether the texture is a power of two. Again, having that extra draw call for that material ID slot will be added and having a larger texture for it will result in a heavier hit.

I hope this helps!

Tim

1 Like

Thanks for the answer!
Sorry, I should’ve mentioned that I’m not using several Mat IDs. It’s one ID with blended Material Layers, and a total of 3 UVs. The top-most MatLayer uses these UV coords for the aforementioned purpose. Or do you mean that having one extra set of UVs is akin to one extra MatID in some way?

1 Like

They are akin but they are not the same. While they are both resulting in different performance hits they are different. With an additional UV you are mapping information to the vertexes and with a Mat ID you are mapping information to the faces. The Mat ID way is less of a performance hit than the third UV though.

1 Like

Big thanks for your help! Very interesting. Couldn’t have solved it without your clarification.

Tim, please confirm:
The Mat ID - worse for performance?

For anyone coming there through Google:

Having another UV set or essentially an additional Material ID will result in an extra draw call per frame.

@Tim_Hobson , please clarify + confirm that claim. That doesn’t make any sense . Here’s some more info :

https://www.reddit.com/r/unrealengine/comments/twfgoc/confirmation_on_additional_uv_channel_findings/

   The number of UV channels is irrelevant to the number of draw calls. In your example material, it would be completely absurd for that material to be split into separate draw calls. This is because every shader execution of your material requires the information from all 8 UV channels at once. In order to split that up, UE4 would have to analyse your material graph and determine that the first 4 and the last 4 could be split into separate draw calls and then combined in hardware using multiply blend mode on the deferred color buffer, which is only possible because your graph happens to multiply them together and only use the result for color. This split would also incur double the vertex and rasterisation cost for no reason. Most other materials would be impossible to split.

They (and you) may be confusing draw calls with texture samples, which is approximately proportional to number of texture sample nodes (not UV channels) multiplied by the number of pixels that are rendered. So yeah, you will incur a small additional cost by using another channel for a mask. That cost is not extra draw calls caused by extra UV coordinates, it is a small extra pixel shading time cost because it needs to sample another texture. But if you need a mask texture on your material, you will already incur the tiny performance penalty simply by sampling it at all, no matter where. Using an extra UV channel to map it to the mesh costs basically nothing.

So basically, yes, use your extra mask texture if you need it, it will cost a tiiiiny amount extra, but not nearly as much as an extra draw call.

I’m wondering about this myself, as I have two different approaches to achieve the same thing: Material ID Masks (for textures and such).

I could either bake a texture for the material IDs (ranging from 64x64 to 512x512 depending on the precision required) for each mesh, or I could simply have a single, static 64x64 image with regions for the mask, and use a secondary UV channel where I set the UV islands to the corresponding area. For this UV channel overlapping etc. wouldn’t matter, either.

With the first approach I’d need to bake material ID textures and create material instances where I’ve parameterized the mask texture, with the secondary approach I need to create custom UV channel but can, in most cases, use the same exact material.

While I don’t think the performance difference is big enough to matter in my case… I’m seeing conflicting information on this one. Here it seems UV channels can incur a heavier performance hit than what has been implied elsewhere, and also the information I can find predates nanite which might change things.