UDIM In Unreal Engine

Sometimes there's a need to use UDIMs in Unreal Engine without going into Virtual Texture land. I had to use this trick in UE4 quite a lot.
All you need is Custom node and a little bit of HLSL.

First prepare you inputs. You'll need you UVs (TexCoord) and Texture Sampler. I'd argue to actually sample texture within HLSL. This way you'd have more control. But sampling in graph is completely fine.

And inside Custom Node just add this.

if ( TexCoord.x > 4 ) {
    return Tex4;
}
if ( TexCoord.x > 3 ) {
    return Tex3;
}
if ( TexCoord.x > 2 ) {
    return Tex2;
}
if ( TexCoord.x > 1 ) {
    return Tex1;
}
return Tex0;

And if you need more slots, just add new quadrant on top.
If you're asking why we don't use If/Else - because in case all textures are present, we want to render them all out.

Main big downside of us sampling textures before switch (which it's technically) - we waste gpu time on sampling disregards if we need the texture or not.