Materials on Mobile

I posted a question on the >forum< which sadly has been ignored so far, so let’s try here… its actually multiple questions:

Its about Materials for mobile devices.

A) Can I use math to adjust the UVs for mobile materials in Unreal Engine?
B) Why do I get the message of 3 Texture Samples in use, when nothing is connected to the material? This is a problem if I may only use 5 Texture Samples per Material on Mobile

The documentation reads: “Customized UVs should be used to avoid dependent texture fetches (no math on texture UVs).”

Does this mean I should not use UV nodes to rescale the textures? I have a base bump texture I use on various objects with different UV sizes… does this mean I should map this correctly within my 3D package and export it and not be able to vary anything in UE anymore, like rescaling the UVs? This would make me sad …

And another thing:
The documentation also says, that you may only use 5 texture samples. What I am wondering now, if I don’t connect anything to the Main Material Node, as in every attribute is not connected to anything, it tells me that three samples are already in use…

To troubleshoot I did the following:
Material is:
Surface > Opaque > Default Lit

I created a simple 0 Value and connected it to all available pins… Now it is reduced to 1 Texture Sample… but that does not make any sense… Help please! I found that two texture samples are being used when I do not connect anything into Ambient Occlusion, once I added my 0 to AO, the texture sample count dropped from 3 to 1. But I still have one going which does not make any sense…

The Material I am trying to setup is supposed to be a Basemat which has following options:

Basecolor: (3Vector) or Texture Sample (Tex Sample 1)
Roughness: Value or Texture Sample (Tex Sample 2) and Intensity
Bump: Texture Sample (Tex Sample 3)
or Normal: Texture Sample (Tex Sample 4)
Metallic 1 or 0

If I leave it as it is, i have 6 samples… and it obviously does not work. So I’ll try working around the AO, maybe by disabling the thing with a “1” but what exactly does it do? Can someone explain?
I am wondering why I cannot find anything about this, even though thousands of people use it to create mobile games… am I doing something wrong?

The workaround that I found and which is also advised in the documentation is, to use the Alpha of the Diffuse Map as Roughness Map. Which means I then don’t have 6 samples but 5 samples officially… but I am actually only using three and I do not understand it…

Thanks for the help!

hello :slight_smile:

As for the math on mobile…
It depends on your target mobile phones/tablets, you can use some math, if its very limited (and if you do, but any math you can avoid, the better of course.
And since you are catering mobile, anything you can do to optimize or avoid math is king.

Customized UV’s are great for this kind of thing… but how to set them up?
I’d check: Customized UVs in Unreal Engine Materials | Unreal Engine 5.2 Documentation to do so :slight_smile:

And the “three texture samples in use” isn’t only for texture samples you place.
Depending if the shader is set to tangent space normal maps or world space normal maps can save you 1 texture sample, as can unlit… but I dont know enough about this to give more in-depth advice.

It might be “smart” to look at the free infinity blade content on the marketplace to see how they solved it.

As for using a separate texture in each channel, that is a really good way to go and I try to use it wherever possible.
In some cases I will add the roughness or other grayscale texture (metal mask/AO/emissive mask) in all but the alpha channel or store them in a separate texture using each of the RGB channels for those aforementioned grayscale textures.