Texture samplers limitation is still present in 4.9?


I am trying to setup some layered materials, but hitting the good old:

Error [SM5] warning X3206: implicit truncation of vector type
Error [SM5] error X4510: maximum ps_5_0 sampler register index (16) exceeded

Weren’t we promised like 100 samplers limitation after 4.6? Or am I mixing something up?

Also, are material functions also taken into account of the final samplers count?


Set texture sample node in material to Sample Source shared:wrap if i remember right to have more than 16.


Thanks a lot, Numbat!

That was it, it seems. Got it down to default 5 for now :slight_smile:

A sampler is something that tells the graphics card how to sample the textures (linear filtering, point filtering, wrap addressing, etc). The 16 sampler limit is a d3d11 limit and not something we can change. HOWEVER you can use fewer samplers in your material with the shared sampler setting to use up to 128 unique textures.

Thanks for your explanation Daniel.

As I mentioned, I was able to bring the count down by setting them to “Shared”. I don’t think one would ever need 128 samplers in one material, but without using Shared setting, it’s easy to max out the 16 samplers, especially when using layered materials - rbg masks, baked normals, color overlays and such. But the biggest hit was actually coming from the material layers themselves. It looks like the samplers from material layers are also taken into account in final material.

So I’ve been trying to get this to work with a terrain material, but no matter what I do it still counts each unique texture towards the total number of texture samplers used, even when I have every single texture set to “shared: wrap” in the texture sample node :frowning:

I do see the number drop when I start changing the sampler source to shared, but as soon as I save it, the number goes back up to what it would be if I had never changed the sampler source…

Right now it says that my terrain material is using 9 samplers when I save it, and it went down to 7 when I had changed all sampler sources to use “shared wrap”, however I am technically using 11 unique textures (one of which is placed in the material as a single instance texture object). Is there anything else that might contribute to the texture samplers?

I’ve also gone through all of the material functions that I may have and realized there are a few texture samplers within them, so I changed those to also used shared wrap for the sampler source, which now helps bring down the total to 8 in the master terrain material, but based on all the things involved in my material I can’t seem to get the numbers to add up to 8, so I feel like there’s something hidden.

Also, with this terrain material I can’t ever seem to use more than 11 texture samplers, which I read was due to the other 4 or 5 slots being used for other rendering functionality such as lightmaps and such(and it seems that turning on decal dbuffer in the rendering options also requires the use of a sampler slot).

I’m also using force no precomputed shadows to have all dynamic lighting, from what I recall in UDK this would free up additional sampler slots from the lighting, but doesn’t seem to do so in UE4?

@tsnodgrass - UE4 has a completely different Renderer so it stands to reason that it wouldn’t be the same in UDK, and some of those texture samplers are indeed used for rendering features (reflections, lighting etc) - all lit materials have that cost. The 16-sampler limit is a DirectX limitation not an engine one - so there’s literally nothing they can do about it. Even DX12 still has the 16-sampler limit I think. No idea what Vulkan allows.

If I remember rightly, samplers hidden away inside Material Functions won’t ‘share’ with other ones even if they belong to the same material - the shared ones need to be part of the same node graph. Don’t take that to the bank though. Also, sharing screenshots of materials of copy-pasting the text code will help here :wink:

What a bump…